我在配置图或秘密更改时尝试重新启动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 }}
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。