kustomize: nameref does not work with nested bases
cat <<'EOF' > example/kustomization.yaml
bases:
- base
secretGenerator:
- commands:
HELLO: printf 'world'
EOF
cat <<'EOF' > example/base/kustomization.yaml
bases:
- otherbase
EOF
cat <<'EOF' > example/base/otherbase/kustomization.yaml
resources:
- deployment.yaml
EOF
cat <<'EOF' > example/base/otherbase/deployment.yaml
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: example
spec:
template:
spec:
containers:
- name: example
image: example
envFrom:
- secretRef:
name: example
EOF
The output looks like this
apiVersion: v1
data:
HELLO: d29ybGQ=
kind: Secret
metadata:
name: example-c89hbk9m56
type: Opaque
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: example
spec:
template:
spec:
containers:
- envFrom:
- secretRef:
name: example
image: example
name: example
It should look like this
apiVersion: v1
data:
HELLO: d29ybGQ=
kind: Secret
metadata:
name: example-c89hbk9m56
type: Opaque
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: example
spec:
template:
spec:
containers:
- envFrom:
- secretRef:
name: example-c89hbk9m56
image: example
name: example
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 4
- Comments: 19 (10 by maintainers)
@Liujingfang1 Ok you are correct. The issue is not the nested bases, it breaks when you add a namePrefix.
The reference to the secret appears in a base that does not define the secret. If you create the secret in
example/base/otherbase/kustomization.yamland merge it (search for “behavior: merge”) inexample/kustomization.yamlI believe your code will work.@valer-cara I think that PR. If we use your example, without the PR the configMapRef is wrong and does not contain the hash. With the PR the configMapRef is correct.