[configmap更改时,Helm图表重新启动Pod

问题描述 投票:5回答:1

我在配置图或秘密更改时尝试重新启动Pod。我尝试过与https://github.com/helm/helm/blob/master/docs/charts_tips_and_tricks.md#automatically-roll-deployments-when-configmaps-or-secrets-change中所述的相同代码但是,更新configmap后,我的pod不会重新启动。您是否知道这里可能做错了什么?

apiVersion: apps/v1beta2
kind: Deployment
metadata:
  name: {{ template "app.fullname" . }}
  labels:
    app: {{ template "app.name" . }}
    {{- include "global_labels" . | indent 4 }}
spec:
  replicas: {{ .Values.replicaCount }}
  selector:
    matchLabels:
      app: {{ template "app.name" . }}
      release: {{ .Release.Name }}
  template:
    metadata:
      annotations:
        checksum/config: {{ include (print $.Template.BasePath "/configmap.yml") . | sha256sum }}
        checksum/secret: {{ include (print $.Template.BasePath "/secret.yml") . | sha256sum }}
kubernetes yaml kubernetes-helm
1个回答
6
投票

Helm和Kubernetes均未提供针对ConfigMap更改的特定滚动更新。解决办法已经有一段时间了,只是对部署进行修补,从而触发滚动更新:

kubectl patch deployment your-deployment -n your-namespace -p '{"spec":{"template":{"metadata":{"annotations":{"date":"$(date)"}}}}}'

您可以看到状态:

kubectl rollout status deployment your-deployment

请注意,这在nix机器上有效。直到添加此feature

© www.soinside.com 2019 - 2024. All rights reserved.