kubernetes-sigs / kustomize

Customization of kubernetes YAML configurations
Apache License 2.0
10.9k stars 2.24k forks source link

Can kustomizations configMapGenerator use the file in parent folder, thanks. #5749

Open johnzheng1975 opened 1 month ago

johnzheng1975 commented 1 month ago

Eschewed features

What would you like to have added?

$ cat kustomization.yaml
generatorOptions:
  disableNameSuffixHash: true
configMapGenerator:
  - name: try01
    files:
      - application.yaml
      - ../asset-manifest.yaml

$ kustomize build .
Error: loading KV pairs: file sources: [application.yaml ../asset-manifest.yaml]: security; file '/home/oc-dev-blue/golang-try01-quickstart/asset-manifest.yaml' is not in y01-quickstart/deploy'

Why is this needed?

can we use the files in parent folder, or any workarround for this? thanks.

Can you accomplish the motivating task without this feature, and if so, how?

we have to move all files in same folder of kustomization.yaml However, in real case, this is not true.

What other solutions have you considered?

copy duplicate files in kustomization.yaml, the code structure is ugly.

Anything else we should know?

No response

Feature ownership

k8s-ci-robot commented 1 month ago

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](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes-sigs/prow](https://github.com/kubernetes-sigs/prow/issues/new?title=Prow%20issue:) repository.
johnzheng1975 commented 1 month ago

Then I want to try another solution like:

$ cat kustomization.yaml
generatorOptions:
  disableNameSuffixHash: true
configMapGenerator:
  - name: try01
    files:
      - application.yaml

  - name: client
    literals:
      - securityChampion=$(yq e '.security.champion' ../asset-manifest.yaml)

I wish it can come out correct value, like

$ yq e '.security.champion' ../asset-manifest.yaml
aaa.bbb@ccc.com

However, it still show variable as below, not show aaa.bbb@ccc.com

$ kustomize build .
apiVersion: v1
data:
  securityChampion: $(yq e '.security.champion' ../asset-manifest.yaml)
kind: ConfigMap
metadata:
  name: client