From 6b8910e26c8e26ae29b971ced85724305c27b4b0 Mon Sep 17 00:00:00 2001 From: Nicklas Frahm Date: Tue, 1 Jun 2021 13:27:49 +0200 Subject: [PATCH] feat(helm): Add flag to force pod recreation as part of helm upgrade (#4898) * feat(helm): Add flag to force pod recreation as part of helm upgrade * feat(helm): Recreate pods when configuration changes * fix(helm): Remove warnings by using v1 of RBAC API for clusters >= 1.17 * chore(CI): Increment version number * fix(CI): Bump version * chore(CI): Undo version bump --- deploy/charts/emqx/README.md | 1 + deploy/charts/emqx/templates/StatefulSet.yaml | 4 ++++ deploy/charts/emqx/templates/rbac.yaml | 8 ++++++++ deploy/charts/emqx/values.yaml | 3 +++ 4 files changed, 16 insertions(+) diff --git a/deploy/charts/emqx/README.md b/deploy/charts/emqx/README.md index 1ba1e3266..535ccb8e1 100644 --- a/deploy/charts/emqx/README.md +++ b/deploy/charts/emqx/README.md @@ -37,6 +37,7 @@ The following table lists the configurable parameters of the emqx chart and thei | `image.repository` | EMQ X Image name |emqx/emqx| | `image.pullPolicy` | The image pull policy |IfNotPresent| | `image.pullSecrets ` | The image pull secrets |`[]` (does not add image pull secrets to deployed pods)| +| `recreatePods` | Forces the recreation of pods during upgrades, which can be useful to always apply the most recent configuration. | false | | `persistence.enabled` | Enable EMQX persistence using PVC |false| | `persistence.storageClass` | Storage class of backing PVC |`nil` (uses alpha storage class annotation)| | `persistence.existingClaim` | EMQ X data Persistent Volume existing claim name, evaluated as a template |""| diff --git a/deploy/charts/emqx/templates/StatefulSet.yaml b/deploy/charts/emqx/templates/StatefulSet.yaml index 3a385732a..4cad21569 100644 --- a/deploy/charts/emqx/templates/StatefulSet.yaml +++ b/deploy/charts/emqx/templates/StatefulSet.yaml @@ -47,6 +47,10 @@ spec: version: {{ .Chart.AppVersion }} app.kubernetes.io/name: {{ include "emqx.name" . }} app.kubernetes.io/instance: {{ .Release.Name }} + {{- if .Values.recreatePods }} + annotations: + checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum | quote }} + {{- end }} spec: volumes: - name: emqx-loaded-plugins diff --git a/deploy/charts/emqx/templates/rbac.yaml b/deploy/charts/emqx/templates/rbac.yaml index f1536836b..87cd18178 100644 --- a/deploy/charts/emqx/templates/rbac.yaml +++ b/deploy/charts/emqx/templates/rbac.yaml @@ -5,7 +5,11 @@ metadata: name: {{ include "emqx.fullname" . }} --- kind: Role +{{- if semverCompare ">=1.17-0" .Capabilities.KubeVersion.GitVersion }} +apiVersion: rbac.authorization.k8s.io/v1 +{{- else }} apiVersion: rbac.authorization.k8s.io/v1beta1 +{{- end }} metadata: namespace: {{ .Release.Namespace }} name: {{ include "emqx.fullname" . }} @@ -20,7 +24,11 @@ rules: - list --- kind: RoleBinding +{{- if semverCompare ">=1.17-0" .Capabilities.KubeVersion.GitVersion }} +apiVersion: rbac.authorization.k8s.io/v1 +{{- else }} apiVersion: rbac.authorization.k8s.io/v1beta1 +{{- end }} metadata: namespace: {{ .Release.Namespace }} name: {{ include "emqx.fullname" . }} diff --git a/deploy/charts/emqx/values.yaml b/deploy/charts/emqx/values.yaml index 34302e09a..0e6f24a66 100644 --- a/deploy/charts/emqx/values.yaml +++ b/deploy/charts/emqx/values.yaml @@ -14,6 +14,9 @@ image: # pullSecrets: # - myRegistryKeySecretName +## Forces the recreation of pods during helm upgrades. This can be useful to update configuration values even if the container image did not change. +recreatePods: false + persistence: enabled: false size: 20Mi