Skip to content

Commit 88d5d77

Browse files
committed
feat: update evolution chart version to 2.3.0, add CronJob for rolling restart, and enhance service account permissions
1 parent e8b1afc commit 88d5d77

5 files changed

Lines changed: 96 additions & 4 deletions

File tree

charts/evolution/Chart.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ type: application
1515
# This is the chart version. This version number should be incremented each time you make changes
1616
# to the chart and its templates, including the app version.
1717
# Versions are expected to follow Semantic Versioning (https://semver.org/)
18-
version: 1.0.7
18+
version: 2.3.0
1919

2020
# This is the version number of the application being deployed. This version number should be
2121
# incremented each time you make changes to the application. Versions are not expected to
2222
# follow Semantic Versioning. They should reflect the version the application is using.
2323
# It is recommended to use it with quotes.
24-
appVersion: "v2.2.3"
24+
appVersion: "v2.3.0"
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{{- /*
2+
CronJob que força rolling-restart
3+
Habilitado somente se .Values.restartCronJob.enabled = true
4+
*/ -}}
5+
{{- if .Values.restartCronJob.enabled }}
6+
{{- /* --------- helpers --------- */}}
7+
{{- $timezone := default "UTC" .Values.restartCronJob.timezone }}
8+
{{- $targetKind := default "Deployment" .Values.restartCronJob.targetKind }}
9+
{{- $targetName := default (include "evolution.fullname" .) .Values.restartCronJob.targetName }}
10+
{{- $saName := default (printf "%s-restart" (include "evolution.fullname" .)) .Values.restartCronJob.serviceAccount.name }}
11+
12+
apiVersion: batch/v1
13+
kind: CronJob
14+
metadata:
15+
name: {{ include "evolution.fullname" . }}-restart
16+
labels:
17+
{{- include "evolution.labels" . | nindent 4 }}
18+
annotations:
19+
cronjob.kubernetes.io/timezone: "{{ $timezone }}"
20+
spec:
21+
schedule: "{{ .Values.restartCronJob.schedule }}"
22+
successfulJobsHistoryLimit: 1
23+
failedJobsHistoryLimit: 1
24+
jobTemplate:
25+
spec:
26+
template:
27+
spec:
28+
restartPolicy: Never
29+
serviceAccountName: {{ $saName }}
30+
containers:
31+
- name: kubectl
32+
image: "{{ .Values.restartCronJob.image.repository }}:{{ .Values.restartCronJob.image.tag }}"
33+
imagePullPolicy: {{ .Values.restartCronJob.image.pullPolicy }}
34+
command:
35+
- /bin/sh
36+
- -c
37+
- |
38+
set -e
39+
echo "Rolling-restart de {{ $targetKind }}/{{ $targetName }} @ $(date -Iseconds)"
40+
kubectl patch {{ $targetKind | lower }} {{ $targetName }} \
41+
-p "{\"spec\":{\"template\":{\"metadata\":{\"annotations\":{\"restartedAt\":\"$(date -Iseconds)\"}}}}}"
42+
{{- end }}

charts/evolution/templates/deployment.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
apiVersion: apps/v1
22
kind: Deployment
33
metadata:
4+
annotations:
5+
{{- with .Values.podAnnotations }}
6+
{{- toYaml . | nindent 4 }}
7+
{{- end }}
48
name: {{ include "evolution.fullname" . }}
59
labels:
610
{{- include "evolution.labels" . | nindent 4 }}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{{- if and .Values.restartCronJob.enabled .Values.restartCronJob.serviceAccount.create }}
2+
apiVersion: v1
3+
kind: ServiceAccount
4+
metadata:
5+
name: {{ default (printf "%s-restart" (include "evolution.fullname" .)) .Values.restartCronJob.serviceAccount.name }}
6+
labels:
7+
{{- include "evolution.labels" . | nindent 4 }}
8+
---
9+
apiVersion: rbac.authorization.k8s.io/v1
10+
kind: Role
11+
metadata:
12+
name: {{ include "evolution.fullname" . }}-restart
13+
rules:
14+
- apiGroups: ["", "apps"]
15+
resources: ["pods", "deployments", "statefulsets", "daemonsets"]
16+
verbs: ["get", "patch", "delete"]
17+
---
18+
kind: RoleBinding
19+
apiVersion: rbac.authorization.k8s.io/v1
20+
metadata:
21+
name: {{ include "evolution.fullname" . }}-restart
22+
subjects:
23+
- kind: ServiceAccount
24+
name: {{ default (printf "%s-restart" (include "evolution.fullname" .)) .Values.restartCronJob.serviceAccount.name }}
25+
roleRef:
26+
apiGroup: rbac.authorization.k8s.io
27+
kind: Role
28+
name: {{ include "evolution.fullname" . }}-restart
29+
{{- end }}

charts/evolution/values.yaml

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ image:
88
repository: ghcr.io/chatwoot-br/evolution-api
99
pullPolicy: Always
1010
# Overrides the image tag whose default is the chart appVersion.
11-
tag: v2.2.3
11+
tag: v2.3.0
1212

1313
imagePullSecrets: []
1414
nameOverride: ""
@@ -35,7 +35,7 @@ config:
3535
# Configura a Versão do WhatsApp
3636
# Você pode consultar as versões no link abaixo:
3737
# https://web.whatsapp.com/check-update?version=0&platform=web
38-
CONFIG_SESSION_PHONE_VERSION: "2.3000.1023247615"
38+
# CONFIG_SESSION_PHONE_VERSION: "2.3000.1023247615"
3939
# Informa a quantidade de QRCODE que será gerado
4040
QRCODE_LIMIT: "3"
4141
# Informa o idioma da Evolution
@@ -278,3 +278,20 @@ nodeSelector: {}
278278
tolerations: []
279279

280280
affinity: {}
281+
282+
# values.yaml
283+
restartCronJob:
284+
enabled: true # vira false se não quiser instalar
285+
schedule: "0 5 * * *" # 05:00 todo dia
286+
timezone: "America/Sao_Paulo"
287+
# imagem leve que já traz kubectl
288+
image:
289+
repository: bitnami/kubectl
290+
tag: 1.31 # mantenha alinhado ao seu cluster
291+
pullPolicy: IfNotPresent
292+
targetKind: Deployment # ou StatefulSet/DaemonSet/Pod
293+
targetName: ""
294+
# RBAC
295+
serviceAccount:
296+
create: true
297+
name: "" # vazio → usa {{ include "evolution.fullname" . }}-restart

0 commit comments

Comments
 (0)