Skip to content

Commit badc490

Browse files
authored
Merge pull request #55 from WesselAtWork/feature/volumes
Additional Persistance Options
2 parents 785e5de + 275dd15 commit badc490

9 files changed

+150
-28
lines changed

charts/wiremock/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ 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.6.0
18+
version: 1.7.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

charts/wiremock/templates/_helpers.tpl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,16 +71,16 @@ Create the name of the service account to use
7171
Pod annotations
7272
*/}}
7373
{{- define "wiremock.podAnnotations" -}}
74-
{{- if .Values.mappingsAsConfigmap }}
74+
{{- if (or .Values.mappingsAsConfigmap .Values.mappingsFromConfigmap) }}
7575
checksum/configMappings: {{ include (print $.Template.BasePath "/configmap-mappings.yaml") . | sha256sum }}
7676
{{- end }}
77-
{{- if .Values.responsesAsConfigmap }}
77+
{{- if (or .Values.responsesAsConfigmap .Values.responsesFromConfigmap) }}
7878
checksum/configResponses: {{ include (print $.Template.BasePath "/configmap-responses.yaml") . | sha256sum }}
7979
{{- end }}
8080
{{- if .Values.podAnnotations }}
8181
{{ toYaml .Values.podAnnotations }}
8282
{{- end }}
83-
{{- end }}
83+
{{- end -}}
8484

8585
{{/*
8686
Additional Pod Labels

charts/wiremock/templates/configmap-mappings.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{{- if .Values.mappingsAsConfigmap -}}
1+
{{- if (or .Values.mappingsAsConfigmap .Values.mappingsFromConfigmap) -}}
22
apiVersion: v1
33
kind: ConfigMap
44
metadata:

charts/wiremock/templates/configmap-responses.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{{- if .Values.responsesAsConfigmap -}}
1+
{{- if (or .Values.responsesAsConfigmap .Values.responsesFromConfigmap) -}}
22
apiVersion: v1
33
kind: ConfigMap
44
metadata:

charts/wiremock/templates/deployment.yaml

Lines changed: 38 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,20 @@ spec:
88
{{- if not .Values.autoscaling.enabled }}
99
replicas: {{ .Values.replicaCount }}
1010
{{- end }}
11+
revisionHistoryLimit: {{ .Values.revisionHistoryLimit | int }}
1112
selector:
1213
matchLabels:
1314
{{- include "wiremock.selectorLabels" . | nindent 6 }}
15+
{{- with .Values.deploymentStrategy }}
16+
strategy:
17+
{{- toYaml . | nindent 4 }}
18+
{{- end }}
1419
template:
1520
metadata:
21+
{{- with (include "wiremock.podAnnotations" .) }}
1622
annotations:
17-
{{- include "wiremock.podAnnotations" . | nindent 8 }}
23+
{{- . | nindent 8 }}
24+
{{- end }}
1825
labels:
1926
{{- include "wiremock.podLabels" . | nindent 8 }}
2027
spec:
@@ -57,43 +64,49 @@ spec:
5764
resources:
5865
{{- toYaml .Values.resources | nindent 12 }}
5966
volumeMounts:
60-
{{- if .Values.mappingsAsConfigmap }}
67+
{{- if (or .Values.mappingsAsConfigmap .Values.mappingsFromConfigmap .Values.persistence.mappings.enabled) }}
6168
- mountPath: /home/wiremock/storage/mappings
6269
name: mappings-data
6370
{{- end }}
64-
{{- if .Values.responsesAsConfigmap }}
71+
{{- if (or .Values.responsesAsConfigmap .Values.responsesFromConfigmap .Values.persistence.responses.enabled) }}
6572
- mountPath: /home/wiremock/storage/__files
6673
name: responses-data
6774
{{- end }}
6875
{{- with .Values.extraVolumeMounts }}
69-
{{- toYaml . | nindent 12 }}
76+
{{- toYaml . | nindent 12 }}
7077
{{- end }}
7178
initContainers:
72-
{{- if .Values.mappingsAsConfigmap }}
79+
{{- if (or .Values.mappingsAsConfigmap .Values.mappingsFromConfigmap) }}
7380
- name: copy-mappings
7481
securityContext:
7582
{{- toYaml .Values.securityContext | nindent 12 }}
7683
image: "{{ .Values.initContainer.image.repository }}:{{ .Values.initContainer.image.tag }}"
7784
imagePullPolicy: {{ .Values.initContainer.image.pullPolicy }}
78-
command: ["bash", "-c", "cp -rf /data/mappings /home/wiremock/storage/mappings"]
85+
command: ["bash", "-c", "cp -rfv /data/mappings /home/wiremock/storage/mappings"]
7986
volumeMounts:
8087
- mountPath: /data/mappings
8188
name: mappings-volume
8289
- mountPath: /home/wiremock/storage/mappings
8390
name: mappings-data
91+
{{- with .Values.initContainer.extraVolumeMounts }}
92+
{{- toYaml . | nindent 12 }}
93+
{{- end }}
8494
{{- end }}
85-
{{- if .Values.responsesAsConfigmap }}
95+
{{- if (or .Values.responsesAsConfigmap .Values.responsesFromConfigmap) }}
8696
- name: copy-responses
8797
securityContext:
8898
{{- toYaml .Values.securityContext | nindent 12 }}
8999
image: "{{ .Values.initContainer.image.repository }}:{{ .Values.initContainer.image.tag }}"
90100
imagePullPolicy: {{ .Values.initContainer.image.pullPolicy }}
91-
command: ["bash", "-c", "cp -rf /data/responses /home/wiremock/storage/__files"]
101+
command: ["bash", "-c", "cp -rfv /data/responses /home/wiremock/storage/__files"]
92102
volumeMounts:
93103
- mountPath: /data/responses
94104
name: responses-volume
95105
- mountPath: /home/wiremock/storage/__files
96106
name: responses-data
107+
{{- with .Values.initContainer.extraVolumeMounts }}
108+
{{- toYaml . | nindent 12 }}
109+
{{- end }}
97110
{{- end }}
98111
{{- with .Values.extraInitContainers }}
99112
{{- toYaml . | nindent 8 }}
@@ -111,20 +124,34 @@ spec:
111124
{{- tpl (toYaml .) $ | nindent 8 }}
112125
{{- end }}
113126
volumes:
114-
{{- if .Values.mappingsAsConfigmap }}
127+
{{- if (or .Values.mappingsAsConfigmap .Values.mappingsFromConfigmap .Values.persistence.mappings.enabled) }}
115128
- name: mappings-data
129+
{{- if .Values.persistence.mappings.enabled }}
130+
persistentVolumeClaim:
131+
claimName: {{ include "wiremock.fullname" . }}-mappings-data
132+
{{- else }}
116133
emptyDir: {}
134+
{{- end }}
135+
{{- end }}
136+
{{- if (or .Values.mappingsAsConfigmap .Values.mappingsFromConfigmap) }}
117137
- name: mappings-volume
118138
configMap:
119139
name: {{ include "wiremock.fullname" . }}-mappings-configs
120140
{{- end }}
121-
{{- if .Values.responsesAsConfigmap }}
141+
{{- if (or .Values.responsesAsConfigmap .Values.responsesFromConfigmap .Values.persistence.responses.enabled) }}
122142
- name: responses-data
143+
{{- if .Values.persistence.responses.enabled }}
144+
persistentVolumeClaim:
145+
claimName: {{ include "wiremock.fullname" . }}-responses-data
146+
{{- else }}
123147
emptyDir: {}
148+
{{- end }}
149+
{{- end }}
150+
{{- if (or .Values.responsesAsConfigmap .Values.responsesFromConfigmap) }}
124151
- name: responses-volume
125152
configMap:
126153
name: {{ include "wiremock.fullname" . }}-responses-configs
127154
{{- end }}
128155
{{- with .Values.extraVolumes }}
129-
{{- toYaml . | nindent 8 }}
156+
{{- toYaml . | nindent 8 }}
130157
{{- end }}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{{ range .Values.extraObjects }}
2+
---
3+
{{- if typeIs "string" . }}
4+
{{ tpl . $ }}
5+
{{ else }}
6+
{{ tpl (. | toYaml) $ }}
7+
{{- end }}
8+
{{ end }}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{{- if .Values.persistence.mappings.enabled }}
2+
{{- /* https://kubernetes.io/docs/concepts/storage/persistent-volumes/#writing-portable-configuration */}}
3+
apiVersion: v1
4+
kind: PersistentVolumeClaim
5+
metadata:
6+
name: {{ include "wiremock.fullname" . }}-mappings-data
7+
labels:
8+
{{- include "wiremock.labels" . | nindent 4 }}
9+
spec:
10+
{{- with .Values.persistence.mappings.accessModes }}
11+
accessModes: {{ . | toYaml | nindent 2 }}
12+
{{- end }}
13+
{{- /* https://kubernetes.io/docs/concepts/storage/persistent-volumes/#class-1 */}}
14+
{{- with .Values.persistence.mappings.storageClassName }}
15+
storageClassName: {{ ternary "" . (eq `-` .) | quote }}
16+
{{- end }}
17+
resources:
18+
requests:
19+
storage: "{{ .Values.persistence.mappings.size }}"
20+
{{- end }}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{{- if .Values.persistence.responses.enabled }}
2+
{{- /* https://kubernetes.io/docs/concepts/storage/persistent-volumes/#writing-portable-configuration */}}
3+
apiVersion: v1
4+
kind: PersistentVolumeClaim
5+
metadata:
6+
name: {{ include "wiremock.fullname" . }}-responses-data
7+
labels:
8+
{{- include "wiremock.labels" . | nindent 4 }}
9+
spec:
10+
{{- with .Values.persistence.responses.accessModes }}
11+
accessModes: {{ . | toYaml | nindent 2 }}
12+
{{- end }}
13+
{{- /* https://kubernetes.io/docs/concepts/storage/persistent-volumes/#class-1 */}}
14+
{{- with .Values.persistence.responses.storageClassName }}
15+
storageClassName: {{ ternary "" . (eq `-` .) | quote }}
16+
{{- end }}
17+
resources:
18+
requests:
19+
storage: "{{ .Values.persistence.responses.size }}"
20+
{{- end }}

charts/wiremock/values.yaml

Lines changed: 58 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ responses: {}
2626

2727
replicaCount: 1
2828

29+
revisionHistoryLimit: 10
30+
2931
image:
3032
repository: wiremock/wiremock
3133
# Overrides the image tag whose default is the chart appVersion.
@@ -37,9 +39,35 @@ initContainer:
3739
repository: bash
3840
tag: 5
3941
pullPolicy: Always
42+
extraVolumeMounts: {}
4043

4144
extraInitContainers: []
4245

46+
deploymentStrategy: {}
47+
# type: Recreate
48+
49+
# Load mappings from the templated configmap
50+
mappingsFromConfigmap: true
51+
52+
# Load mappings from the templated configmap
53+
responsesFromConfigmap: true
54+
55+
persistence:
56+
mappings:
57+
enabled: false
58+
accessModes: ["ReadWriteOnce"]
59+
size: 10Gi
60+
# storageClassName: "-"
61+
responses:
62+
enabled: false
63+
accessModes: ["ReadWriteOnce"]
64+
size: 10Gi
65+
# storageClassName: "-"
66+
67+
extraVolumes: {}
68+
69+
extraVolumeMounts: {}
70+
4371
imagePullSecrets: []
4472
nameOverride: ""
4573
fullnameOverride: ""
@@ -54,7 +82,6 @@ serviceAccount:
5482
name: ""
5583

5684
labels: {}
57-
5885
podLabels: {}
5986
podAnnotations: {}
6087

@@ -106,16 +133,6 @@ args:
106133
- "--local-response-templating"
107134
- "--root-dir=/home/wiremock/storage"
108135

109-
# Disable this if you mount your own mappings using extraVolumeMounts
110-
mappingsAsConfigmap: true
111-
112-
# Disable this if you mount your own responses using extraVolumeMounts
113-
responsesAsConfigmap: true
114-
115-
extraVolumeMounts: []
116-
117-
extraVolumes: []
118-
119136
resources: {}
120137
# We usually recommend not to specify default resources and to leave this as a conscious
121138
# choice for the user. This also increases chances charts run on environments with little
@@ -142,3 +159,33 @@ tolerations: []
142159
affinity: {}
143160

144161
scheme: "HTTP"
162+
163+
# extraObjects could be utilized to add dynamic manifests via values
164+
extraObjects: []
165+
# Examples:
166+
# extraObjects:
167+
# - apiVersion: kubernetes-client.io/v1
168+
# kind: ExternalSecret
169+
# metadata:
170+
# name: wiremock-config-{{ .Release.Name }}
171+
# spec:
172+
# backendType: gcpSecretsManager
173+
# data:
174+
# - remoteRef:
175+
# key: wiremock-config
176+
# property: config.json
177+
# secretKey: wiremock-config-gcp
178+
# Alternatively, you can use strings, which lets you use additional templating features:
179+
# extraObjects:
180+
# - |
181+
# apiVersion: kubernetes-client.io/v1
182+
# kind: ExternalSecret
183+
# metadata:
184+
# name: wiremock-config-{{ .Release.Name }}
185+
# spec:
186+
# backendType: gcpSecretsManager
187+
# data:
188+
# - remoteRef:
189+
# key: wiremock-config
190+
# property: config.json
191+
# secretKey: {{ include "some-other-template" }}

0 commit comments

Comments
 (0)