tag what container to backup and to run the steps against
This commit is contained in:
parent
3a7dd1d2b2
commit
1b09212f6d
@ -44,6 +44,8 @@ type Target struct {
|
||||
Kind string `json:"kind"`
|
||||
Name string `json:"name"`
|
||||
// +optional
|
||||
ContainerName string `json:"containerName"`
|
||||
// +optional
|
||||
ApiVersion string `json:"apiVersion,omitempty"`
|
||||
// +optional
|
||||
VolumeMounts []corev1.VolumeMount `json:"volumeMounts,omitempty"`
|
||||
|
||||
@ -19,6 +19,8 @@ const (
|
||||
RESTORE_ANNOTATION = "restore"
|
||||
// the name of the sidecar container
|
||||
SIDECARCONTAINER_NAME string = "formol"
|
||||
// the name of the container we backup when there are more than 1 container in the pod
|
||||
TARGETCONTAINER_TAG string = "FORMOL_TARGET"
|
||||
// Used by both the backupsession and restoresession controllers to identified the target deployment
|
||||
TARGET_NAME string = "TARGET_NAME"
|
||||
// Used by restoresession controller
|
||||
|
||||
@ -214,11 +214,19 @@ func (r *BackupConfigurationReconciler) Reconcile(ctx context.Context, req recon
|
||||
return err
|
||||
}
|
||||
log.V(1).Info("got deployment", "Deployment", deployment)
|
||||
for _, container := range deployment.Spec.Template.Spec.Containers {
|
||||
for i, container := range deployment.Spec.Template.Spec.Containers {
|
||||
if container.Name == formolv1alpha1.SIDECARCONTAINER_NAME {
|
||||
log.V(0).Info("There is already a backup sidecar container. Skipping", "container", container)
|
||||
return nil
|
||||
}
|
||||
if target.ContainerName != "" && target.ContainerName == container.Name {
|
||||
// Put a tag so we can find what container we are supposed to backup
|
||||
// and what process we are supposed to chroot to run the init steps
|
||||
deployment.Spec.Template.Spec.Containers[i].Env = append(container.Env, corev1.EnvVar{
|
||||
Name: formolv1alpha1.TARGETCONTAINER_TAG,
|
||||
Value: "True",
|
||||
})
|
||||
}
|
||||
}
|
||||
sidecar := corev1.Container{
|
||||
Name: formolv1alpha1.SIDECARCONTAINER_NAME,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user