mariadb-rs.yaml 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. apiVersion: batch/v1
  2. kind: CronJob
  3. metadata:
  4. name: mariadb-backup
  5. spec:
  6. schedule: "@daily"
  7. jobTemplate:
  8. spec:
  9. template:
  10. spec:
  11. affinity:
  12. nodeAffinity:
  13. requiredDuringSchedulingIgnoredDuringExecution:
  14. nodeSelectorTerms:
  15. - matchExpressions:
  16. - key: "kubernetes.io/arch"
  17. operator: In
  18. values:
  19. - amd64
  20. containers:
  21. - name: mariadb-backup
  22. image: qdii/mysql-ssh:latest
  23. env:
  24. - name: SQL_USERNAME
  25. value: "root"
  26. - name: SQL_HOSTNAME
  27. value: "mariadb.mariadb"
  28. - name: SQL_PASSWORD
  29. valueFrom:
  30. secretKeyRef:
  31. name: mariadb-root
  32. key: mariadb-root
  33. - name: BCK_USERNAME
  34. value: "uab10c1ba4bc"
  35. - name: BCK_HOSTNAME
  36. value: "bck.dodges.it"
  37. - name: BCK_FOLDER
  38. value: "/home/uab10c1ba4bc/data/vol0/mariadb"
  39. volumeMounts:
  40. - name: mariadb-config
  41. mountPath: "/root/backup.sh"
  42. subPath: backup.sh
  43. readOnly: true
  44. - name: backup
  45. mountPath: "/root/.ssh/id_rsa"
  46. subPath: ssh_private_key
  47. readOnly: true
  48. - name: backup
  49. mountPath: "/root/.ssh/id_rsa.pub"
  50. subPath: ssh_public_key
  51. readOnly: true
  52. command: ["/root/backup.sh"]
  53. restartPolicy: Never
  54. volumes:
  55. - name: mariadb-config
  56. configMap:
  57. name: mariadb
  58. defaultMode: 0500
  59. - name: backup
  60. secret:
  61. secretName: backup
  62. defaultMode: 0400