Skip to content

Commit ff85fd1

Browse files
committed
add image pull secret
Signed-off-by: Name Soname <[email protected]>
1 parent 95398eb commit ff85fd1

File tree

8 files changed

+25
-4
lines changed

8 files changed

+25
-4
lines changed

charts/k8up/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ keywords:
66
- backup
77
- operator
88
- restic
9-
version: 4.4.3
9+
version: 4.4.4
1010
sources:
1111
- https://github.com/k8up-io/k8up
1212
maintainers:

charts/k8up/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# k8up
22

3-
![Version: 4.4.3](https://img.shields.io/badge/Version-4.4.3-informational?style=flat-square)
3+
![Version: 4.4.4](https://img.shields.io/badge/Version-4.4.4-informational?style=flat-square)
44

55
Kubernetes and OpenShift Backup Operator based on restic
66

@@ -13,7 +13,7 @@ helm repo add k8up-io https://k8up-io.github.io/k8up
1313
helm install k8up k8up-io/k8up
1414
```
1515
```bash
16-
kubectl apply -f https://github.com/k8up-io/k8up/releases/download/k8up-4.4.3/k8up-crd.yaml
16+
kubectl apply -f https://github.com/k8up-io/k8up/releases/download/k8up-4.4.4/k8up-crd.yaml
1717
```
1818

1919
<!---
@@ -53,7 +53,7 @@ Document your changes in values.yaml and let `make docs:helm` generate this sect
5353
| k8up.backupImage.repository | string | `""` | The backup runner image repository. Defaults to `{image.registry}/{image.repository}`. Specify an image repository including registry, e.g. `example.com/repo/image` |
5454
| k8up.backupImage.tag | string | `""` | The backup runner image tag Defaults to `{image.tag}` |
5555
| k8up.enableLeaderElection | bool | `true` | Specifies whether leader election should be enabled. |
56-
| k8up.envVars | list | `[]` | envVars allows the specification of additional environment variables. See [values.yaml](values.yaml) how to specify See documentation which variables are supported. |
56+
| k8up.envVars | list | `[]` | envVars allows the specification of additional environment variables. See [values.yaml](values.yaml) how to specify See documentation which variables are supported. List of names of imagePullSecrets for backupImage Example: imagePullSecrets: "one_secret, two_secret" |
5757
| k8up.globalResources | object | empty values | Specify the resource requests and limits that the Pods should have when they are scheduled by K8up. You are still able to override those via K8up resources, but this gives cluster administrators custom defaults. |
5858
| k8up.globalResources.limits.cpu | string | `""` | Global CPU resource limit applied to jobs. See [supported units][resource-units]. |
5959
| k8up.globalResources.limits.memory | string | `""` | Global Memory resource limit applied to jobs. See [supported units][resource-units]. |

charts/k8up/templates/deployment.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ spec:
3232
env:
3333
- name: BACKUP_IMAGE
3434
value: "{{ include "k8up.backupImage" . }}"
35+
{{- with .Values.k8up.imagePullSecrets }}
36+
- name: IMAGE_SECRETS
37+
value: "{{ . }}"
38+
{{- end }}
3539
{{- with .Values.k8up.timezone }}
3640
- name: TZ
3741
value: {{ . }}

charts/k8up/values.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ k8up:
2626
# -- envVars allows the specification of additional environment variables.
2727
# See [values.yaml](values.yaml) how to specify
2828
# See documentation which variables are supported.
29+
30+
# List of names of imagePullSecrets for backupImage
31+
# Example:
32+
# imagePullSecrets: "one_secret, two_secret"
2933
envVars: []
3034
# - name: BACKUP_GLOBALACCESSKEYID
3135
# valueFrom:

cmd/operator/main.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ const (
2525
leaderElectionID = "d2ab61da.syn.tools"
2626
argCommandRestic = "command-restic"
2727
argResticOptions = "restic-options"
28+
listImageSecrets = "ImageSecretPulls"
2829
)
2930

3031
var (
@@ -64,6 +65,7 @@ var (
6465
&cli.StringFlag{Destination: &cfg.Config.GlobalMemoryResourceLimit, Name: "global-memory-limit", EnvVars: []string{"BACKUP_GLOBAL_MEMORY_LIMIT"}, Usage: "set the memory limit for scheduled jobs"},
6566

6667
&cli.StringFlag{Destination: &cfg.Config.BackupImage, Name: "image", EnvVars: []string{"BACKUP_IMAGE"}, Value: "ghcr.io/k8up-io/k8up:latest", Usage: "URL of the restic image"},
68+
&cli.StringSliceFlag{Name: listImageSecrets, EnvVars: []string{"IMAGE_SECRETS"}, Usage: "Secrets for access to $BACKUP_IMAGE"},
6769
&cli.StringSliceFlag{Name: argCommandRestic, EnvVars: []string{"BACKUP_COMMAND_RESTIC"}, Value: cli.NewStringSlice("/usr/local/bin/k8up", "restic"), Usage: "The command that is executed for restic backups."},
6870
&cli.StringSliceFlag{Name: argResticOptions, EnvVars: []string{"BACKUP_RESTIC_OPTIONS"}, Usage: "Pass custom restic options in the form 'key=value,key2=value2'. See https://restic.readthedocs.io/en/stable/manual_rest.html?highlight=--option#usage-help"},
6971
&cli.StringFlag{Destination: &cfg.Config.MountPath, Name: "datapath", Aliases: []string{"mountpath"}, EnvVars: []string{"BACKUP_DATAPATH"}, Value: "/data", Usage: "to which path the PVCs should get mounted in the backup container"},
@@ -91,6 +93,7 @@ func operatorMain(c *cli.Context) error {
9193

9294
cfg.Config.BackupCommandRestic = c.StringSlice(argCommandRestic)
9395
cfg.Config.ResticOptions = strings.Join(c.StringSlice(argResticOptions), ",")
96+
cfg.Config.ImageSecrets = c.StringSlice(listImageSecrets)
9497

9598
err := validateQuantityFlags(c)
9699
if err != nil {

operator/cfg/config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ type Configuration struct {
7070
GlobalMemoryResourceRequest string
7171
GlobalMemoryResourceLimit string
7272
BackupImage string
73+
ImageSecrets []string
7374
BackupCommandRestic []string
7475
MetricsBindAddress string
7576
PodExecRoleName string

operator/job/job.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,14 @@ func MutateBatchJob(batchJob *batchv1.Job, jobObj k8upv1.JobObject, config Confi
6060
batchJob.Spec.Template.Spec.RestartPolicy = corev1.RestartPolicyOnFailure
6161
batchJob.Spec.Template.Spec.SecurityContext = jobObj.GetPodSecurityContext()
6262

63+
if len(cfg.Config.ImageSecrets) != 0 {
64+
var imPulSecs []corev1.LocalObjectReference
65+
for _, secret := range cfg.Config.ImageSecrets {
66+
imPulSecs = append(imPulSecs, corev1.LocalObjectReference{Name: secret})
67+
}
68+
batchJob.Spec.Template.Spec.ImagePullSecrets = imPulSecs
69+
}
70+
6371
containers := batchJob.Spec.Template.Spec.Containers
6472
if len(containers) == 0 {
6573
containers = make([]corev1.Container, 1)

restic/cfg/config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ type Configuration struct {
4444
ResticBin string
4545
ResticRepository string
4646
ResticOptions string
47+
ImageSecrets []string
4748

4849
RestoreDir string
4950
RestoreS3Endpoint string

0 commit comments

Comments
 (0)