<p>I have a Kubernetes deployment up and running:
(some fields omitted for brevity)</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: argocd-server
  namespace: argocd
spec:
  replicas: 1
  selector:
    matchLabels:
      app.kubernetes.io/name: argocd-server
  template:
    metadata:
      creationTimestamp: null
      labels:
        app.kubernetes.io/name: argocd-server
    spec:
      containers:
        - name: argocd-server
          image: quay.io/argoproj/argocd:v2.2.5
          command:
            - argocd-server
</code></pre>
<p>I would like to create a patch for the existing deployment to add certain arguements to the <code>command</code> of the container:</p>
<pre><code>            - '--insecure'
            - '--basehref'
            - /argocd
</code></pre>
<p>I read the documentation on the <code>kubectl patch</code> command <a href="https://kubernetes.io/docs/tasks/manage-kubernetes-objects/update-api-object-kubectl-patch/" rel="nofollow noreferrer">here</a>, but I am not sure how to actually select the container (by name or index) that I would like to patch.<br />
It would be fine to overwrite the complete <code>command:</code> list (giving the <code>- argocd-server</code> line in the patch file) but I would like to prevent giving the complete <code>containers:</code> spec in the patch file.</p>

mxcd
<p>You can select the container by index, e.g.:</p>
<pre class="lang-sh prettyprint-override"><code>kubectl patch deployment argocd-server -n argocd --type='json' -p='[{&quot;op&quot;: &quot;replace&quot;, &quot;path&quot;: &quot;/spec/template/spec/containers/0/command&quot;, &quot;value&quot;: [&quot;argocd-server&quot;, &quot;--insecure&quot;]}]'
</code></pre>
