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

secretName in azureFile doesn't expand vars #1390

Closed
jstralko opened this issue Jul 24, 2019 · 2 comments
Closed

secretName in azureFile doesn't expand vars #1390

jstralko opened this issue Jul 24, 2019 · 2 comments

Comments

@jstralko
Copy link

For example, the following example doesn't seem to expand the vars for secretName:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: app
spec:
  template:
    spec:
      containers:
          - name: app
            volumeMounts:
            - name: appMnt
              mountPath: /data
      volumes:
      - name: appMnt
        azureFile:
          secretName: $(STORAGE_SECRET)
          shareName: appMnt-share
          readOnly: true
---
vars:
- name : STORAGE_SECRET
  objref:
    kind: Secret
    name: storage-secret
    apiVersion: v1
  fieldref:
    fieldpath: metadata.name

STORAGE_SECRET is never transformed. I even get a warning saying: well-defined vars that were never replaced: STORAGE_SECRET Is this something that isn't supported? Since I'm using namePrefix I need to get storage name via this way.

@jbrette
Copy link
Contributor

jbrette commented Jul 24, 2019

@jstralko Your are missing a kustomizeconfig.yaml

We attempted to reproduce your issue here

The output will look like that:

kustomize build manual
apiVersion: v1
data:
  password: c29tZXB3
  username: YWRtaW4=
kind: Secret
metadata:
  name: pfx-storage-secret
type: Opaque
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: pfx-app
spec:
  template:
    spec:
      containers:
      - name: app
        volumeMounts:
        - mountPath: /data
          name: appMnt
      volumes:
      - azureFile:
          readOnly: true
          secretName: pfx-storage-secret
          shareName: appMnt-share
        name: appMnt

kustomizeconfig.yaml:

varReference:
- kind: Deployment
  path: spec/template/spec/volumes[]/azureFile/secretName

kustomization.yaml

namePrefix: pfx-

resources:
- deployment.yaml
- secret.yaml

configurations:
- kustomizeconfig.yaml

vars:
- name : STORAGE_SECRET
  objref:
    kind: Secret
    name: storage-secret
    apiVersion: v1
  fieldref:
    fieldpath: metadata.name

@jstralko
Copy link
Author

Thank you so much! That was the missing piece. I appreciate the quick response.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants