1

I have a sidecar like this:

apiVersion: networking.istio.io/v1alpha3
kind: Sidecar
metadata:
  name: test
  namespace: testns
spec:
  workloadSelector:
    labels:
      app: test
...

and a kustomization like:

resources:
  - ../../base

nameSuffix: -dev

But kustomize doesn't adapt the workloadSelector label app to test-dev as I would expect it to do. The name suffix is only appended to the name of the sidecar. Any ideas why?

Steffen Harbich
  • 2,639
  • 2
  • 37
  • 71

1 Answers1

4

By default kustomize namePrefix and nameSuffix only apply to metadata/name for all resources.

There are a set of configured nameReferences that will also be transformed with the appropriate name, but they are limited to resource names.

See here for more info: https://github.com/kubernetes-sigs/kustomize/blob/master/examples/transformerconfigs/README.md#prefixsuffix-transformer

rjferguson21
  • 1,004
  • 5
  • 9
  • Thanks for the explanation. How would you overcome this issue? Using a patch? – Steffen Harbich Dec 09 '21 at 07:09
  • 1
    Yes, based on your example I'm assuming you were hoping to target specific workloads, in which case you could write patches to set the appropriate label in the pod spec, and an additional corresponding patch to update the `workloadSelector`. It is hard to know without more information but it seems like it would be easier to reason about with a more specific `workloadSelector` so you could write a single patch that added a label like `sidecar: enabled` to your pods/workloads. – rjferguson21 Dec 09 '21 at 14:18