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

nested namePrefix configuration behaviour #5870

Open
penekk opened this issue Feb 28, 2025 · 1 comment
Open

nested namePrefix configuration behaviour #5870

penekk opened this issue Feb 28, 2025 · 1 comment
Labels
kind/bug Categorizes issue or PR as related to a bug. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one.

Comments

@penekk
Copy link

penekk commented Feb 28, 2025

What happened?

Let me begin with that I'm not entirely sure this is actually a bug but considering the unintuitive nature of this behaviour I'll go with that.

In order to get my point across let's consider this simplified (in a proper scenario there would be for example more 'bars' and more resources) structure:

Case 1:

apps/foo
├── bar
│   ├── ingress.yaml
│   ├── kustomization.yaml
│   ├── prefixed-resources.yaml
│   └── service-account.yaml
├── generators.yaml
├── jobs.yaml
├── kustomization.yaml
├── prefixed-resources.yaml
└── secrets.enc.yaml

and relevant files:

❯ cat apps/foo/kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namePrefix: foo-
namespace: apps
resources:
  - bar
  - jobs.yaml
generators:
  - generators.yaml
configurations:
  - prefixed-resources.yaml

❯ cat apps/foo/bar/kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namePrefix: bar-
namespace: apps
resources:
  - service-account.yaml
  - ingress.yaml

❯ cat apps/foo/prefixed-resources.yaml
namePrefix:
  - path: metadata/name
    kind: Job

❯ cat apps/foo/jobs.yaml
apiVersion: batch/v1
kind: Job
metadata:
  name: migrations
spec:
  template:
    spec:
      containers: []

In foo there's a namePrefix with explicit config for kinds and in bar there is namePrefix applied on everything.

This results in for example Job: migrations having prefixed applied twice:

---
apiVersion: batch/v1
kind: Job
metadata:
  name: foo-foo-migrations
  namespace: apps
spec:
  template:
    spec:
      containers: []

Case 2:

The difference compared to Case 1 is we do not apply prefix to Job resources in foo but decide to apply it to Job resources in bar:

❯ cat apps/foo/prefixed-resources.yaml
namePrefix:
  # - path: metadata/name
  #   kind: Job
  - path: metadata/name
    kind: Secret
❯ cat apps/foo/bar/kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namePrefix: bar-
namespace: apps
resources:
  - service-account.yaml
  - ingress.yaml
configurations:
  - prefixed-resources.yaml
❯ cat apps/foo/bar/prefixed-resources.yaml
namePrefix:
  - path: metadata/name
    kind: IngressRoute
  - path: metadata/name
    kind: ServiceAccount
  - path: metadata/name
    kind: Job

Which results with Job: migrations having prefix applied once but with value 'from another namePrefix configuration' (so to speak):

---
apiVersion: batch/v1
kind: Job
metadata:
  name: foo-migrations
  namespace: apps
spec:
  template:
    spec:
      containers: []

What did you expect to happen?

Case 1: Job should have prefix foo applied once.

Case 2: Job should not have any prefix applied.

Perhaps I'm misunderstanding something fundamental over here but I would've expected to be able to have a granular control over prefix transformer used but things are gettin mixed/confusing here.

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

.

Expected output

No response

Actual output

No response

Kustomize version

v5.4.1

Operating system

Linux

@penekk penekk added the kind/bug Categorizes issue or PR as related to a bug. label Feb 28, 2025
@k8s-ci-robot k8s-ci-robot added the needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label Feb 28, 2025
@k8s-ci-robot
Copy link
Contributor

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-sigs/prow repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one.
Projects
None yet
Development

No branches or pull requests

2 participants