apiVersion: apps/v1 kind: Deployment metadata: name: redis-sentinel namespace: redis labels: app: redis-sentinel spec: replicas: 3 selector: matchLabels: app: redis-sentinel template: metadata: labels: app: redis-sentinel spec: # Init container to copy the sentinel.conf from the ConfigMap to a writable emptyDir volume. initContainers: - name: copy-sentinel-config image: busybox command: ['sh', '-c', 'cp /config/sentinel.conf /writable/'] volumeMounts: - name: sentinel-config-readonly mountPath: /config - name: sentinel-config mountPath: /writable containers: - name: redis-sentinel image: redis:7.4-alpine ports: - containerPort: 26379 name: sentinel command: - "redis-sentinel" - "/etc/redis/sentinel.conf" volumeMounts: - name: sentinel-config mountPath: /etc/redis # this volume is now writable volumes: # Mount the ConfigMap as a read-only volume for the init container - name: sentinel-config-readonly configMap: name: redis-sentinel-config # EmptyDir volume to hold the writable config file - name: sentinel-config emptyDir: {}