0

Let's say I have two yml file with patches:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: ingress-whitelist-1
  annotations:
    nginx.ingress.kubernetes.io/whitelist-source-range: 192.168.0.1, 192.168.0.2
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: ingress-whitelist-2
  annotations:
    nginx.ingress.kubernetes.io/whitelist-source-range: 192.168.0.3, 192.168.0.4

Then main Kustomize file:

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
  - ...

patches:
  - path: ingress-whitelist-1.yml
    target:
      kind: Ingress
      labelSelector: ingress-whitelist-1=true
      
  - path: ingress-whitelist-2.yml
    target:
      kind: Ingress
      labelSelector: ingress-whitelist-2=true

And finally main ingress file I'd like to patch by above:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: xyz
  labels:
    ingress-whitelist-1: "true"
    ingress-whitelist-2: "true"

For above example I would like to achieve final collection as merge:

nginx.ingress.kubernetes.io/whitelist-source-range: 192.168.0.1, 192.168.0.2, 192.168.0.3, 192.168.0.4

But instead the last patch is replacing everything and final output is:

nginx.ingress.kubernetes.io/whitelist-source-range: 192.168.0.3, 192.168.0.4

Is it possible?

Documentation says it's a list, not string: https://github.com/kubernetes/ingress-nginx/blob/main/docs/user-guide/nginx-configuration/annotations.md#whitelist-source-range

Staly
  • 85
  • 7
  • Annotations (and Labels) are **always** simple `string_key: string_value` constructs. Because the annotation value is a string, it can't be "merged" with anything else because there is no "merge a string with another string" operation. – larsks May 30 '23 at 16:46

0 Answers0