Skip to content
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

[Question] How can i use variables in kustomization.yaml file #4787

Closed
Kristin0 opened this issue Sep 3, 2022 · 7 comments
Closed

[Question] How can i use variables in kustomization.yaml file #4787

Kristin0 opened this issue Sep 3, 2022 · 7 comments
Labels
kind/support Categorizes issue or PR as a support question. triage/out-of-scope Indicates an issue or PR is not a fit for Kustomize's scope and/or principles

Comments

@Kristin0
Copy link

Kristin0 commented Sep 3, 2022

For example i want in file
kustomization.yaml smth like this

resources:
  - deployment.yaml
namespace: $(namespace)

vars:
  - name: namespace
    objref:
      kind: ClusterContext
      name: clustercontext
      apiVersion: msc.test.com/v1alpha1
    fieldref:
      fieldpath: spec.TEST_NAMESPACE
@k8s-ci-robot
Copy link
Contributor

@Kristin0: 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 triage/accepted label.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

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.

@k8s-ci-robot k8s-ci-robot added needs-kind Indicates a PR lacks a `kind/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Sep 3, 2022
@Kristin0 Kristin0 changed the title How can i use variables in kustomization.yaml file [Question] [Question] How can i use variables in kustomization.yaml file Sep 3, 2022
@tdi
Copy link

tdi commented Sep 5, 2022

hi @Kristin0 I think having variables like that is against the kustomize principles of having clean builds (https://kubectl.docs.kubernetes.io/faq/kustomize/eschewedfeatures/#build-time-side-effects-from-cli-args-or-env-variables).

You can use something like that kustomize edit set namespace $NAMESPACE_FROM_ENV if namespace is in metadata field it will be effective.

@Kristin0
Copy link
Author

Kristin0 commented Sep 6, 2022

Ok, thanks

@KnVerey
Copy link
Contributor

KnVerey commented Sep 6, 2022

@tdi is correct. Variables go against a core goal of Kustomize, namely to provide a template-free solution. The "vars" feature you referenced does not really work like variables and is being removed in favour of replacements. #4049

/triage out-of-scope
/close

@k8s-ci-robot k8s-ci-robot added the triage/out-of-scope Indicates an issue or PR is not a fit for Kustomize's scope and/or principles label Sep 6, 2022
@k8s-ci-robot
Copy link
Contributor

@KnVerey: Closing this issue.

In response to this:

@tdi is correct. Variables go against a core goal of Kustomize, namely to provide a template-free solution. The "vars" feature you referenced does not really work like variables and is being removed in favour of replacements. #4049

/triage out-of-scope
/close

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.

@mtrin
Copy link

mtrin commented Nov 4, 2022

@KnVerey
Does it mean this documentation is out of date?
What is the official, most up-to-date documentation source for Kustomize?
Thanks!

@KnVerey KnVerey added kind/support Categorizes issue or PR as a support question. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Nov 15, 2022
@k8s-ci-robot k8s-ci-robot removed the needs-kind Indicates a PR lacks a `kind/foo` label and requires one. label Nov 15, 2022
@KnVerey
Copy link
Contributor

KnVerey commented Nov 15, 2022

At a glance that doc looks fine to me, but is about advanced transformer configuration. It does mention the existing vars feature (which as mentioned above is not actually variables, despite the name) as an example; that feature is being deprecated but still works in current versions, as advised in the linked doc. The best docs for Kustomize are currently in the SIG CLI site: https://kubectl.docs.kubernetes.io. There is a slowly progressing initiative to consolidate the various sources into a dedicated site: #4338.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/support Categorizes issue or PR as a support question. triage/out-of-scope Indicates an issue or PR is not a fit for Kustomize's scope and/or principles
Projects
None yet
Development

No branches or pull requests

5 participants