这对我有用
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
和简单的配置映射:
data:
<html></html>
您必须使用更新后的index.html 创建一个新映像,然后在部署中使用此新映像。
如果您希望index.html易于修改,那么
然后,每当你想更新index.html时,你只需要更新ConfigMap并等待几分钟即可。 Kubernetes 将负责同步更新的 index.html。
使用 init 容器进行任何预处理,或者如上所述在使用之前相应地更改 docker 镜像。
那么,在不重新部署的情况下,通常不可能执行到 nginx pod 并更改静态网站的内容吗?