gpt4 book ai didi

Kubernetes configMap - 只有一个文件

转载 作者:行者123 更新时间:2023-12-02 23:20:55 29 4
gpt4 key购买 nike

我有一个从文件创建的configMap:

kubectl create configmap ssportal-apache-conf --from-file=ssportal.conf=ssportal.conf

然后我需要将此文件安装到部署中:

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: ssportal
spec:
replicas: 2
template:
metadata:
labels:
app: ssportal
spec:
containers:
- name: ssportal
image: eu.gcr.io/my-project/ssportal:0.0.0
ports:
- containerPort: 80
volumeMounts:
- name: apache2-config-volume
mountPath: /etc/apache2/
volumes:
- name: apache2-config-volume
configMap:
name: ssportal-apache-conf
items:
- key: ssportal.conf
path: sites-enabled/ssportal.conf

但这实际上会从容器中删除现有的 /etc/apache2/ 目录,并将其替换为唯一的文件 /etc/apache2/sites-enabled/ssportal.conf.

是否可以在现有配置目录上仅覆盖一个文件?

最佳答案

好吧,这有点棘手。最终的工作 YAML 规范是

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: ssportal
spec:
replicas: 2
template:
metadata:
labels:
app: ssportal
spec:
containers:
- name: ssportal
image: eu.gcr.io/my-project/ssportal:0.0.0
command: ["sleep","120d"]
ports:
- containerPort: 80
volumeMounts:
- name: test
mountPath: /etc/apache2/conf-enabled/test.conf
subPath: test.conf
volumes:
- name: test
configMap:
name: sstest

configMap创建步骤:

echo "# comment" > test.conf
kubectl create configmap sstest --from-file=test.conf=test.conf

关于Kubernetes configMap - 只有一个文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44325048/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com