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

ConfigMap generated hashes don't get replaced when using replacements #4475

Open
Shalucik opened this issue Feb 15, 2022 · 13 comments
Open

ConfigMap generated hashes don't get replaced when using replacements #4475

Shalucik opened this issue Feb 15, 2022 · 13 comments
Assignees
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. lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. triage/under-consideration

Comments

@Shalucik
Copy link

Describe the bug

I'm trying to replace vars with replacements.
I have a var that is used to give an Deployments env value the name of a ConfigMap created by a configMapGenerator

When using replacements for this, the env value is replaced without the generated hash suffix

Files that can reproduce the issue

kustomization.yaml

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
  - deployment.yaml
 
configMapGenerator:
  - name: test
  
replacements:
  - source:
      kind: ConfigMap
      name: test
      fieldPath: metadata.name
    targets:
      - select:
          kind: Deployment
          name: test
        fieldPaths:
          - spec.template.spec.containers.[name=test].env.[name=test].value

deployment.yaml

kind: Deployment
apiVersion: apps/v1
metadata:
  name: test
spec:
  selector:
    matchLabels:
      app: test
  template:
    metadata:
      labels:
        app: test
    spec:
      containers:
        - name: test
          env:
            - name: test
              value: REPLACE

Expected output

apiVersion: v1
kind: ConfigMap
metadata:
  name: test-6ct58987ht
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: test
spec:
  selector:
    matchLabels:
      app: test
  template:
    metadata:
      labels:
        app: test
    spec:
      containers:
      - env:
        - name: test
          value: test-6ct58987ht
        name: test

Actual output

apiVersion: v1
kind: ConfigMap
metadata:
  name: test-6ct58987ht
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: test
spec:
  selector:
    matchLabels:
      app: test
  template:
    metadata:
      labels:
        app: test
    spec:
      containers:
      - env:
        - name: test
          value: test
        name: test

Kustomize version

4.5.2

Platform

Linux

Additional context

@Shalucik Shalucik added the kind/bug Categorizes issue or PR as related to a bug. label Feb 15, 2022
@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 15, 2022
@natasha41575
Copy link
Contributor

Went to add a test for this, and realized one already exists! There is an older issue that ended up not getting addressed due to lack of bandwidth (#4034). In general, I agree that replacements would ideally keep track of name references. I will see if I have the bandwidth to work on this in the next few weeks.

/triage accepted

@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Mar 16, 2022
@natasha41575 natasha41575 added the help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. label Mar 16, 2022
@k8s-triage-robot
Copy link

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

This bot triages issues and PRs 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:

  • Mark this issue or PR as fresh with /remove-lifecycle stale
  • Mark this issue or PR as rotten with /lifecycle rotten
  • Close this issue or PR with /close
  • Offer to help out with Issue Triage

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

/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jun 14, 2022
@natasha41575
Copy link
Contributor

/remove-lifecycle stale

@k8s-ci-robot k8s-ci-robot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jun 22, 2022
@k8s-triage-robot
Copy link

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

This bot triages issues and PRs 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:

  • Mark this issue or PR as fresh with /remove-lifecycle stale
  • Mark this issue or PR as rotten with /lifecycle rotten
  • Close this issue or PR with /close
  • Offer to help out with Issue Triage

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

/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Sep 20, 2022
@k8s-triage-robot
Copy link

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

This bot triages issues and PRs 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:

  • Mark this issue or PR as fresh with /remove-lifecycle rotten
  • Close this issue or PR with /close
  • Offer to help out with Issue Triage

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

/lifecycle rotten

@k8s-ci-robot k8s-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Oct 20, 2022
@sallylyen
Copy link

hi, I was wondering if anyone was working on this issue?

@natasha41575
Copy link
Contributor

natasha41575 commented Dec 9, 2022

We had a discussion quite a while ago discussing name references in replacements, and concluded that with the current implementation of name references, doing this in replacements is impractical. I think we need to think more about this, as this ties in with some discussion about rewriting the way we do name references and fieldspecs.

Using the name reference transformer directly as suggested here may help.

/triage under-consideration

@dornimaug
Copy link

What's the status? Kustomize v5.0.0 was released in February officially deprecating vars, but replacements still lack this essential functionality.

@barakatintel
Copy link

facing the same issue
kustomize replaces config map generator hashes for cronjob, but does not do that for deployment

progamesigner added a commit to progamesigner/manifests that referenced this issue May 26, 2023
Currently there are bugs in "replacements" transformer that cannot
replace hashed ConfigMap or Secret names.

See: kubernetes-sigs/kustomize#4475
@k8s-triage-robot
Copy link

This issue has not been updated in over 1 year, and should be re-triaged.

You can:

  • Confirm that this issue is still relevant with /triage accepted (org members only)
  • Close this issue with /close

For more details on the triage process, see https://www.kubernetes.dev/docs/guide/issue-triage/

/remove-triage accepted

@k8s-ci-robot k8s-ci-robot removed the triage/accepted Indicates an issue or PR is ready to be actively worked on. label Apr 4, 2024
@purvaldur
Copy link

purvaldur commented Sep 3, 2024

Is any work being done on this?
If not, is anything planned at all to address this?

I'd like to avoid using vars which is deprecated but replacements which was supposed to "replace" it doesn't have nearly the same functionality.

@solteranis
Copy link

+1 for this. We too experience the same issues, and will prevent us from upgrading kustomize at this point. Is there any accepted/documented work arounds?

@sandeeprudraraju
Copy link

How is this implemented using vars?

replacements:

  • source:
    kind: ConfigMap
    fieldPath: metadata.name
    name: filebeat-infra-config-generated
    targets:
    • select:
      name: filebeat-infra
      kind: DaemonSet
      fieldPaths:

      • spec.template.metadata.annotations.configMapChecksum

      It is still not replacing checksum in daemonset with filebeat-infra-config-generated-hashvalue.

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. lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. triage/under-consideration
Projects
None yet
Development

No branches or pull requests

10 participants