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

Name in a configMapRef is not updated to include suffix/prefix when namespace is defined #5827

Open
safizn opened this issue Dec 21, 2024 · 2 comments
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

@safizn
Copy link

safizn commented Dec 21, 2024

What happened?

The same issue appears when using a namespace in the base kustomization.yml. I don't think it is intentional.

Issue

ConfigMap hash generated metadata.name doesn't match Deployment spec.template.spec.containers.envFrom.configMapRef.name; when base kustomization specifies a namespace.

Reproduce

Files at: https://gist.github.com/safizn/a37f399fb2706cf8d73331f42b840ddf

base/deployment.yml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: deployment
spec:
  template: 
    spec: 
      containers:
        - name: container
          envFrom: 
          - configMapRef:
              name: configuration

base/kustomization.yml

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources: 
- deployment.yml
namespace: A

overlay/kustomization.yml

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources: 
- ../base
namePrefix: dev- 
configMapGenerator:
- name: configuration

Expected result

apiVersion: v1
kind: ConfigMap
metadata:
  name: dev-configuration-6ct58987ht
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: dev-deployment
  namespace: A
spec:
  template:
    spec:
      containers:
      - envFrom:
        - configMapRef:
            name: dev-configuration-6ct58987ht
        name: container

Actual result

apiVersion: v1
kind: ConfigMap
metadata:
  name: dev-configuration-6ct58987ht
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: dev-deployment
  namespace: A
spec:
  template:
    spec:
      containers:
      - envFrom:
        - configMapRef:
            name: configuration
        name: container

Difference

$ diff with_namespace.txt without_namespace.txt 
10d9
<   namespace: A
17c16
<             name: configuration
---
>             name: dev-configuration-6ct58987ht

Versions

Linux

$ kubectly version
Client Version: v1.32.0
Kustomize Version: v5.5.0

@safizn safizn added the kind/bug Categorizes issue or PR as related to a bug. label Dec 21, 2024
@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.

@k8s-ci-robot k8s-ci-robot added the needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label Dec 21, 2024
@safizn
Copy link
Author

safizn commented Dec 21, 2024

related to #5047

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