Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/kubernetes/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Change index.html nginx kubernetes部署_Nginx_Kubernetes - Fatal编程技术网

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易于修改,那么

  • 创建一个没有index.html文件的新图像
  • 将index.html的内容存储在configMap中
  • 卷将configMap(如上所述)装载到要装载index.html的路径上
  • 然后,每当您想更新index.html时,只需更新ConfigMap并等待几分钟。Kubernetes将负责同步更新后的index.html。

    遵循此和此

    可以使用以下命令创建configMap

    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之前相应地更改它