Helm chart 在 configmap 更改时重新启动 pod [英] Helm chart restart pods when configmap changes

查看:116
本文介绍了Helm chart 在 configmap 更改时重新启动 pod的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 confimap 或秘密更改时重新启动 Pod.我尝试了与以下所述相同的代码:https://github.com/helm/helm/blob/master/docs/charts_tips_and_tricks.md#automatically-roll-deployments-when-configmaps-or-secrets-change但是,更新 configmap 后,我的 pod 没有重新启动.你知道这里可能做错了什么吗?

I am trying to restart the pods when there is a confimap or secret change. I have tried the same piece of code as described in: https://github.com/helm/helm/blob/master/docs/charts_tips_and_tricks.md#automatically-roll-deployments-when-configmaps-or-secrets-change However, after updating the configmap, my pod does not get restarted. Would you have any idea what could has been done wrong here?

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 更改提供特定的滚动更新.解决方法已经有一段时间了,只是修补触发滚动更新的部署:

Neither Helm nor Kubernetes provide a specific rolling update for a ConfigMap change. The workaround has been for a while is to just patch the deployment which triggers the rolling update:

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

你可以看到状态:

kubectl rollout status deployment your-deployment

注意这适用于 nix 机器.直到添加了此功能.

Note this works on a nix machine. This is until this feature is added.

2021 年 5 月 5 日更新

Helm 和 kubectl 现在提供:

Helm and kubectl provide this now:

掌舵:https://helm.sh/docs/howto/charts_tips_and_tricks/#automatically-roll-deployments

kubectl: kubectl rollout restart deploy WORKLOAD_NAME

这篇关于Helm chart 在 configmap 更改时重新启动 pod的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆