Change index.html nginx kubernetes部署
我有以下部署:Change index.html nginx kubernetes部署,nginx,kubernetes,Nginx,Kubernetes,我有以下部署: 我可以在我的一个pod上编辑索引页,但是如何将其提交到部署映像?因此,当我缩放应用程序时,所有新的POD都将具有相同的图像,并编辑索引。您必须使用更新的index.html创建一个新图像,然后在部署中使用此新图像 如果希望index.html易于修改,那么 创建一个没有index.html文件的新图像 将index.html的内容存储在configMap中 卷将configMap(如上所述)装载到要装载index.html的路径上 然后,每当您想更新index.html时,只需
我可以在我的一个pod上编辑索引页,但是如何将其提交到部署映像?因此,当我缩放应用程序时,所有新的POD都将具有相同的图像,并编辑索引。您必须使用更新的index.html创建一个新图像,然后在部署中使用此新图像 如果希望index.html易于修改,那么
kubectl create configmap nginx-index-html-configmap --from-file=index.html -o yaml --dry-run
然后将此cm作为volumeMount添加到k8s部署对象中。它对我有效
apiVersion: v1
kind: Pod
metadata:
name: nginx
labels:
name: nginx
spec:
containers:
- name: nginx
image: nginx
ports:
- containerPort: 80
volumeMounts:
- mountPath: /usr/share/nginx/html/index.html
name: nginx-conf
subPath: index.html
volumes:
- name: nginx-conf
configMap:
name: nginx-index-html-configmap
和简单的configmap,包括:
data:
<html></html>
数据:
使用init container进行任何预处理,或者如上所述,在使用docker image之前相应地更改它