Skip to content

Commit

Permalink
[ADD] Add Volume for using secret or configmap in k8s, Add VolumeMoun…
Browse files Browse the repository at this point in the history
…ts for mount volume, Add BackendOpts for using custom options in k8up or restic

Signed-off-by: Pooya Azarpour <[email protected]>
  • Loading branch information
poyaz committed Mar 18, 2024
1 parent 2ea688a commit 8eb0703
Show file tree
Hide file tree
Showing 10 changed files with 2,992 additions and 2 deletions.
10 changes: 10 additions & 0 deletions api/v1/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ type (
Swift *SwiftSpec `json:"swift,omitempty"`
B2 *B2Spec `json:"b2,omitempty"`
Rest *RestServerSpec `json:"rest,omitempty"`

Options *BackendOpts `json:"options,omitempty"`
}

// +k8s:deepcopy-gen=false
Expand Down Expand Up @@ -116,6 +118,7 @@ type S3Spec struct {
Bucket string `json:"bucket,omitempty"`
AccessKeyIDSecretRef *corev1.SecretKeySelector `json:"accessKeyIDSecretRef,omitempty"`
SecretAccessKeySecretRef *corev1.SecretKeySelector `json:"secretAccessKeySecretRef,omitempty"`
VolumeMounts *[]corev1.VolumeMount `json:"volumeMounts,omitempty"`
}

// EnvVars returns the env vars for this backend.
Expand Down Expand Up @@ -265,6 +268,7 @@ type RestServerSpec struct {
URL string `json:"url,omitempty"`
UserSecretRef *corev1.SecretKeySelector `json:"userSecretRef,omitempty"`
PasswordSecretReg *corev1.SecretKeySelector `json:"passwordSecretReg,omitempty"`
VolumeMounts *[]corev1.VolumeMount `json:"volumeMounts,omitempty"`
}

// EnvVars returns the env vars for this backend.
Expand All @@ -279,3 +283,9 @@ func (in *RestServerSpec) String() string {
protocol, url, _ := strings.Cut(in.URL, "://")
return fmt.Sprintf("rest:%s://%s:%s@%s", protocol, "$(USER)", "$(PASSWORD)", url)
}

type BackendOpts struct {
CACert string `json:"caCert,omitempty"`
ClientCert string `json:"clientCert,omitempty"`
ClientKey string `json:"clientKey,omitempty"`
}
11 changes: 9 additions & 2 deletions api/v1/restore_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ type RestoreSpec struct {
// RestoreMethod contains how and where the restore should happen
// all the settings are mutual exclusive.
type RestoreMethod struct {
S3 *S3Spec `json:"s3,omitempty"`
Folder *FolderRestore `json:"folder,omitempty"`
S3 *S3Spec `json:"s3,omitempty"`
Folder *FolderRestore `json:"folder,omitempty"`
Options *RestoreOpts `json:"options,omitempty"`
}

type FolderRestore struct {
Expand Down Expand Up @@ -145,3 +146,9 @@ func init() {
var (
RestoreKind = reflect.TypeOf(Restore{}).Name()
)

type RestoreOpts struct {
CACert string `json:"caCert,omitempty"`
ClientCert string `json:"clientCert,omitempty"`
ClientKey string `json:"clientKey,omitempty"`
}
23 changes: 23 additions & 0 deletions api/v1/runnable_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,34 @@ type RunnableSpec struct {
// PodSecurityContext describes the security context with which this action shall be executed.
PodSecurityContext *corev1.PodSecurityContext `json:"podSecurityContext,omitempty"`

// Volumes List of volumes that can be mounted by containers belonging to the pod.
Volumes *[]RunnableVolumeSpec `json:"volumes,omitempty"`

// ActiveDeadlineSeconds specifies the duration in seconds relative to the startTime that the job may be continuously active before the system tries to terminate it.
// Value must be positive integer if given.
ActiveDeadlineSeconds *int64 `json:"activeDeadlineSeconds,omitempty"`
}

type RunnableVolumeSpec struct {
// name of the volume.
// Must be a DNS_LABEL and unique within the pod.
// More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
Name string `json:"name"`

// persistentVolumeClaimVolumeSource represents a reference to a
// PersistentVolumeClaim in the same namespace.
// More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#persistentvolumeclaims
// +optional
PersistentVolumeClaim *corev1.PersistentVolumeClaimVolumeSource `json:"persistentVolumeClaim,omitempty"`
// secret represents a secret that should populate this volume.
// More info: https://kubernetes.io/docs/concepts/storage/volumes#secret
// +optional
Secret *corev1.SecretVolumeSource `json:"secret,omitempty"`
// configMap represents a configMap that should populate this volume
// +optional
ConfigMap *corev1.ConfigMapVolumeSource `json:"configMap,omitempty"`
}

// AppendEnvFromToContainer will add EnvFromSource from the given RunnableSpec to the Container
func (in *RunnableSpec) AppendEnvFromToContainer(containerSpec *corev1.Container) {
if in.Backend != nil {
Expand Down
103 changes: 103 additions & 0 deletions api/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 8eb0703

Please sign in to comment.