[英]Pass configMap as argument in a Kubernetes deployment
I have a Dockerfile that starts a java process with this command CMD java -jar application.jar serve /path-to-file/setting.yaml
現在,我想將settings.yaml
為 configMap,所以,我可以在 kubernetes 中管理它,而不是每次更新設置時都構建新的 docker 圖像。
My question is: is possible to achieve this now that I won't be passing setting.yaml in the Dockerfile but a kubernetes yaml as a confiMap?
containers: - name: java-container image: javaimage:1.0 command: [""] args: ["pass the file here"]
是否可以將 kubernetes 部署中的文件作為args[""]
上的 configMap 傳遞
首先,您將創建一個 ConfigMap:
cat <<EOF >file.yaml
[...]
EOF
kubectl create -n my-namespace configmap my-app-config --from-file=settings.yaml=file.yaml
然后,根據容器映像的CMD
中加載的配置文件的路徑,將該 ConfigMap 掛載到正確的位置:
containers:
- name: app
[ ... ]
volumeMounts:
- name: config-volume
path: /path-to-file/settings.yaml
subPath: settings.yaml
[ ... ]
volumes:
- name: config-volume
configMap:
name: my-app-config
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.