My original YAML
base/deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: nginx
name: nginx
spec:
replicas: 1
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- image: nginx
name: nginx
---
apiVersion: v1
kind: ConfigMap
metadata:
name: database-configmap
data:
config: |
dbport=1234
dcname=sfsdf
dbssl=false
locktime=300
domainuser=
base/Kustomization.yaml
resources:
- deployment.yaml
commonLabels:
owner: sara
From the parent folder of base:
kustomize build base
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: nginx
owner: sara
name: nginx
spec:
replicas: 1
selector:
matchLabels:
app: nginx
owner: sara
template:
metadata:
labels:
app: nginx
owner: sara
spec:
containers:
- image: nginx
name: nginx
If you observe above, the ConfigMap is being discarded, please suggest how to fix that.
In both versions of the Kustomize - the current newest (
v.4.4.0
) andv4.1.3
used in the question it is working correctly. The author notice that the restart can help:Keep in mind about two things:
base/Kustomization.yaml
name can't be used; you will get an errorError: unable to find one of 'kustomization.yaml', 'kustomization.yml' or 'Kustomization' in directory
. There is a need to use proper name.kustomize build base
the ConfigMap will be generated at the top of the output, even if it is defined at the bottom in the resource file. Check below.Output of the
kustomize build base
command: