/kind question
is it possible to have kustomization file avoid adding prefixes to few kinds ?
@kameshsampath Which kinds do you want to skip name prefix?
@Liujingfang1 I would prefer to have list of resources where we can say which resources to skip
e.g.
like
I would like to skip for ingress, so there will be single ingress resource which contains all the overlay hosts (applied using a patch from base)
It would be nice to be able to configure on a per-resource basis somehow. My usecase is that I have a Kubernetes cluster with Istio running and I want to deploy my resources using canary deployments. To do this, I:
my-service into my namespace that has selector app: my-app.my-service-v1 into my namespace that has template labels app: my-app and version: v1my-service-v2 into my namespace that has template labels app: my-app and version: v2my-service with selector version: v1 and the rest to the selector version: v2It would be really nice to be able to set nameSuffix: v2 or whatever in my kustomization and have a way of specifying which resources it should apply for - or perhaps which resources should be excluded from it. I think in my usecase, I'd most of the time want to have a namePrefix/nameSuffix on my deployments/pods and perhaps namespaces - but not on my services or any custom resources created like for example Redis instances created with a form of operator pattern; those should be version independent.
@tanordheim did you find a workaround? I can't find something that is not supper ugly to do this.
@luisyonaldo I ended up just using sed/envsubst on the files in question before running kustomize build; it's not nearly pretty, but this way I control which resources have my version suffix and which do not.
@tanordheim can you provide an example?
Currently I have a base with the current resources:
- deployment.yaml
- service.yaml
- gateway.yaml
- virtual-service.yaml
then I have two overrides: prod and canary (each with the own name prefix prod and canary). Where canary only have the resources deployment.yaml and virtual-service-patch.yaml. All works good except that the patch is creating a new virtual-service because the namePrefix changed.
+1
Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.
If this issue is safe to close now please do so with /close.
Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale
bump
Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.
If this issue is safe to close now please do so with /close.
Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle rotten
/remove-lifecycle rotten
@kameshsampath @verult @lwille @tanordheim @guyromb
Please have a look at:
The following test is an example of custom config for the PrefixSuffixTransformer.
The test programs it to add prefixes only to Deployment and Service, and shows how a Role is left unmodified.
https://github.com/kubernetes-sigs/kustomize/blob/master/api/internal/target/customconfigofbuiltinplugin_test.go
The plugin's config is currently oriented towards specifying which kinds to modify, ignoring others.
The plugin and it's config could be modified to do the opposite - add prefixes to everything _except_ specific items on a skip list. Feel free to make a PR doing so.
The following test has custom configuration for the LabelTransformer, showing
how to use it to add labels to specific kinds, and specific paths in those kinds:
https://github.com/kubernetes-sigs/kustomize/blob/master/api/internal/target/customconfigreusable_test.go
Moreover, the test shows how to bundle custom config for transformers into a reusable base.
This is live in https://github.com/kubernetes-sigs/kustomize/releases/tag/kustomize%2Fv3.4.0
Considering this issue addressed. The tests are nice (since they are known to be correct) but they're not very discoverable as a form of documentation. we need better docs
Most helpful comment
bump