0
votes

I have a kustomize transformer plugin that reads the value of serviceName in Ingress spec/rules/*/http/paths/0/backend/serviceName. The intent of the plugin is to update the host entries in the Ingress with the final serviceName after nameSuffix/namePrefix has been applied.

The plugins reads from stdin, but the state of the yaml isn't what I expected. The names of the Service and the Ingress have the nameSuffix/namePrefix applied, but the value of serviceName in the Ingress is still the raw service name. I verified this by dumping the Ingress yaml when the plugin executes. After the plugin runs, the final output does have the updated serviceName (with prefix/suffix). So something is running after the plugin that does the updating.

How do I configure the plugin so that it runs after the serviceName in the Ingress has been updated?

1

1 Answers

0
votes

According to this example: Transformer Configs

namePrefix and nameSuffix have reference only:

 namePrefix:
- path: metadata/name

If you want to include serviceName to the nameReference, you can create, for example, a kustomize-config.yml file with the content:

nameReference:
- kind: ServiceName
  fieldSpecs:
  - path: spec/rules/*/http/paths/0/backend/serviceName
    kind: Ingress

Then, on your kustomization.yml you need to reference it:

configurations:
- kustomize-config.yml

Next time you run kubectl kustomize . or kustomize build ., you may see both Prefix and Suffix reflect also to serviceName