kuberneteskustomize

Kustomize prefix/suffix transformer for custom variable in Ingress object


I'm trying to configure kustomize so it adds a suffix to my tls secret name, I've got the following configuration:

nameSuffix:
  - kind: Ingress
    path: /spec/tls/0/secretName

This is my ingress manifest:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: ingress
spec:
  rules:
  - host: <APP-URL>
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: service
            port:
              number: 80
  tls:
  - hosts:
    - <APP-URL>
    secretName: letsencrypt-this-is-where-i-want-my-suffix

When trying to build my kustomize file I receive the following error:

Error: considering field '/spec/tls/0/secretName' of object Ingress.v1.networking.k8s.io/joeingressjoe.[noNs]: cannot set or create an empty field name

I'm a bit confused by this, my path (/spec/tls/0/secretName) does work when I'd try to apply a patch. Does anybody know if I am overseeing something here?


Solution

  • Please modify your nameSuffix file to this:

    nameSuffix:
      - path: spec/tls/secretName
        kind: Ingress
    

    this fix the problem