Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: {{ include "wordpress.fullname" . }}
labels:
app: {{ include "wordpress.name" . }}
release: {{ .Release.Name }}
spec:
selector:
matchLabels:
app: {{ include "wordpress.name" . }}
release: {{ .Release.Name }}
serviceName: {{ include "wordpress.fullname" . }}
replicas: 1
template:
metadata:
labels:
app: {{ include "wordpress.name" . }}
release: {{ .Release.Name }}
annotations:
# Reload the pod when values-local.yaml changes, so the ansible playbook
# gets re-run.
checksum/config: {{ include (print $.Template.BasePath "/ansible-vars.yaml") . | sha256sum }}
checksum/config: {{ include (print $.Template.BasePath "/secrets.yaml") . | sha256sum }}
{{- if .Values.podAnnotations }}
{{- toYaml .Values.podAnnotations | nindent 8 }}
{{- end }}
spec:
imagePullSecrets:
- name: {{ .Values.initImage.imagePullSecretName }}
initContainers:
- name: init-{{ .Chart.Name }}
image: "{{ .Values.initImage.repository }}:{{ .Values.initImage.tag }}"
imagePullPolicy: {{ .Values.initImage.pullPolicy }}
# command: ['sh', '-c', '/usr/local/bin/wp --info > /var/www/html/wp-info.txt & echo "sleeping now" && sleep 600']
# The WP Apache container runs Debian, which has a different UID for
# the www-data user than this Alpine container, so use that ID instead
securityContext:
runAsUser: 33
runAsGroup: 33
volumeMounts:
- name: {{ include "wordpress.name" . }}-wp-storage
mountPath: /var/www/html
- name: {{ include "wordpress.name" . }}-wp-content
mountPath: {{ .Values.wordpress.wp_content.mount_path }}
- name: ansible-vars
mountPath: /var/local/ansible/roles/wordpress-init/defaults/main.yml
subPath: main.yml
- name: ansible-secrets
mountPath: /var/local/ansible/secrets
env:
- name: WORDPRESS_DB_HOST
value: {{ .Release.Name }}-database
- name: WORDPRESS_DB_USER
value: {{ .Values.database.db.user }}
- name: WORDPRESS_DB_PASSWORD
valueFrom:
secretKeyRef:
name: {{ .Release.Name }}-database
key: mariadb-password
- name: WORDPRESS_DB_NAME
value: {{ .Values.database.db.name }}
- name: WORDPRESS_TABLE_PREFIX
value: {{ .Values.wordPressTablePrefix }}
# TODO: Remove this debug
- name: WORDPRESS_DEBUG
value: "true"
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http
containerPort: 80
- name: https
containerPort: 443
{{- if .Values.livenessProbe.enabled }}
livenessProbe:
httpGet:
path: {{ .Values.wordpress.site.probe_path }}
port: http
initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.livenessProbe.periodSeconds }}
timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }}
successThreshold: {{ .Values.livenessProbe.successThreshold }}
failureThreshold: {{ .Values.livenessProbe.failureThreshold }}
{{- end }}
{{- if .Values.readinessProbe.enabled }}
readinessProbe:
httpGet:
path: {{ .Values.wordpress.site.probe_path }}
port: http
initialDelaySeconds: {{ .Values.readinessProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.readinessProbe.periodSeconds }}
timeoutSeconds: {{ .Values.readinessProbe.timeoutSeconds }}
successThreshold: {{ .Values.readinessProbe.successThreshold }}
failureThreshold: {{ .Values.readinessProbe.failureThreshold }}
{{- end }}
env:
- name: WORDPRESS_DB_HOST
value: {{ .Release.Name }}-database
- name: WORDPRESS_DB_USER
value: {{ .Values.database.db.user }}
- name: WORDPRESS_DB_PASSWORD
valueFrom:
secretKeyRef:
name: {{ .Release.Name }}-database
key: mariadb-password
- name: WORDPRESS_DB_NAME
value: {{ .Values.database.db.name }}
- name: WORDPRESS_TABLE_PREFIX
value: {{ .Values.wordPressTablePrefix }}
# TODO: Remove this debug
- name: WORDPRESS_DEBUG
value: "true"
# readinessProbe:
# httpGet:
# path: /
# port: apache
volumeMounts:
- name: {{ include "wordpress.name" . }}-wp-storage
mountPath: /var/www/html
- name: {{ include "wordpress.name" . }}-wp-content
mountPath: {{ .Values.wordpress.wp_content.mount_path }}
- name: {{ include "wordpress.name" . }}-wp-uploads
mountPath: {{ .Values.wordpress.wp_upload.mount_path }}
- name: htuploads
mountPath: {{ .Values.wordpress.wp_upload.mount_path }}/.htaccess
subPath: .htaccess
resources:
{{ toYaml .Values.resources | indent 12 }}
{{- if .Values.backup.enabled }}
- name: {{ .Chart.Name }}-backup
image: "{{ .Values.initImage.repository }}:{{ .Values.initImage.tag }}"
imagePullPolicy: {{ .Values.initImage.pullPolicy }}
command:
- "/var/local/ansible/scripts/backup.sh"
securityContext:
runAsUser: 33
runAsGroup: 33
env:
- name: WORDPRESS_DB_HOST
value: {{ .Release.Name }}-database
- name: WORDPRESS_DB_USER
value: {{ .Values.database.db.user }}
- name: WORDPRESS_DB_PASSWORD
valueFrom:
secretKeyRef:
name: {{ .Release.Name }}-database
key: mariadb-password
- name: WORDPRESS_DB_NAME
value: {{ .Values.database.db.name }}
- name: WORDPRESS_TABLE_PREFIX
value: {{ .Values.wordPressTablePrefix }}
- name: BACKUP_NAME
value: {{ .Release.Name }}
volumeMounts:
- name: {{ include "wordpress.name" . }}-wp-storage
mountPath: /var/www/html
- name: {{ include "wordpress.name" . }}-wp-content
mountPath: {{ .Values.wordpress.wp_content.mount_path }}
- name: {{ include "wordpress.name" . }}-wp-uploads
mountPath: {{ .Values.wordpress.wp_upload.mount_path }}
- name: ansible-vars
mountPath: /var/local/ansible/roles/wordpress-backup/defaults/main.yml
subPath: main.yml
- name: ansible-secrets
mountPath: /var/local/ansible/secrets
- name: {{ include "wordpress.name" . }}-backups
mountPath: /mnt/backups
{{- end }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{ toYaml . | indent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{ toYaml . | indent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{ toYaml . | indent 8 }}
{{- end }}
volumes:
- name: {{ include "wordpress.name" . }}-wp-storage
emptyDir: {}
- name: {{ include "wordpress.name" . }}-wp-content
emptyDir: {}
- name: {{ include "wordpress.name" . }}-wp-uploads
{{- if .Values.persistence.enabled }}
persistentVolumeClaim:
claimName: {{ if .Values.persistence.existingClaim }}{{ .Values.persistence.existingClaim }}{{- else }}{{ template "wordpress.fullname" . }}-wp-uploads{{- end }}
{{- else }}
emptyDir: {}
{{- end }}
- name: ansible-secrets
secret:
secretName: {{ include "wordpress.fullname" . }}-ansible-secrets
# TODO: this might not be necessary
items:
- key: secret-vars.yaml
path: secret-vars.yaml
- name: ansible-vars
configMap:
name: {{ include "wordpress.fullname" . }}-ansible-vars
- name: htuploads
configMap:
name: {{ include "wordpress.fullname" . }}-htuploads
{{- if .Values.backup.enabled }}
- name: {{ include "wordpress.name" . }}-backups
persistentVolumeClaim:
claimName: {{ .Values.backup.pvcName }}
{{- end }}