added local repository for restic
This commit is contained in:
parent
0c2d2d8f54
commit
5090b5fb1a
@ -24,6 +24,8 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
RESTIC_REPO_VOLUME = "restic-volume"
|
||||||
|
RESTIC_REPO_PATH = "/restic-repo"
|
||||||
RESTIC_REPOSITORY = "RESTIC_REPOSITORY"
|
RESTIC_REPOSITORY = "RESTIC_REPOSITORY"
|
||||||
RESTIC_PASSWORD = "RESTIC_PASSWORD"
|
RESTIC_PASSWORD = "RESTIC_PASSWORD"
|
||||||
AWS_ACCESS_KEY_ID = "AWS_ACCESS_KEY_ID"
|
AWS_ACCESS_KEY_ID = "AWS_ACCESS_KEY_ID"
|
||||||
@ -38,7 +40,7 @@ type S3 struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Local struct {
|
type Local struct {
|
||||||
Path string `json:"path"`
|
corev1.VolumeSource `json:"source"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Backend struct {
|
type Backend struct {
|
||||||
@ -115,7 +117,7 @@ func (repo *Repo) GetResticEnv(backupConf BackupConfiguration) []corev1.EnvVar {
|
|||||||
if repo.Spec.Backend.Local != nil {
|
if repo.Spec.Backend.Local != nil {
|
||||||
env = append(env, corev1.EnvVar{
|
env = append(env, corev1.EnvVar{
|
||||||
Name: RESTIC_REPOSITORY,
|
Name: RESTIC_REPOSITORY,
|
||||||
Value: repo.Spec.Backend.Local.Path,
|
Value: RESTIC_REPO_PATH,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
env = append(env, corev1.EnvVar{
|
env = append(env, corev1.EnvVar{
|
||||||
|
|||||||
@ -37,7 +37,7 @@ func (in *Backend) DeepCopyInto(out *Backend) {
|
|||||||
if in.Local != nil {
|
if in.Local != nil {
|
||||||
in, out := &in.Local, &out.Local
|
in, out := &in.Local, &out.Local
|
||||||
*out = new(Local)
|
*out = new(Local)
|
||||||
**out = **in
|
(*in).DeepCopyInto(*out)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -350,6 +350,7 @@ func (in *Keep) DeepCopy() *Keep {
|
|||||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||||
func (in *Local) DeepCopyInto(out *Local) {
|
func (in *Local) DeepCopyInto(out *Local) {
|
||||||
*out = *in
|
*out = *in
|
||||||
|
in.VolumeSource.DeepCopyInto(&out.VolumeSource)
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Local.
|
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Local.
|
||||||
|
|||||||
@ -187,7 +187,7 @@ func (r *BackupConfigurationReconciler) DeleteSidecar(backupConf formolv1alpha1.
|
|||||||
if repo.Spec.Backend.Local != nil {
|
if repo.Spec.Backend.Local != nil {
|
||||||
restoreVolumes := []corev1.Volume{}
|
restoreVolumes := []corev1.Volume{}
|
||||||
for _, volume := range targetPodSpec.Volumes {
|
for _, volume := range targetPodSpec.Volumes {
|
||||||
if volume.Name == "restic-local-repo" {
|
if volume.Name == formolv1alpha1.RESTIC_REPO_VOLUME {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
restoreVolumes = append(restoreVolumes, volume)
|
restoreVolumes = append(restoreVolumes, volume)
|
||||||
@ -310,14 +310,12 @@ func (r *BackupConfigurationReconciler) addOnlineSidecar(backupConf formolv1alph
|
|||||||
})
|
})
|
||||||
if repo.Spec.Backend.Local != nil {
|
if repo.Spec.Backend.Local != nil {
|
||||||
sidecar.VolumeMounts = append(vms, corev1.VolumeMount{
|
sidecar.VolumeMounts = append(vms, corev1.VolumeMount{
|
||||||
Name: "restic-local-repo",
|
Name: formolv1alpha1.RESTIC_REPO_VOLUME,
|
||||||
MountPath: "/repo",
|
MountPath: formolv1alpha1.RESTIC_REPO_PATH,
|
||||||
})
|
})
|
||||||
targetPodSpec.Volumes = append(targetPodSpec.Volumes, corev1.Volume{
|
targetPodSpec.Volumes = append(targetPodSpec.Volumes, corev1.Volume{
|
||||||
Name: "restic-local-repo",
|
Name: formolv1alpha1.RESTIC_REPO_VOLUME,
|
||||||
VolumeSource: corev1.VolumeSource{
|
VolumeSource: repo.Spec.Backend.Local.VolumeSource,
|
||||||
EmptyDir: &corev1.EmptyDirVolumeSource{},
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
sidecar.VolumeMounts = vms
|
sidecar.VolumeMounts = vms
|
||||||
|
|||||||
@ -79,7 +79,8 @@ metadata:
|
|||||||
spec:
|
spec:
|
||||||
backend:
|
backend:
|
||||||
local:
|
local:
|
||||||
path: /repo
|
source:
|
||||||
|
emptyDir:
|
||||||
repositorySecrets: secret-minio
|
repositorySecrets: secret-minio
|
||||||
---
|
---
|
||||||
apiVersion: formol.desmojim.fr/v1alpha1
|
apiVersion: formol.desmojim.fr/v1alpha1
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user