<p>im successfully running kubernetes, gcloud and postgres but i wanna make some modifications after pod startup , im trying to move some files so i tried these 3 options</p>

<p>1</p>

<pre><code> image: paunin/postgresql-cluster-pgsql
      lifecycle:
        postStart:
          exec:
            command: [/bin/cp /var/lib/postgres/data /tmpdatavolume/]
</code></pre>

<p>2</p>

<pre><code>image: paunin/postgresql-cluster-pgsql
      lifecycle:
        postStart:
          exec:
            command: 
              - "cp"
              - "/var/lib/postgres/data"
              - "/tmpdatavolume/"
</code></pre>

<p>3</p>

<pre><code>image: paunin/postgresql-cluster-pgsql
      lifecycle:
        postStart:
          exec:
            command: ["/bin/cp "]
            args: ["/var/lib/postgres/data","/tmpdatavolume/"]
</code></pre>

<p>on option 1 and 2, im getting the same errors (from  <strong>kubectl get events</strong> )</p>

<pre><code>Killing container with docker id f436e40f5df2: PostStart handler: Error ex
ecuting in Docker Container: -1
</code></pre>

<p>and on option 3 it wont even let me upload the yaml file giving me this error </p>

<pre><code>error validating "postgres-master.yaml": error validating data: found invalid field args for v1.ExecAction; if you choose to ignore these errors, turn validation off with --validate=false 
</code></pre>

<p>any help would be appreciated! thanks.
pd: i just pasted part of my yaml file since i wasnt getting any errors since i added those new lines</p>

<p>Here's the <a href="https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/" rel="nofollow noreferrer">document about lifecycle hooks</a> you might find useful.</p>
<p>Your option 1 won't work and should give you the error you saw, it should be <code>[&quot;/bin/cp&quot;,&quot;/var/lib/postgres/data&quot;,&quot;/tmpdatavolume/&quot;]</code> instead. Option 2 is also the right way to specify it. Can you <code>kubectl exec</code> into your pod and type those commands to see what error messages that generates? Do something like <code>kubectl exec &lt;pod-name&gt; -i -t -- bash -il</code></p>
<p>The error message shown in option 3 means that you're not passing a valid configuration to the API server. To learn the API definition, see <a href="http://kubernetes.io/docs/api-reference/v1/definitions/#_v1_lifecycle" rel="nofollow noreferrer">v1.Lifecycle</a> and after a few clicks into its child fields you'll find <code>args</code> isn't valid under <code>lifecycle.postStart.exec</code>.</p>
<p>Alternatively, you can find those API definition using <code>kubectl explain</code>, e.g. <code>kubectl explain pods.spec.containers.lifecycle.postStart.exec</code> in this case.</p>
