2

My Setup: GitHub(Build Pipeline) + Kustomize + Kubernetes

Kustomize structure:

--base
----deployment.yaml
----service.yaml
----kustomizationn.yaml
--env-country1
----kustomizationn.yaml
--env-country2
----kustomizationn.yaml

Issue: I am trying to patch the spec.selector.matchLabels.service and spec.template.metadata.labels.service values present in the deployment.yaml in the base.

what I tried:

  1. I tried to use patch like below:

    patches:
    - patch: |-
     - op: replace
      path: /metadata/name
      value: <serviceName>-<country>
     - op: replace
      path: /spec/selector/matchLabels/service
      value: <serviceName>-<country>
     - op: replace
      path: /spec/template/metadata/labels/service
      value: <serviceName>-<country>  
     target:
     kind: Deployment
    

Issue: these are immutable entities, hence can't be patched.

I also tried to research but was not able to find any related documentation with examples.

PS: I am not using helm.

Thanks in advance

Prabhat Mishra
  • 951
  • 2
  • 12
  • 33
  • I wanted to [replicate your issue so I can debug it locally](https://stackoverflow.com/help/minimal-reproducible-example), but there is some information missing. Could you please share example deployment, services, kustomization (from base + env-country directories) yamls files? Which commands did you run and from which directories? Please also share information about used kustmize version (`kustomize version` command). – Mikolaj S. Dec 01 '21 at 10:06

0 Answers0