<p>I have a deployment running in Kubernetes and want to update the "args" prior to applying an update so that when it restarts, it uses a different entrypoint arg than it did during its initial startup, which also included some data bootstrapping.</p>

<p>I know you can run <code>kubectl set image</code> to update the image that the deployment or replicaset is running, but how can I also update the args without deleting and re-creating the resource?</p>

<p>You can use <a href="https://kubernetes.io/docs/tasks/run-application/update-api-object-kubectl-patch/" rel="noreferrer"><code>kubectl patch</code></a> as pointed in the answer by @mr.franco. I'm using this to patch <code>args</code> of <code>kubernetes-dashboard</code> Deployment without modifying their official installation manifest.</p>

<p>Here is a full example of how you can replace (in terms of JSON patch) container <code>args</code> on existing Deployment:</p>

<pre class="lang-sh prettyprint-override"><code>kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.0.1/aio/deploy/recommended.yaml
</code></pre>

<pre class="lang-sh prettyprint-override"><code>kubectl get deployment kubernetes-dashboard --namespace kubernetes-dashboard -o=json | jq '.spec.template.spec.containers[0].args'
</code></pre>



<pre><code>[
  "--auto-generate-certificates",
  "--namespace=kubernetes-dashboard"
]
</code></pre>

<pre class="lang-sh prettyprint-override"><code>kubectl patch deployment \
  kubernetes-dashboard \
  --namespace kubernetes-dashboard \
  --type='json' \
  -p='[{"op": "replace", "path": "/spec/template/spec/containers/0/args", "value": [
  "--auto-generate-certificates",
  "--enable-insecure-login",
  "--enable-skip-login",
  "--namespace=kubernetes-dashboard"
]}]'
</code></pre>

<pre class="lang-sh prettyprint-override"><code>kubectl get deployment kubernetes-dashboard --namespace kubernetes-dashboard -o=json | jq '.spec.template.spec.containers[0].args'
</code></pre>



<pre><code>[
  "--auto-generate-certificates",
  "--enable-insecure-login",
  "--enable-skip-login",
  "--namespace=kubernetes-dashboard"
]
</code></pre>
