title: Patching list in kubernetes manifest with Kustomize
body: <p>I want to patch (overwrite) <strong>list</strong> in <strong>kubernetes</strong> manifest with <strong>Kustomize</strong>.
  I am using patchesStrategicMerge method.
  When I patch the parameters which are not in list the patching works as expected - only addressed parameters in patch.yaml are replaced, rest is untouched.
  When I patch list the whole list is replaced.</p>
  <p><strong>How can I replace only specific items in the list and the res of the items in list stay untouched?</strong></p>
  <p>I found these two resources:<br />
  <a href="https://github.com/kubernetes-sigs/kustomize/issues/581" rel="noreferrer">https://github.com/kubernetes-sigs/kustomize/issues/581</a><br />
  <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/sig-api-machinery/strategic-merge-patch.md" rel="noreferrer">https://github.com/kubernetes/community/blob/master/contributors/devel/sig-api-machinery/strategic-merge-patch.md</a><br />
  but wasn't able to make desired solution of it.</p>
  <p>exmaple code:
  orig-file.yaml</p>
  <pre><code>apiVersion: monitoring.coreos.com/v1alpha1
  kind: AlertmanagerConfig
  metadata:
    name: alertmanager-slack-config
    namespace: system-namespace
  spec:
    test: test
    other: other-stuff
    receivers:
      - name: default
        slackConfigs:
          - name: slack
            username: test-user
            channel: &quot;#alerts&quot;
            sendResolved: true
            apiURL:
              name: slack-webhook-url
              key: address
  </code></pre>
  <p>patch.yaml:</p>
  <pre><code>apiVersion: monitoring.coreos.com/v1alpha1
  kind: AlertmanagerConfig
  metadata:
    name: alertmanager-slack-config
    namespace: system-namespace
  spec:
    test: brase-yourself
    receivers:
      - name: default
        slackConfigs:
          - name: slack
            username: Karl
  </code></pre>
  <p>kustomization.yaml</p>
  <pre><code>apiVersion: kustomize.config.k8s.io/v1beta1
  kind: Kustomization
  resources:
  - orig-file.yaml
  
  patchesStrategicMerge:
  - patch.yaml
  </code></pre>
  <p>What I get:</p>
  <pre><code>apiVersion: monitoring.coreos.com/v1alpha1
  kind: AlertmanagerConfig
  metadata:
    name: alertmanager-slack-config
    namespace: system-namespace
  spec:
    other: other-stuff
    receivers:
    - name: default
      slackConfigs:
      - name: slack
        username: Karl
    test: brase-yourself
  </code></pre>
  <p>What I want:</p>
  <pre><code>apiVersion: monitoring.coreos.com/v1alpha1
  kind: AlertmanagerConfig
  metadata:
    name: alertmanager-slack-config
    namespace: system-namespace
  spec:
    other: other-stuff
    receivers:
      - name: default
        slackConfigs:
          - name: slack
            username: Karl
            channel: &quot;#alerts&quot;
            sendResolved: true
            apiURL:
              name: slack-webhook-url
              key: address
    test: brase-yourself
  </code></pre>