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
Kubernetes configmap更改不需要';t在各自的POD上自动反射_Kubernetes_Kubernetes Pod - Fatal编程技术网

Kubernetes configmap更改不需要';t在各自的POD上自动反射

Kubernetes configmap更改不需要';t在各自的POD上自动反射,kubernetes,kubernetes-pod,Kubernetes,Kubernetes Pod,对于创建configmap,我使用以下命令: apiVersion: apps/v1 # for versions before 1.8.0 use apps/v1beta1 kind: Deployment metadata: name: consoleservice1 spec: selector: matchLabels: app: consoleservice1 replicas: 3 # t

对于创建configmap,我使用以下命令:

apiVersion: apps/v1 # for versions before 1.8.0 use apps/v1beta1
    kind: Deployment
    metadata:
      name: consoleservice1
    spec:
      selector:
        matchLabels:
          app: consoleservice1
      replicas: 3 # tells deployment to run 3 pods matching the template
      strategy:
        type: RollingUpdate
        rollingUpdate:
          maxSurge: 1
          maxUnavailable: 1
      minReadySeconds: 5
      template: # create pods using pod definition in this template
        metadata:
          labels:
            app: consoleservice1
        spec:
          containers:
          - name: consoleservice
            image: chintamani/insightvu:ms-console1
            readinessProbe:
              httpGet:
                path: /
                port: 8385
              initialDelaySeconds: 5
              periodSeconds: 5
              successThreshold: 1
            ports:
            - containerPort: 8384
            imagePullPolicy: Always
            volumeMounts:
              - mountPath: /deploy/config
                name: config
          volumes:
            - name: config
              configMap:
                name: console-config

在configmap中更改时,它不会自动反映,每次我都必须重新启动pod。我怎样才能自动完成它呢?

谢谢你们。能够修复它,我正在使用重新加载程序来反映吊舱内部是否发生了任何变化 kubectl应用-f

然后在deployment.yml文件中添加注释

kubectl create configmap console-config --from-file=deploy/config

它将逐渐重新启动您的Pod。

Pod和configmap在Kubernetes中是完全独立的,如果configmap发生更改,Pod不会自动重新启动

要做到这一点,几乎没有其他选择

  • 使用wave,它是一个Kubernetes控制器,用于查找特定注释,并在configmap中发生任何更改时更新部署

  • 使用,重新加载程序可以监视configmap更改,并可以更新pod以选择新配置

    apiVersion: apps/v1 # for versions before 1.8.0 use apps/v1beta1
    kind: Deployment
    metadata:
      name: consoleservice1
      annotations:
        configmap.reloader.stakater.com/reload: "console-config"
    
  • 您可以在部署和CI/CD中添加自定义configHash注释,也可以在部署应用程序时使用
    yq
    将该值替换为configmap的哈希值,以防configmap中发生任何更改。Kubernetes将检测部署注释中的更改,并使用新配置重新加载吊舱

  • apiVersion: apps/v1 # for versions before 1.8.0 use apps/v1beta1
    kind: Deployment
    metadata:
      name: consoleservice1
      annotations:
        configmap.reloader.stakater.com/reload: "console-config"
    
    yq w--inplace deployment.yaml spec.template.metadata.annotations.configHash$(kubectl get cm/configmap-oyaml | sha256sum)


    参考资料:

    您好,当configmap中发生更改时,k8s不会触发新pod部署。下面是问题的详细信息,这里是该线程中的一些解决方案
            apiVersion: apps/v1 # for versions before 1.8.0 use apps/v1beta1
            kind: Deployment
            metadata:
              name: application
            spec:
              selector:
                matchLabels:
                  app: consoleservice1
              replicas: 3              
              template:
                metadata:
                  labels:
                    app: consoleservice1
                  annotations:
                    configHash: ""