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

Secret hash is not taken into account by spec.template.spec.volumes.azureFile.secretName #4498

Closed
stefano-salari opened this issue Feb 28, 2022 · 10 comments
Labels
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/accepted Indicates an issue or PR is ready to be actively worked on.

Comments

@stefano-salari
Copy link

When a deployment file volumes section makes use of {{azureFile}} definition, the {{secretName}} reference inside it, does not takes into account the secret hash generated by Kustomize.

Files that can reproduce the issue

kustomization.yaml

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

resources:
  - deployment.yaml

secretGenerator:
- name: secret-credentials
  envs:
  - secret-credentials.env

secret-credentials.env

azurestorageaccountname=storage-account-name
azurestorageaccountkey=storage-account-key

deployment.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: test-deployment
spec:
  replicas: 1
  selector:
    matchLabels:
      app.kubernetes.io/name: test-deployment
  template:
    metadata:
      labels:
        app.kubernetes.io/name: test-deployment
    spec:
      containers:
      - name: test-deployment
        image: busybox
        imagePullPolicy: IfNotPresent
        envFrom:
        - secretRef:
            name: secret-credentials
        resources:
          limits:
            cpu: 100m
            memory: 100Mi
          requests:
            cpu: 100m
            memory: 100Mi
        volumeMounts:
        - name: azure-share
          mountPath: /test-share
      volumes:
      - name: azure-share
        azureFile:
          secretName: secret-credentials
          shareName: test-share

Expected output

The secret referenced in both the {{envFrom}} and {{secretName}} properties is expected to report the hash suffix created by the secret generator:

apiVersion: v1
data:
  azurestorageaccountkey: c3RvcmFnZS1hY2NvdW50LWtleQ==
  azurestorageaccountname: c3RvcmFnZS1hY2NvdW50LW5hbWU=
kind: Secret
metadata:
  name: secret-credentials-8b6bkhgkkb
type: Opaque
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: test-deployment
spec:
  [...]
  template:
    [...]
    spec:
      containers:
      - name: test-deployment
        envFrom:
        - secretRef:
            name: secret-credentials-8b6bkhgkkb
        [...]
      volumes:
      - azureFile:
          secretName: secret-credentials-8b6bkhgkkb
        [...]

Actual output

Here follows the whole output of the {{kustomize build}} command. Note that the {{spec.template.spec.volumes.azureFile.secretName}} does not references the actual secret name because is missing the generated hash:

apiVersion: v1
data:
  azurestorageaccountkey: c3RvcmFnZS1hY2NvdW50LWtleQ==
  azurestorageaccountname: c3RvcmFnZS1hY2NvdW50LW5hbWU=
kind: Secret
metadata:
  name: secret-credentials-8b6bkhgkkb
type: Opaque
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: test-deployment
spec:
  replicas: 1
  selector:
    matchLabels:
      app.kubernetes.io/name: test-deployment
  template:
    metadata:
      labels:
        app.kubernetes.io/name: test-deployment
    spec:
      containers:
      - envFrom:
        - secretRef:
            name: secret-credentials-8b6bkhgkkb
        image: busybox
        imagePullPolicy: IfNotPresent
        name: test-deployment
        resources:
          limits:
            cpu: 100m
            memory: 100Mi
          requests:
            cpu: 100m
            memory: 100Mi
        volumeMounts:
        - mountPath: /test-share
          name: azure-share
      volumes:
      - azureFile:
          secretName: secret-credentials
          shareName: test-share
        name: azure-share

Kustomize version

Reproduced with both kustomize v4.0.5 and v4.5.2:
{Version:kustomize/v4.0.5 GitCommit:9e8e7a7fe99ec9fbf801463e8607928322fc5245 BuildDate:2021-03-08T20:53:03Z GoOs:darwin GoArch:amd64}
{Version:kustomize/v4.5.2 GitCommit:9091919699baf1c5a5bf71b32ca73a993e98088b BuildDate:2022-02-09T23:26:42Z GoOs:darwin GoArch:amd64}

Platform

Both Linux and macOS

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

KnVerey commented Mar 16, 2022

We believe this is happening because the field specs used by the name reference transformer currently do not include spec.template.spec.volumes.azureFile.secretName as a possible location for a secret name. This is the file that needs to be updated: https://github.com/kubernetes-sigs/kustomize/blob/master/api/konfig/builtinpluginconsts/namereference.go#L134-L271

/triage accepted
/kind bug

@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
@jimethn
Copy link

jimethn commented Mar 21, 2022

I am seeing this same problem, but specifically for CRDs.

If I have a secretGenerator, any Deployments or StatefulSets that reference the generated secret will have the reference updated with the name suffix hash. However, if a CRD references that secret, it does not get the reference updated.

@KnVerey
Copy link
Contributor

KnVerey commented Apr 7, 2022

It is not possible for Kustomize to handle references in CRDs by default. Please see the CRDs and configurations features. (Note: we have a longer-term issue to reconcile these and the openapi field: #3944 #3945))

@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 Jul 6, 2022
@KnVerey
Copy link
Contributor

KnVerey commented Jul 7, 2022

/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 Jul 7, 2022
@dani-santos-code
Copy link
Contributor

/assign

@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 Nov 7, 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 Dec 7, 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 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

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

/close not-planned

@k8s-ci-robot
Copy link
Contributor

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

In response to this:

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

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

/close not-planned

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/test-infra repository.

@k8s-ci-robot k8s-ci-robot closed this as not planned Won't fix, can't repro, duplicate, stale Jan 6, 2023
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. lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
Development

No branches or pull requests

6 participants