title: How to overwrite file at a deployment time in kubernetes?
body: <p>I'm trying to deploy Diffusion image in kubernetes and I need to overwrite one of Diffusion configuration files at deployment time.</p>
  
  <p>Actually it is a <code>SystemAuthentication.store</code> file with default credentials in <code>/opt/Diffusion6.0.3_01/etc/</code>. I'm storing new file in secret and mount it into <code>etc/test/</code> which can be seen in below deployment file. </p>
  
  <pre><code>template:
  metadata:
    labels:
      run: diffusion
  spec:
    serviceAccountName: diffusion-role
    volumes:
    - name: diffusion-secrets
      secret:
        secretName: diffusion-license
    - name: ssl-cert
      secret:
        secretName: ssl-certificate
    - name: system-authentication
      secret:
        secretName: system-authentication-store
    containers:
    - image: pushtechnology/diffusion:6.0.3
      imagePullPolicy: IfNotPresent
      name: diffusion
      ports:
      - containerPort: 8080
        protocol: TCP
      - containerPort: 8443
        protocol: TCP
      volumeMounts:
      - name: diffusion-secrets
        mountPath: /etc/diffusion-secrets
        readOnly: true
      - name: ssl-cert
        mountPath: /etc/test/
        readOnly: true
      - name: system-authentication
        mountPath: /etc/test/
      command: [ "/bin/sh", "-c", "cp etc/test/SystemAuthentication.store /opt/DIffusion6.0.3_01" ]
  </code></pre>
  
  <p>When I deploy this image pods are failing with</p>
  
  <pre><code>Events:
  Type     Reason                 Age              From                                   Message
  ----     ------                 ----             ----                               -------
  Normal   Scheduled              2m               default-scheduler                  Successfully assigned diffusion-db6d6df7b-f5tp4 to timmy.pushtechnology.com
  Normal   SuccessfulMountVolume  2m               kubelet, timmy.pushtechnology.com  MountVolume.SetUp succeeded for volume "diffusion-role-token-n59ds"
  Normal   SuccessfulMountVolume  2m               kubelet, timmy.pushtechnology.com  MountVolume.SetUp succeeded for volume "ssl-cert"
  Normal   SuccessfulMountVolume  2m               kubelet, timmy.pushtechnology.com  MountVolume.SetUp succeeded for volume "system-authentication"
  Normal   SuccessfulMountVolume  2m               kubelet, timmy.pushtechnology.com  MountVolume.SetUp succeeded for volume "diffusion-secrets"
  Normal   Killing                1m (x2 over 1m)  kubelet, timmy.pushtechnology.com  Killing container with id docker://diffusion:FailedPostStartHook
  Warning  BackOff                1m (x2 over 1m)  kubelet, timmy.pushtechnology.com  Back-off restarting failed container
  Normal   Pulled                 1m (x3 over 2m)  kubelet, timmy.pushtechnology.com  Container image "pushtechnology/diffusion:6.0.3" already present on machine
  Normal   Created                1m (x3 over 1m)  kubelet, timmy.pushtechnology.com  Created container
  Normal   Started                1m (x3 over 1m)  kubelet, timmy.pushtechnology.com  Started container
  Warning  FailedPostStartHook    1m (x3 over 1m)  kubelet, timmy.pushtechnology.com  
  Warning  FailedSync             1m (x5 over 1m)  kubelet, timmy.pushtechnology.com  Error syncing pod
  </code></pre>
  
  <p>I have tried also workaruond described here: <a href="https://github.com/kubernetes/kubernetes/issues/19764#issuecomment-269879587" rel="nofollow noreferrer">https://github.com/kubernetes/kubernetes/issues/19764#issuecomment-269879587</a></p>
  
  <p>with same results.</p>