Sfoglia il codice sorgente

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
Nicklas Frahm 4 anni fa
parent
commit
6b8910e26c

+ 1 - 0
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 |""|

+ 4 - 0
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

+ 8 - 0
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" . }}

+ 3 - 0
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