您可以创建ConfigMap对象,然后将值作为文件挂载到您需要的位置:
原文链接:https://www.f2er.com/nginx/435023.htmlapiVersion: v1
kind: ConfigMap
Metadata:
name: Nginx-config
data:
Nginx.conf: |
your config
comes here
like this
other.conf: |
second file
contents
在你的pod规格:
spec:
containers:
- name: Nginx
image: Nginx
volumeMounts:
- name: Nginx-config
mountPath: /etc/Nginx/Nginx.conf
subPath: Nginx.conf
- name: Nginx-config
mountPath: /etc/Nginx/other.conf
subPath: other.conf
volumes:
- name: Nginx-config
configMap:
name: Nginx-config
(注意mountPath中文件名的重复,并使用完全相同的子路径;与bind装入文件相同.)
有关ConfigMap的更多信息,请参阅:
https://kubernetes.io/docs/user-guide/configmap/