Added 'image' tag to BackupConfiguration to allow users to specify what container image to use as a sidecar container
This commit is contained in:
parent
efc6114586
commit
ba5fc36712
@ -69,6 +69,7 @@ type Keep struct {
|
|||||||
// BackupConfigurationSpec defines the desired state of BackupConfiguration
|
// BackupConfigurationSpec defines the desired state of BackupConfiguration
|
||||||
type BackupConfigurationSpec struct {
|
type BackupConfigurationSpec struct {
|
||||||
Repository string `json:"repository"`
|
Repository string `json:"repository"`
|
||||||
|
Image string `json:"image"`
|
||||||
|
|
||||||
// +optional
|
// +optional
|
||||||
Suspend *bool `json:"suspend,omitempty"`
|
Suspend *bool `json:"suspend,omitempty"`
|
||||||
|
|||||||
@ -58,6 +58,7 @@ var _ reconcile.Reconciler = &BackupConfigurationReconciler{}
|
|||||||
// +kubebuilder:rbac:groups=rbac.authorization.k8s.io,resources=clusterrolebindings,verbs=get;list;watch;create;update;patch;delete
|
// +kubebuilder:rbac:groups=rbac.authorization.k8s.io,resources=clusterrolebindings,verbs=get;list;watch;create;update;patch;delete
|
||||||
// +kubebuilder:rbac:groups=batch,resources=cronjobs,verbs=get;list;watch;create;update;patch;delete
|
// +kubebuilder:rbac:groups=batch,resources=cronjobs,verbs=get;list;watch;create;update;patch;delete
|
||||||
// +kubebuilder:rbac:groups=batch,resources=cronjobs/status,verbs=get
|
// +kubebuilder:rbac:groups=batch,resources=cronjobs/status,verbs=get
|
||||||
|
// +kubebuilder:rbac:groups=coordination.k8s.io,resources=leases,verbs=get;list;create;update
|
||||||
|
|
||||||
func (r *BackupConfigurationReconciler) Reconcile(ctx context.Context, req reconcile.Request) (reconcile.Result, error) {
|
func (r *BackupConfigurationReconciler) Reconcile(ctx context.Context, req reconcile.Request) (reconcile.Result, error) {
|
||||||
var changed bool
|
var changed bool
|
||||||
@ -151,7 +152,7 @@ func (r *BackupConfigurationReconciler) Reconcile(ctx context.Context, req recon
|
|||||||
Containers: []corev1.Container{
|
Containers: []corev1.Container{
|
||||||
corev1.Container{
|
corev1.Container{
|
||||||
Name: "job-createbackupsession-" + backupConf.Name,
|
Name: "job-createbackupsession-" + backupConf.Name,
|
||||||
Image: "desmo999r/formolcli:latest",
|
Image: backupConf.Spec.Image,
|
||||||
Args: []string{
|
Args: []string{
|
||||||
"backupsession",
|
"backupsession",
|
||||||
"create",
|
"create",
|
||||||
@ -220,7 +221,7 @@ func (r *BackupConfigurationReconciler) Reconcile(ctx context.Context, req recon
|
|||||||
sidecar := corev1.Container{
|
sidecar := corev1.Container{
|
||||||
Name: formolv1alpha1.SIDECARCONTAINER_NAME,
|
Name: formolv1alpha1.SIDECARCONTAINER_NAME,
|
||||||
// TODO: Put the image in the BackupConfiguration YAML file
|
// TODO: Put the image in the BackupConfiguration YAML file
|
||||||
Image: "desmo999r/formolcli:latest",
|
Image: backupConf.Spec.Image,
|
||||||
Args: []string{"backupsession", "server"},
|
Args: []string{"backupsession", "server"},
|
||||||
//Image: "busybox",
|
//Image: "busybox",
|
||||||
//Command: []string{
|
//Command: []string{
|
||||||
|
|||||||
@ -41,6 +41,7 @@ var _ = Describe("Testing BackupConf controller", func() {
|
|||||||
Spec: formolv1alpha1.BackupConfigurationSpec{
|
Spec: formolv1alpha1.BackupConfigurationSpec{
|
||||||
Repository: TestRepoName,
|
Repository: TestRepoName,
|
||||||
Schedule: "1 * * * *",
|
Schedule: "1 * * * *",
|
||||||
|
Image: "desmo999r/formolcli:latest",
|
||||||
Targets: []formolv1alpha1.Target{
|
Targets: []formolv1alpha1.Target{
|
||||||
formolv1alpha1.Target{
|
formolv1alpha1.Target{
|
||||||
Kind: formolv1alpha1.SidecarKind,
|
Kind: formolv1alpha1.SidecarKind,
|
||||||
|
|||||||
@ -57,6 +57,7 @@ var _ reconcile.Reconciler = &BackupSessionReconciler{}
|
|||||||
// +kubebuilder:rbac:groups=formol.desmojim.fr,resources=backupsessions/status,verbs=get;update;patch;create;delete
|
// +kubebuilder:rbac:groups=formol.desmojim.fr,resources=backupsessions/status,verbs=get;update;patch;create;delete
|
||||||
// +kubebuilder:rbac:groups=formol.desmojim.fr,resources=functions,verbs=get;list;watch
|
// +kubebuilder:rbac:groups=formol.desmojim.fr,resources=functions,verbs=get;list;watch
|
||||||
// +kubebuilder:rbac:groups=batch,resources=jobs,verbs=get;list;create;update;patch;delete;watch
|
// +kubebuilder:rbac:groups=batch,resources=jobs,verbs=get;list;create;update;patch;delete;watch
|
||||||
|
// +kubebuilder:rbac:groups=coordination.k8s.io,resources=leases,verbs=get;list;create;update
|
||||||
|
|
||||||
func (r *BackupSessionReconciler) Reconcile(ctx context.Context, req reconcile.Request) (reconcile.Result, error) {
|
func (r *BackupSessionReconciler) Reconcile(ctx context.Context, req reconcile.Request) (reconcile.Result, error) {
|
||||||
log := r.Log.WithValues("backupsession", req.NamespacedName)
|
log := r.Log.WithValues("backupsession", req.NamespacedName)
|
||||||
@ -105,7 +106,7 @@ func (r *BackupSessionReconciler) Reconcile(ctx context.Context, req reconcile.R
|
|||||||
if target.SessionState == formolv1alpha1.Success {
|
if target.SessionState == formolv1alpha1.Success {
|
||||||
deleteSnapshots = append(deleteSnapshots, corev1.Container{
|
deleteSnapshots = append(deleteSnapshots, corev1.Container{
|
||||||
Name: target.Name,
|
Name: target.Name,
|
||||||
Image: "desmo999r/formolcli:latest",
|
Image: backupConf.Spec.Image,
|
||||||
Args: []string{"snapshot", "delete", "--snapshot-id", target.SnapshotId},
|
Args: []string{"snapshot", "delete", "--snapshot-id", target.SnapshotId},
|
||||||
Env: env,
|
Env: env,
|
||||||
})
|
})
|
||||||
@ -164,7 +165,7 @@ func (r *BackupSessionReconciler) Reconcile(ctx context.Context, req reconcile.R
|
|||||||
}
|
}
|
||||||
restic := corev1.Container{
|
restic := corev1.Container{
|
||||||
Name: "restic",
|
Name: "restic",
|
||||||
Image: "desmo999r/formolcli:latest",
|
Image: backupConf.Spec.Image,
|
||||||
Args: []string{"volume", "backup", "--tag", backupSession.Name, "--path", "/output"},
|
Args: []string{"volume", "backup", "--tag", backupSession.Name, "--path", "/output"},
|
||||||
VolumeMounts: []corev1.VolumeMount{output},
|
VolumeMounts: []corev1.VolumeMount{output},
|
||||||
Env: backupSessionEnv,
|
Env: backupSessionEnv,
|
||||||
|
|||||||
@ -55,6 +55,7 @@ var _ reconcile.Reconciler = &RestoreSessionReconciler{}
|
|||||||
|
|
||||||
// +kubebuilder:rbac:groups=formol.desmojim.fr,resources=restoresessions,verbs=get;list;watch;create;update;patch;delete
|
// +kubebuilder:rbac:groups=formol.desmojim.fr,resources=restoresessions,verbs=get;list;watch;create;update;patch;delete
|
||||||
// +kubebuilder:rbac:groups=formol.desmojim.fr,resources=restoresessions/status,verbs=get;update;patch
|
// +kubebuilder:rbac:groups=formol.desmojim.fr,resources=restoresessions/status,verbs=get;update;patch
|
||||||
|
// +kubebuilder:rbac:groups=coordination.k8s.io,resources=leases,verbs=get;list;create;update
|
||||||
|
|
||||||
func (r *RestoreSessionReconciler) Reconcile(ctx context.Context, req reconcile.Request) (reconcile.Result, error) {
|
func (r *RestoreSessionReconciler) Reconcile(ctx context.Context, req reconcile.Request) (reconcile.Result, error) {
|
||||||
log := log.FromContext(ctx).WithValues("restoresession", req.NamespacedName)
|
log := log.FromContext(ctx).WithValues("restoresession", req.NamespacedName)
|
||||||
@ -127,19 +128,16 @@ func (r *RestoreSessionReconciler) Reconcile(ctx context.Context, req reconcile.
|
|||||||
Name: "output",
|
Name: "output",
|
||||||
MountPath: "/output",
|
MountPath: "/output",
|
||||||
}
|
}
|
||||||
//for _, targetStatus := range backupSession.Status.Targets {
|
|
||||||
//if targetStatus.Name == target.Name {
|
|
||||||
//snapshotId := targetStatus.SnapshotId
|
|
||||||
restic := corev1.Container{
|
restic := corev1.Container{
|
||||||
Name: "restic",
|
Name: "restic",
|
||||||
Image: "desmo999r/formolcli:latest",
|
Image: backupConf.Spec.Image,
|
||||||
Args: []string{"volume", "restore", "--snapshot-id", snapshotId},
|
Args: []string{"volume", "restore", "--snapshot-id", snapshotId},
|
||||||
VolumeMounts: []corev1.VolumeMount{output},
|
VolumeMounts: []corev1.VolumeMount{output},
|
||||||
Env: restoreSessionEnv,
|
Env: restoreSessionEnv,
|
||||||
}
|
}
|
||||||
finalizer := corev1.Container{
|
finalizer := corev1.Container{
|
||||||
Name: "finalizer",
|
Name: "finalizer",
|
||||||
Image: "desmo999r/formolcli:latest",
|
Image: backupConf.Spec.Image,
|
||||||
Args: []string{"target", "finalize"},
|
Args: []string{"target", "finalize"},
|
||||||
VolumeMounts: []corev1.VolumeMount{output},
|
VolumeMounts: []corev1.VolumeMount{output},
|
||||||
Env: restoreSessionEnv,
|
Env: restoreSessionEnv,
|
||||||
@ -214,8 +212,6 @@ func (r *RestoreSessionReconciler) Reconcile(ctx context.Context, req reconcile.
|
|||||||
if err := r.Create(ctx, job); err != nil {
|
if err := r.Create(ctx, job); err != nil {
|
||||||
log.Error(err, "unable to create job", "job", job)
|
log.Error(err, "unable to create job", "job", job)
|
||||||
return err
|
return err
|
||||||
//}
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -263,9 +259,6 @@ func (r *RestoreSessionReconciler) Reconcile(ctx context.Context, req reconcile.
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//for _, targetStatus := range backupSession.Status.Targets {
|
|
||||||
//if targetStatus.Name == target.Name && targetStatus.Kind == target.Kind {
|
|
||||||
//snapshotId := targetStatus.SnapshotId
|
|
||||||
restoreSessionEnv := []corev1.EnvVar{
|
restoreSessionEnv := []corev1.EnvVar{
|
||||||
corev1.EnvVar{
|
corev1.EnvVar{
|
||||||
Name: formolv1alpha1.TARGET_NAME,
|
Name: formolv1alpha1.TARGET_NAME,
|
||||||
@ -282,7 +275,7 @@ func (r *RestoreSessionReconciler) Reconcile(ctx context.Context, req reconcile.
|
|||||||
}
|
}
|
||||||
initContainer := corev1.Container{
|
initContainer := corev1.Container{
|
||||||
Name: RESTORESESSION,
|
Name: RESTORESESSION,
|
||||||
Image: formolutils.FORMOLCLI,
|
Image: backupConf.Spec.Image,
|
||||||
Args: []string{"volume", "restore", "--snapshot-id", snapshotId},
|
Args: []string{"volume", "restore", "--snapshot-id", snapshotId},
|
||||||
VolumeMounts: target.VolumeMounts,
|
VolumeMounts: target.VolumeMounts,
|
||||||
Env: restoreSessionEnv,
|
Env: restoreSessionEnv,
|
||||||
@ -305,9 +298,6 @@ func (r *RestoreSessionReconciler) Reconcile(ctx context.Context, req reconcile.
|
|||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
//}
|
|
||||||
//}
|
|
||||||
//return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
startNextTask := func() (*formolv1alpha1.TargetStatus, error) {
|
startNextTask := func() (*formolv1alpha1.TargetStatus, error) {
|
||||||
|
|||||||
@ -168,6 +168,7 @@ var (
|
|||||||
},
|
},
|
||||||
Spec: formolv1alpha1.BackupConfigurationSpec{
|
Spec: formolv1alpha1.BackupConfigurationSpec{
|
||||||
Repository: TestRepoName,
|
Repository: TestRepoName,
|
||||||
|
Image: "desmo999r/formolcli:latest",
|
||||||
Schedule: "1 * * * *",
|
Schedule: "1 * * * *",
|
||||||
Keep: formolv1alpha1.Keep{
|
Keep: formolv1alpha1.Keep{
|
||||||
Last: 2,
|
Last: 2,
|
||||||
|
|||||||
@ -7,10 +7,6 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
|
||||||
FORMOLCLI string = "desmo999r/formolcli:latest"
|
|
||||||
)
|
|
||||||
|
|
||||||
func ContainsString(slice []string, s string) bool {
|
func ContainsString(slice []string, s string) bool {
|
||||||
for _, item := range slice {
|
for _, item := range slice {
|
||||||
if item == s {
|
if item == s {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user