我原来的 YAML
基础/部署.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=
基础/Kustomization.yaml
resources:
- deployment.yaml
commonLabels:
owner: sara
从 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
如果您在上面观察到,ConfigMap 正在被丢弃,请建议如何解决该问题。
在 Kustomize 的两个版本中 - 当前最新的 (
v.4.4.0
) 并v4.1.3
在问题中使用它可以正常工作。作者注意到重启可以帮助:请记住两件事:
base/Kustomization.yaml
名称不能使用;你会得到一个错误Error: unable to find one of 'kustomization.yaml', 'kustomization.yml' or 'Kustomization' in directory
。需要使用正确的名称。kustomize build base
ConfigMap 将在输出的顶部生成,即使它是在资源文件的底部定义的。检查下面。命令的输出
kustomize build base
: