redis-rs.yaml 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. apiVersion: apps/v1
  2. kind: Deployment
  3. metadata:
  4. name: redis
  5. labels:
  6. name: redis
  7. spec:
  8. replicas: 1
  9. selector:
  10. matchLabels:
  11. name: redis
  12. template:
  13. metadata:
  14. name: redis
  15. labels:
  16. name: redis
  17. spec:
  18. containers:
  19. - name: redis
  20. image: redis:alpine
  21. args: ["--requirepass", "$(REDISCLI_AUTH)"]
  22. livenessProbe:
  23. exec:
  24. command: ["redis-cli", "PING"]
  25. initialDelaySeconds: 120
  26. periodSeconds: 60
  27. env:
  28. - name: REDISCLI_AUTH
  29. valueFrom:
  30. secretKeyRef:
  31. key: root-password
  32. name: redis
  33. lifecycle:
  34. preStop:
  35. exec:
  36. command: ["redis-cli", "SHUTDOWN SAVE"]
  37. ports:
  38. - containerPort: 6379
  39. name: redis
  40. protocol: TCP
  41. resources:
  42. requests:
  43. memory: "100Mi"
  44. cpu: "10m"
  45. volumeMounts:
  46. - mountPath: /data
  47. name: redis-pv
  48. volumes:
  49. - name: redis-pv
  50. persistentVolumeClaim:
  51. claimName: redis-pvc
  52. ---
  53. apiVersion: batch/v1
  54. kind: CronJob
  55. metadata:
  56. name: redis-backup
  57. spec:
  58. schedule: "@daily"
  59. jobTemplate:
  60. spec:
  61. template:
  62. spec:
  63. containers:
  64. - name: redis-backup
  65. image: qdii/backup-ssh:latest
  66. env:
  67. - name: REDISCLI_AUTH
  68. valueFrom:
  69. secretKeyRef:
  70. key: root-password
  71. name: redis
  72. - name: BCK_USERNAME
  73. value: "uab10c1ba4bc"
  74. - name: BCK_HOSTNAME
  75. value: "bck.dodges.it"
  76. - name: BCK_FOLDER
  77. value: "/home/uab10c1ba4bc/data/vol0/redis"
  78. volumeMounts:
  79. - name: redis-config
  80. mountPath: "/root/backup.sh"
  81. subPath: backup.sh
  82. readOnly: true
  83. - name: backup
  84. mountPath: "/root/.ssh/id_rsa"
  85. subPath: ssh_private_key
  86. readOnly: true
  87. - name: backup
  88. mountPath: "/root/.ssh/id_rsa.pub"
  89. subPath: ssh_public_key
  90. readOnly: true
  91. command: ["/root/backup.sh"]
  92. restartPolicy: Never
  93. volumes:
  94. - name: redis-config
  95. configMap:
  96. name: redis
  97. defaultMode: 0500
  98. - name: backup
  99. secret:
  100. secretName: backup
  101. defaultMode: 0400