kustomize: Problem reusing a base containing a variable
When I include a base that defines and uses a variable twice, the variable is not expanded.
Example:
component1/kustomization.yaml:
resources:
- resources.yaml
vars:
- name: VAR
objref:
apiVersion: v1
kind: Pod
name: component1
component1/resources.yaml:
apiVersion: v1
kind: Pod
metadata:
name: component1
spec:
containers:
- name: component1
image: bash
env:
- name: VAR
value: $(VAR)
app1/kustomization.yaml:
bases:
- ../component1
namePrefix: app1-
app2/kustomization.yaml:
bases:
- ../component1
namePrefix: app2-
kustomization.yaml:
bases:
- app1
- app2
Output:
apiVersion: v1
kind: Pod
metadata:
name: app1-component1
spec:
containers:
- env:
- name: VAR
value: $(VAR)
image: bash
name: component1
---
apiVersion: v1
kind: Pod
metadata:
name: app2-component1
spec:
containers:
- env:
- name: VAR
value: $(VAR)
image: bash
name: component1
Output when you comment out one of the app bases in the toplevel kustomization:
apiVersion: v1
kind: Pod
metadata:
name: app1-component1
spec:
containers:
- env:
- name: VAR
value: app1-component1
image: bash
name: component1
Note: this example is silly, but it shows the problem succinctly. In my case, I have an application that uses a variable to discover a database service name to connect to. That application is then used as a base multiple times in order to deploy multiple versions of it.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 6
- Comments: 18 (9 by maintainers)
@jcassee @Shalucik I think we finally nailed it. Have a look here. and in the automatic go tests
Your need to use this PR
I’m also having this problem, is there any news if and when this will be fixed?
Sure, but the variable is resolved on the lower level, right? It means some kustomizations cannot be reused, because they use variables?
Would you say this is a design decision or could it be “fixed”?