kustomize: Prefix/Suffix transformers cannot target list elements

I am trying to use a Prefix/Suffix transformer on my Ingress TLS hosts hostname, but it cannot seem to target that field. Below is my sample transformer and ingress configs. I have tried many variations on spec/tls/hosts but I cannot seem to target that list hostname object. The key here is I want to be able to prefix any name, hostname, or secretNames that are listed and I can get the others just not this last one. Any help would be appreciated as I know other people have had issues with list objects previously, not sure if I am missing something or if this is not currently possible.

apiVersion: builtin
kind: prefixTransformer
metadata:
  name: prefixer
prefix: "prefix-"
fieldSpecs:
- path: metadata/name
- path: spec/rules/host
  kind: Ingress
- path: spec/tls/secretName
  kind: Ingress
- path: spec/tls/hosts
  kind: Ingress
kind: Ingress
metadata:
  name: test-ingress
  namespace: test
spec:
  rules:
  - host: test.fakedomain.com
    http:
    ...
  tls:
  - hosts
    - test.fakedomain.com    <--- trying to target
    secretName: test-secret

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Comments: 16 (4 by maintainers)

Most upvoted comments

@KnVerey Thanks for the suggestion, I was actually trying to use the replacement transformer similar to your suggestion as a workaround, but I can’t quite get it to work with my situation. I want it to be able to be general so in this case if there are multiple ingresses it will update all of them. However, I keep getting the error Error: multiple matches for selector Ingress.[noVer].[noGrp]/[noName].[noNs]:.spec.rules.0.host as I leave out the name compared to your example. I assume this is just a limitation of the replacement transformer, but is it possible to make the replacement transformer relative so it can work generally across multiple ingresses?

apiVersion: builtin
kind: ReplacementTransformer
metadata:
  name: configReplacement
replacements:
- source:
    kind: Ingress
    fieldPath: .spec.rules.0.host
  targets:
  - select:
      kind: Ingress
    fieldPaths:
    - spec.tls.0.hosts.0