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

Using nameSuffix is applied to everything but spec/template/spec/volumes/persistentVolumeClaim/claimName of a deployment #5690

Open
svscorp opened this issue May 5, 2024 · 2 comments
Labels
help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. kind/bug Categorizes issue or PR as related to a bug. triage/accepted Indicates an issue or PR is ready to be actively worked on.

Comments

@svscorp
Copy link

svscorp commented May 5, 2024

What happened?

I'm using Kustomize v5.2.1, and trying to add environment related suffix (i.e. -prod, -dev) using nameSuffix in overlays. When I deploy the configuration, I see resources such as pvc, service are properly deployed with the right naming (i.e. grafana-prod), but my deployment can't start, because it can't find the pvc with name "grafana".

My configuration:
base/grafana-persistentvolumeclaim.yaml

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: grafana
spec:
  accessModes:
    - ReadWriteOnce
  storageClassName: longhorn
  resources:
    requests:
      storage: 2Gi`

base/grafana-deployment.yaml
`apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    service: grafana
  name: grafana
  namespace: observability
spec:
  replicas: 1
  selector:
    matchLabels:
      service: grafana
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        network/backend: "true"
        service: grafana
    spec:
      containers:
        - image: grafana/grafana:10.4.2-ubuntu
          name: grafana
          resources: {}
          volumeMounts:
            - mountPath: /var/lib/grafana
              name: grafana
      restartPolicy: Always
      volumes:
        - name: grafana
          persistentVolumeClaim:
            claimName: grafana
status: {}

base/kustomization.yaml

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
- grafana-deployment.yaml
- grafana-service.yaml
- grafana-persistentvolumeclaim.yaml
- longhorn-storageclass.yaml

base/grafana-deployment.yaml (omitted, it's ok)
base/longhorn-storageclass.yaml (omitted, it's ok)

overlays/prod/kustomization.yaml

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
nameSuffix: -prod

resources:
  - ../../base

P.S> Also tried this approach, but this didn't work either https://github.com/kubernetes-sigs/kustomize/blob/master/examples/transformerconfigs/README.md
P.S2> Using transformers, placed into the overlays like this - worked. But for me it looks like a workaround...

apiVersion: builtin
kind: PrefixSuffixTransformer
metadata:
  name: suffix-transformer
suffix: "-prod" 
fieldSpecs:
  - path: spec/volumes/persistentVolumeClaim/claimName
    kind: Deployment
  - path: spec/template/spec/volumes/persistentVolumeClaim/claimName
    kind: Deployment

What did you expect to happen?

I was expecting, that nameSuffix will be properly applied and the claimName of the PVC in deployment template would also become suffixed with "-prod".

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

The configuration can be used, as I wrote in the previous section.

Expected output

No response

Actual output

No response

Kustomize version

5.2.1

Operating system

None

@svscorp svscorp added the kind/bug Categorizes issue or PR as related to a bug. label May 5, 2024
@k8s-ci-robot k8s-ci-robot added the needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label May 5, 2024
@stormqueen1990
Copy link
Member

Similar to #5674, this would require adding the missing path into api/internal/konfig/builtinpluginconsts/namereference.go, along with a test case in api/krusty/namereference_test.go.

Sample PR: #5698

/triage accepted
/help

@k8s-ci-robot
Copy link
Contributor

@stormqueen1990:
This request has been marked as needing help from a contributor.

Guidelines

Please ensure that the issue body includes answers to the following questions:

  • Why are we solving this issue?
  • To address this issue, are there any code changes? If there are code changes, what needs to be done in the code and what places can the assignee treat as reference points?
  • Does this issue have zero to low barrier of entry?
  • How can the assignee reach out to you for help?

For more details on the requirements of such an issue, please see here and ensure that they are met.

If this request no longer meets these requirements, the label can be removed
by commenting with the /remove-help command.

In response to this:

Similar to #5674, this would require adding the missing path into api/internal/konfig/builtinpluginconsts/namereference.go, along with a test case in api/krusty/namereference_test.go.

Sample PR: #5698

/triage accepted
/help

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.

@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels May 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. kind/bug Categorizes issue or PR as related to a bug. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
Development

No branches or pull requests

3 participants