Skip to content

Commit

Permalink
K8SPXC-1337: add initContainer to backup job (#1754)
Browse files Browse the repository at this point in the history
* K8SPXC-1337: add initContainer to backup job

https://perconadev.atlassian.net/browse/K8SPXC-1337

* add volumes and volumeMounts

* fix securityContext

* fix tests

---------

Co-authored-by: Viacheslav Sarzhan <[email protected]>
  • Loading branch information
pooknull and hors authored Jul 10, 2024
1 parent 033cdae commit 7037956
Show file tree
Hide file tree
Showing 18 changed files with 273 additions and 1 deletion.
1 change: 1 addition & 0 deletions build/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ COPY --from=go_builder /usr/local/bin/pitr /pitr
COPY build/pxc-entrypoint.sh /pxc-entrypoint.sh
COPY build/pxc-init-entrypoint.sh /pxc-init-entrypoint.sh
COPY build/pitr-init-entrypoint.sh /pitr-init-entrypoint.sh
COPY build/backup-init-entrypoint.sh /backup-init-entrypoint.sh
COPY build/unsafe-bootstrap.sh /unsafe-bootstrap.sh
COPY build/pxc-configure-pxc.sh /pxc-configure-pxc.sh
COPY build/liveness-check.sh /liveness-check.sh
Expand Down
6 changes: 6 additions & 0 deletions build/backup-init-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

set -o errexit
set -o xtrace

install -o "$(id -u)" -g "$(id -g)" -m 0755 -D /peer-list /opt/percona/peer-list
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,26 @@ spec:
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /opt/percona
name: bin
- mountPath: /etc/mysql/ssl
name: ssl
- mountPath: /etc/mysql/ssl-internal
name: ssl-internal
- mountPath: /etc/mysql/vault-keyring-secret
name: vault-keyring-secret
dnsPolicy: ClusterFirst
initContainers:
- command:
- /backup-init-entrypoint.sh
imagePullPolicy: Always
name: backup-init
resources: {}
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /opt/percona
name: bin
restartPolicy: Never
schedulerName: default-scheduler
securityContext:
Expand All @@ -90,6 +103,8 @@ spec:
- 1001
terminationGracePeriodSeconds: 30
volumes:
- emptyDir: {}
name: bin
- name: ssl
secret:
defaultMode: 420
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,20 +74,35 @@ spec:
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /opt/percona
name: bin
- mountPath: /etc/mysql/ssl
name: ssl
- mountPath: /etc/mysql/ssl-internal
name: ssl-internal
- mountPath: /etc/mysql/vault-keyring-secret
name: vault-keyring-secret
dnsPolicy: ClusterFirst
initContainers:
- command:
- /backup-init-entrypoint.sh
imagePullPolicy: Always
name: backup-init
resources: {}
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /opt/percona
name: bin
restartPolicy: Never
schedulerName: default-scheduler
securityContext:
supplementalGroups:
- 1001
terminationGracePeriodSeconds: 30
volumes:
- emptyDir: {}
name: bin
- name: ssl
secret:
defaultMode: 420
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,26 @@ spec:
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /opt/percona
name: bin
- mountPath: /etc/mysql/ssl
name: ssl
- mountPath: /etc/mysql/ssl-internal
name: ssl-internal
- mountPath: /etc/mysql/vault-keyring-secret
name: vault-keyring-secret
dnsPolicy: ClusterFirst
initContainers:
- command:
- /backup-init-entrypoint.sh
imagePullPolicy: Always
name: backup-init
resources: {}
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /opt/percona
name: bin
restartPolicy: Never
schedulerName: default-scheduler
securityContext:
Expand All @@ -89,6 +102,8 @@ spec:
- 1001
terminationGracePeriodSeconds: 30
volumes:
- emptyDir: {}
name: bin
- name: ssl
secret:
defaultMode: 420
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,26 @@ spec:
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /opt/percona
name: bin
- mountPath: /etc/mysql/ssl
name: ssl
- mountPath: /etc/mysql/ssl-internal
name: ssl-internal
- mountPath: /etc/mysql/vault-keyring-secret
name: vault-keyring-secret
dnsPolicy: ClusterFirst
initContainers:
- command:
- /backup-init-entrypoint.sh
imagePullPolicy: Always
name: backup-init
resources: {}
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /opt/percona
name: bin
restartPolicy: Never
schedulerName: default-scheduler
securityContext:
Expand All @@ -84,6 +97,8 @@ spec:
- 1001
terminationGracePeriodSeconds: 30
volumes:
- emptyDir: {}
name: bin
- name: ssl
secret:
defaultMode: 420
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,20 +68,35 @@ spec:
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /opt/percona
name: bin
- mountPath: /etc/mysql/ssl
name: ssl
- mountPath: /etc/mysql/ssl-internal
name: ssl-internal
- mountPath: /etc/mysql/vault-keyring-secret
name: vault-keyring-secret
dnsPolicy: ClusterFirst
initContainers:
- command:
- /backup-init-entrypoint.sh
imagePullPolicy: Always
name: backup-init
resources: {}
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /opt/percona
name: bin
restartPolicy: Never
schedulerName: default-scheduler
securityContext:
supplementalGroups:
- 1001
terminationGracePeriodSeconds: 30
volumes:
- emptyDir: {}
name: bin
- name: ssl
secret:
defaultMode: 420
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,26 @@ spec:
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /opt/percona
name: bin
- mountPath: /etc/mysql/ssl
name: ssl
- mountPath: /etc/mysql/ssl-internal
name: ssl-internal
- mountPath: /etc/mysql/vault-keyring-secret
name: vault-keyring-secret
dnsPolicy: ClusterFirst
initContainers:
- command:
- /backup-init-entrypoint.sh
imagePullPolicy: Always
name: backup-init
resources: {}
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /opt/percona
name: bin
restartPolicy: Never
schedulerName: default-scheduler
securityContext:
Expand All @@ -83,6 +96,8 @@ spec:
- 1001
terminationGracePeriodSeconds: 30
volumes:
- emptyDir: {}
name: bin
- name: ssl
secret:
defaultMode: 420
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,32 @@ spec:
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /opt/percona
name: bin
- mountPath: /etc/mysql/ssl
name: ssl
- mountPath: /etc/mysql/ssl-internal
name: ssl-internal
- mountPath: /etc/mysql/vault-keyring-secret
name: vault-keyring-secret
dnsPolicy: ClusterFirst
initContainers:
- command:
- /backup-init-entrypoint.sh
imagePullPolicy: Always
name: backup-init
resources:
limits:
cpu: "1"
memory: 2G
requests:
cpu: 500m
memory: 500M
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /opt/percona
name: bin
restartPolicy: Never
schedulerName: default-scheduler
securityContext:
Expand All @@ -97,6 +116,8 @@ spec:
- 1001
terminationGracePeriodSeconds: 30
volumes:
- emptyDir: {}
name: bin
- name: ssl
secret:
defaultMode: 420
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,20 +81,41 @@ spec:
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /opt/percona
name: bin
- mountPath: /etc/mysql/ssl
name: ssl
- mountPath: /etc/mysql/ssl-internal
name: ssl-internal
- mountPath: /etc/mysql/vault-keyring-secret
name: vault-keyring-secret
dnsPolicy: ClusterFirst
initContainers:
- command:
- /backup-init-entrypoint.sh
imagePullPolicy: Always
name: backup-init
resources:
limits:
cpu: "1"
memory: 2G
requests:
cpu: 500m
memory: 500M
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /opt/percona
name: bin
restartPolicy: Never
schedulerName: default-scheduler
securityContext:
supplementalGroups:
- 1001
terminationGracePeriodSeconds: 30
volumes:
- emptyDir: {}
name: bin
- name: ssl
secret:
defaultMode: 420
Expand Down
21 changes: 21 additions & 0 deletions e2e-tests/demand-backup/compare/job_xb-on-demand-backup-minio.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,32 @@ spec:
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /opt/percona
name: bin
- mountPath: /etc/mysql/ssl
name: ssl
- mountPath: /etc/mysql/ssl-internal
name: ssl-internal
- mountPath: /etc/mysql/vault-keyring-secret
name: vault-keyring-secret
dnsPolicy: ClusterFirst
initContainers:
- command:
- /backup-init-entrypoint.sh
imagePullPolicy: Always
name: backup-init
resources:
limits:
cpu: "1"
memory: 2G
requests:
cpu: 500m
memory: 500M
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /opt/percona
name: bin
restartPolicy: Never
schedulerName: default-scheduler
securityContext:
Expand All @@ -96,6 +115,8 @@ spec:
- 1001
terminationGracePeriodSeconds: 30
volumes:
- emptyDir: {}
name: bin
- name: ssl
secret:
defaultMode: 420
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ spec:
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /opt/percona
name: bin
- mountPath: /backup
name: xtrabackup
- mountPath: /etc/mysql/ssl
Expand All @@ -71,6 +73,19 @@ spec:
- mountPath: /etc/mysql/vault-keyring-secret
name: vault-keyring-secret
dnsPolicy: ClusterFirst
initContainers:
- command:
- /backup-init-entrypoint.sh
imagePullPolicy: Always
name: backup-init
resources: {}
securityContext:
privileged: true
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /opt/percona
name: bin
restartPolicy: Never
schedulerName: default-scheduler
securityContext:
Expand All @@ -83,6 +98,8 @@ spec:
serviceAccountName: percona-xtradb-cluster-operator-workload
terminationGracePeriodSeconds: 30
volumes:
- emptyDir: {}
name: bin
- name: xtrabackup
persistentVolumeClaim:
claimName: xb-on-demand-backup-pvc
Expand Down
Loading

0 comments on commit 7037956

Please sign in to comment.