kubernetes-sigs / kustomize

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

Namespaces not added to Resources of Components #5329

Open sanmai-NL opened 11 months ago

sanmai-NL commented 11 months ago

What happened?

When using a Base, and perhaps Overlay, the namespace field in kustomization.yml is applied to all Resources. When adding a Resource from a Component, its kustomization.yml has to repeat the namespace field.

What did you expect to happen?

Either namespace is inherited, optionally controlled, and/or the behavior is documented.

How can we reproduce it (as minimally and precisely as possible)?

# base/kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namepace: test
components:
- ../../components/test
resources:
- resource1.yml
# base/resource1.yml
apiVersion: v1
kind: ConfigMap
metadata:
  name: test-object
data:
  placeholder: data
# components/test/kustomization.yml
apiVersion: kustomize.config.k8s.io/v1alpha1
kind: Component
resources:
- resource2.yml
# components/test/resource2.yml
apiVersion: v1
kind: ConfigMap
metadata:
  name: test-object2
data:
  placeholder: data2

Expected output

Actual output

Kustomize version

v5.1.1

Operating system

MacOS

natasha41575 commented 7 months ago

@ncapps Could you please investigate how components work with respect to the ordering of transformers (in this case the namespace transformer) and report back? Ideally we will understand how it works, rationalize it, and then decide whether to change or document the behavior.

Here is a starting point for where to look in the code: https://github.com/kubernetes-sigs/kustomize/blob/ab519fdc13ded9875e42d70ac8a5b1b9023a2dbb/api/internal/target/kusttarget.go#L232

Here is the KEP for the original design of components: https://github.com/kubernetes/enhancements/tree/master/keps/sig-cli/1802-kustomize-components

/assign @ncapps

k8s-triage-robot commented 4 months ago

The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

You can:

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

k8s-triage-robot commented 3 months ago

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

You can:

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle rotten

sanmai-NL commented 3 months ago

@ncapps What's the status?

k8s-triage-robot commented 2 months ago

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues according to the following rules:

You can:

Please send feedback to sig-contributor-experience at kubernetes/community.

/close not-planned

k8s-ci-robot commented 2 months ago

@k8s-triage-robot: Closing this issue, marking it as "Not Planned".

In response to [this](https://github.com/kubernetes-sigs/kustomize/issues/5329#issuecomment-2171362081): >The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs. > >This bot triages issues according to the following rules: >- After 90d of inactivity, `lifecycle/stale` is applied >- After 30d of inactivity since `lifecycle/stale` was applied, `lifecycle/rotten` is applied >- After 30d of inactivity since `lifecycle/rotten` was applied, the issue is closed > >You can: >- Reopen this issue with `/reopen` >- Mark this issue as fresh with `/remove-lifecycle rotten` >- Offer to help out with [Issue Triage][1] > >Please send feedback to sig-contributor-experience at [kubernetes/community](https://github.com/kubernetes/community). > >/close not-planned > >[1]: https://www.kubernetes.dev/docs/guide/issue-triage/ 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.
sanmai-NL commented 2 months ago

/reopen

k8s-ci-robot commented 2 months ago

@sanmai-NL: Reopened this issue.

In response to [this](https://github.com/kubernetes-sigs/kustomize/issues/5329#issuecomment-2171891808): >/reopen 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.
sanmai-NL commented 2 months ago

/remove-lifecycle rotten