Skip to content

Commit 9493989

Browse files
authored
feat: auto restart deployment when config files change (#36)
Signed-off-by: Zhiming Guo <guo.zhming@gmail.com>
1 parent f535ead commit 9493989

4 files changed

Lines changed: 31 additions & 3 deletions

File tree

charts/zot/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ appVersion: v2.0.1
33
description: A Helm chart for Kubernetes
44
name: zot
55
type: application
6-
version: 0.1.46
6+
version: 0.1.47

charts/zot/templates/deployment.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,13 @@ spec:
1111
{{- include "zot.selectorLabels" . | nindent 6 }}
1212
template:
1313
metadata:
14-
{{- with .Values.podAnnotations }}
1514
annotations:
15+
{{- with .Values.podAnnotations }}
1616
{{- toYaml . | nindent 8 }}
17-
{{- end }}
17+
{{- end }}
18+
{{- if and .Values.mountConfig .Values.configFiles }}
19+
checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
20+
{{- end }}
1821
labels:
1922
{{- include "zot.selectorLabels" . | nindent 8 }}
2023
spec:
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
suite: configmap checksum in deployment
2+
# Can't use global templates in this test suite as it will break the checksum calculation
3+
# causing false negative test outcome.
4+
# templates:
5+
# - deployment.yaml
6+
tests:
7+
- it: has no checksum/config if no config
8+
template: deployment.yaml
9+
asserts:
10+
- isNull:
11+
path: spec.template.metadata.annotations.checksum/config
12+
- it: generate checksum/config if config is present
13+
template: deployment.yaml
14+
set:
15+
mountConfig: true
16+
configFiles:
17+
config.json: "{}"
18+
asserts:
19+
- isNotNull:
20+
path: spec.template.metadata.annotations.checksum/config
21+
- matchRegex:
22+
path: spec.template.metadata.annotations.checksum/config
23+
pattern: "^[a-f0-9]{64}$" # SHA256 hex output

charts/zot/values.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,3 +171,5 @@ extraVolumeMounts: []
171171
extraVolumes: []
172172
# - name: data
173173
# emptyDir: {}
174+
175+
podAnnotations: {}

0 commit comments

Comments
 (0)