global variable replacement in kustomize

41 views Asked by At

So I have 6 kustomize.yaml files (different env and regions) of the following form:

nameSuffix: -bar
components:
  - ../common
  - ../regions/site1
resources:
  - ../../base
commonLabels:
  env: bar
patches:
  - patch: |-
      - op: replace
        path: /spec/tls/0/hosts/0
        value: foo.foo.bar.site1.k8s.internal
      - op: replace
        path: /spec/rules/0/host
        value: foo.foo.bar.site1.k8s.internal
      - op: replace
        path: /spec/rules/1/host
        value: foo.bar.k8s.internal
    target:
      kind: Ingress
      name: foo
  - patch: |-
      - op: replace
        path: /spec/replicas
        value: 1
    target:
      kind: Deployment
      name: foo

Is there a convenient way within kustomize to define a "variable"/replacements/... so I can manage foo (and possibly also bar for that matter) in one place instead of 6 files * 7 occurrences each?

Currently we create the whole set of files with placeholders and sed -i '///g' them to the final values. Not nice.

0

There are 0 answers