-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using replacements with a commonLabel as a source #4776
Comments
@dharmeshgordhan: This issue is currently awaiting triage. SIG CLI takes a lead on issue triage for this repo, but any Kubernetes member can accept issues by applying the The Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
It isn't possible to target the Kustomization itself using the replacements transformer--it only operates on the resource data that the Kustomization has already produced. Would you be able to instead target the label field on the /triage needs-information |
I had a quick go, but it threw an error. I will try more diligently in a couple of days - thought I'd share what I had so far.
I had a look at the output without the replacements, and the attribute looks like it's there. Trying with square brackets around the label for the replacement source threw:
Here's a sample of the deployment object output from kustomize:
Here's the replacements:
|
Okay! Got it working :) Not toooo sure why it didn't work the first time. Thanks!
|
Oh I just realised that it doesn't work when I have the common label in my overlay, and the replacements in the base. But if I have the common label in my overlay and the replacements in the same overlay it works. Is that expected? If so, the downside is I'd need to duplicate my replacements blocks into the overlay kustomization.yaml. |
@dharmeshgordhan: This issue is currently awaiting triage. SIG CLI takes a lead on issue triage for this repo, but any Kubernetes member can accept issues by applying the The Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Yes, that is expected. When you reference a base in the |
Hi! I just tried to use values from apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
commonLabels:
cluster.x-k8s.io/cluster-name: foofoo
testing.io/cluster: f0001
testing.io/organization: lab-for-foo
release.testing.io/version: 3.0.2
resources:
- ../../../base/cluster
- ./control-plane
components:
- ../../../components/replace-organization-name
- ../../../components/replace-cluster-name
- ../../../components/replace-control-plane-name
|
I agree with you that it is an ordering issue. Since Kustomize is quite generic and can be used to build configuration sets in many different ways, I expect there is no perfect ordering we can choose. As a rule we try to put generation-oriented functionality earlier and transformation-oriented functionality later, but |
Thank you for the prompt answer :) Looking forward to the Composition API in the long run then. |
/close I believe my previous comments addressed this. |
@KnVerey: Closing this issue. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Hi,
Any suggestions on how I can use replacements to read the commonLabels value? I'm getting an error at the moment:
Error: nothing selected by Kustomization.[noVer].[noGrp]/[noName].[noNs]:commonLabels.[pipeline/branch]
.I'm looking to have my app pod, and database pod deployed on the same node. I'm using podAffinity to do this. My deployment method means application feature branches get deployed, and each deployment has the unique label
pipeline/branch
. I'm looking to usepipeline/branch
label as thelabelSelector
for podAffinity. I wanted to use replacements to take the label from my kustomization.yaml and replaceme theBRANCH_NAME
is my deployment.sample of my kustomize manifest:
The text was updated successfully, but these errors were encountered: