<p>I am trying to deploy a redis sentinel deployment in Kubernetes. I have accomplished that but want to use ConfigMaps to allow us to change the IP address of the master in the sentinel.conf file. I started this but redis cant write to the config file because the mount point for configMaps are readOnly. </p>

<p>I was hoping to run an init container and copy the redis conf to a different dir just in the pod. But the init container couldn't find the conf file. </p>

<p>What are my options? Init Container? Something other than ConfigMap? </p>

<pre><code>apiVersion: apps/v1beta1
kind: Deployment
metadata:
  name: redis-sentinel
spec:
  replicas: 3
  template:
    metadata:
      labels:
        app: redis-sentinel
    spec:
      hostNetwork: true
      containers:
      - name: redis-sentinel
        image: IP/redis-sentinel
        ports:
          - containerPort: 63790
          - containerPort: 26379
        volumeMounts:
          - mountPath: /redis-master-data
            name: data
          - mountPath: /usr/local/etc/redis/conf
            name: config
      volumes:
        - name: data
          emptyDir: {}
        - name: config
          configMap:
            name: sentinel-redis-config
            items:
            - key: redis-config-sentinel
              path: sentinel.conf
</code></pre>

Dylan
<p>According to @P Ekambaram proposal, you can try this one:</p>

<pre><code>apiVersion: apps/v1beta1
kind: Deployment
metadata:
  name: redis-sentinel
spec:
  replicas: 3
  template:
    metadata:
      labels:
        app: redis-sentinel
    spec:
      hostNetwork: true
      containers:
      - name: redis-sentinel
        image: redis:5.0.4
        ports:
          - containerPort: 63790
          - containerPort: 26379
        volumeMounts:
          - mountPath: /redis-master-data
            name: data
          - mountPath: /usr/local/etc/redis/conf
            name: config
      initContainers:
      - name: copy
        image: redis:5.0.4
        command: ["bash", "-c", "cp /redis-master/redis.conf /redis-master-data/"]
        volumeMounts:
        - mountPath: /redis-master
          name: config
        - mountPath: /redis-master-data
          name: data
     volumes:
     - name: data
       emptyDir: {}
     - name: config
       configMap:
         name: example-redis-config
         items:
         - key: redis-config
           path: redis.conf
</code></pre>

<p>In this example initContainer copy the file from ConfigMap into writable dir.</p>

<p>Note:</p>

<blockquote>
  <p>An emptyDir volume is first created when a Pod is assigned to a Node, and exists as long as that Pod is running on that node. As the name says, it is initially empty. Containers in the Pod can all read and write the same files in the emptyDir volume, though that volume can be mounted at the same or different paths in each Container. When a Pod is removed from a node for any reason, the data in the emptyDir is deleted forever.</p>
</blockquote>
