@@ -8,6 +8,8 @@ metadata:
8
8
spec :
9
9
serviceName : {{ include "marklogic.headlessServiceName" . }}
10
10
replicas : {{ .Values.replicaCount }}
11
+ updateStrategy :
12
+ type : {{ .Values.updateStrategy.type }}
11
13
selector :
12
14
matchLabels :
13
15
{{- include "marklogic.selectorLabels" . | nindent 6 }}
@@ -25,10 +27,16 @@ spec:
25
27
initContainers :
26
28
- name : configure-group
27
29
image : " {{ .Values.initContainerImage.repository }}:{{ .Values.initContainerImage.tag }}"
30
+ volumeMounts :
31
+ - name : admin-creds
32
+ mountPath : " /run/secrets/creds"
33
+ readOnly : false
28
34
command :
29
35
- sh
30
36
- ' -c'
31
37
- |
38
+ MARKLOGIC_ADMIN_USERNAME="$(< /run/secrets/creds/username)"
39
+ MARKLOGIC_ADMIN_PASSWORD="$(< /run/secrets/creds/password)"
32
40
log () {
33
41
local TIMESTAMP=$(date +"%Y-%m-%d %T.%3N")
34
42
echo "${TIMESTAMP} $@"
@@ -67,16 +75,10 @@ spec:
67
75
exit 1
68
76
fi
69
77
env :
70
- - name : MARKLOGIC_ADMIN_USERNAME
71
- valueFrom :
72
- secretKeyRef :
73
- name : {{ include "marklogic.fullname" . }}-admin
74
- key : username
75
- - name : MARKLOGIC_ADMIN_PASSWORD
76
- valueFrom :
77
- secretKeyRef :
78
- name : {{ include "marklogic.fullname" . }}-admin
79
- key : password
78
+ - name : MARKLOGIC_ADMIN_USERNAME_FILE
79
+ value : " creds/username"
80
+ - name : MARKLOGIC_ADMIN_PASSWORD_FILE
81
+ value : " creds/password"
80
82
- name : POD_NAME
81
83
valueFrom :
82
84
fieldRef :
@@ -90,22 +92,19 @@ spec:
90
92
image : " {{ .Values.image.repository }}:{{ .Values.image.tag }}"
91
93
imagePullPolicy : {{ .Values.image.pullPolicy}}
92
94
volumeMounts :
95
+ - name : admin-creds
96
+ mountPath : " /run/secrets/creds"
97
+ readOnly : false
93
98
- name : datadir
94
99
mountPath : {{ .Values.persistence.mountPath }}
95
100
{{- if .Values.extraVolumeMounts }}
96
101
{{- toYaml .Values.extraVolumeMounts | nindent 12 }}
97
102
{{- end }}
98
103
env :
99
- - name : MARKLOGIC_ADMIN_USERNAME
100
- valueFrom :
101
- secretKeyRef :
102
- name : {{ include "marklogic.fullname" . }}-admin
103
- key : username
104
- - name : MARKLOGIC_ADMIN_PASSWORD
105
- valueFrom :
106
- secretKeyRef :
107
- name : {{ include "marklogic.fullname" . }}-admin
108
- key : password
104
+ - name : MARKLOGIC_ADMIN_USERNAME_FILE
105
+ value : " creds/username"
106
+ - name : MARKLOGIC_ADMIN_PASSWORD_FILE
107
+ value : " creds/password"
109
108
- name : POD_NAME
110
109
valueFrom :
111
110
fieldRef :
@@ -137,75 +136,89 @@ spec:
137
136
- bash
138
137
- ' -c'
139
138
- |
140
- pid=$(ps aux | grep -i '/bin/bas[h] /usr' | awk {'print $2'})
139
+ MARKLOGIC_ADMIN_USERNAME="$(< /run/secrets/creds/username)"
140
+ MARKLOGIC_ADMIN_PASSWORD="$(< /run/secrets/creds/password)"
141
141
142
- log () {
143
- local TIMESTAMP=$(date +"%Y-%m-%d %T.%3N")
144
- echo "${TIMESTAMP} $@" > /proc/$pid/fd/1
145
- }
146
- log "Info: [poststart] Begin Poststart Hook Execution"
147
- if [[ $POD_NAME != *-0 ]]; then
148
- log "Info: [poststart] Skipping group configuration."
149
- else
150
- while [ ! -f /var/opt/MarkLogic/ready ]; do
151
- log "[poststart] wait for marklogic server to be ready"
152
- sleep 5s
153
- done
154
- sleep 10s
155
- GROUP_CFG_TEMPLATE='{"group-name":"%s", "xdqp-ssl-enabled":"%s"}'
156
- GROUP_CFG=$(printf "$GROUP_CFG_TEMPLATE" "$MARKLOGIC_GROUP" "$XDQP_SSL_ENABLED")
157
- log "Info: [poststart] Updating group configuration: ${GROUP_CFG}"
158
- curl --anyauth -m 20 -X PUT -H "Content-type: application/json" -d "${GROUP_CFG}" http://${MARKLOGIC_BOOTSTRAP_HOST}:8002/manage/v2/groups/Default/properties --user ${MARKLOGIC_ADMIN_USERNAME}:${MARKLOGIC_ADMIN_PASSWORD}
159
- sleep 2s
160
- fi
161
- log "Info: [poststart] Poststart Hook Execution Completed"
142
+ pid=$(pgrep start.marklogic)
143
+
144
+ log () {
145
+ local TIMESTAMP=$(date +"%Y-%m-%d %T.%3N")
146
+ # Check to make sure pod doesn't terminate if PID value is empty for any reason
147
+ # If PID value is empty postStart hook logs are not recorded
148
+ if [ -n "$pid" ]; then
149
+ echo "${TIMESTAMP} $@" > /proc/$pid/fd/1
150
+ fi
151
+ }
152
+ log "Info: [poststart] Begin Poststart Hook Execution"
153
+ if [[ $POD_NAME != *-0 ]]; then
154
+ log "Info: [poststart] Skipping group configuration."
155
+ else
156
+ while [ ! -f /var/opt/MarkLogic/ready ]; do
157
+ log "[poststart] wait for marklogic server to be ready"
158
+ sleep 5s
159
+ done
160
+ sleep 10s
161
+ GROUP_CFG_TEMPLATE='{"group-name":"%s", "xdqp-ssl-enabled":"%s"}'
162
+ GROUP_CFG=$(printf "$GROUP_CFG_TEMPLATE" "$MARKLOGIC_GROUP" "$XDQP_SSL_ENABLED")
163
+ log "Info: [poststart] Updating group configuration: ${GROUP_CFG}"
164
+ curl --anyauth -m 20 -X PUT -H "Content-type: application/json" -d "${GROUP_CFG}" http://${MARKLOGIC_BOOTSTRAP_HOST}:8002/manage/v2/groups/Default/properties --user ${MARKLOGIC_ADMIN_USERNAME}:${MARKLOGIC_ADMIN_PASSWORD}
165
+ sleep 2s
166
+ fi
167
+ log "Info: [poststart] Poststart Hook Execution Completed"
162
168
{{- end }}
163
169
preStop :
164
170
exec :
165
171
command :
166
172
- bash
167
173
- ' -c'
168
174
- |
169
- log () {
170
- local TIMESTAMP=$(date +"%Y-%m-%d %T.%3N")
171
- echo "${TIMESTAMP} $@" > /proc/$pid/fd/1
172
- }
175
+ MARKLOGIC_ADMIN_USERNAME="$(< /run/secrets/creds/username)"
176
+ MARKLOGIC_ADMIN_PASSWORD="$(< /run/secrets/creds/password)"
173
177
174
- pid=$(ps aux | grep -i '/bin/bas[h] /usr' | awk {'print $2'})
175
- log "Info: [prestop] Prestop Hook Execution"
178
+ log () {
179
+ local TIMESTAMP=$(date +"%Y-%m-%d %T.%3N")
180
+ # Check to make sure pod doesn't terminate if PID value is empty for any reason
181
+ # If PID value is empty preStart hook logs are not recorded
182
+ if [ -n "$pid" ]; then
183
+ echo "${TIMESTAMP} $@" > /proc/$pid/fd/1
184
+ fi
185
+ }
176
186
177
- my_host=$(hostname -f)
187
+ pid=$(pgrep start.marklogic)
188
+ log "Info: [prestop] Prestop Hook Execution"
178
189
179
- log "Info: [prestop] MarkLogic Pod Hostname: "$ my_host
190
+ my_host=$(hostname -f)
180
191
181
- for ((i = 0; i < 5; i = i + 1)); do
182
- res_code=$(curl --anyauth --user $MARKLOGIC_ADMIN_USERNAME:$MARKLOGIC_ADMIN_PASSWORD \
183
- -o /dev/null -m 10 -s -w %{http_code} \
184
- -i -X POST --data "state=shutdown&failover=true" \
185
- -H "Content-type: application/x-www-form-urlencoded" \
186
- http://localhost:8002/manage/v2/hosts/$my_host?format=json)
192
+ log "Info: [prestop] MarkLogic Pod Hostname: "$my_host
187
193
188
- if [[ ${res_code} -eq 202 ]]; then
189
- log "Info: [prestop] Host shut down response code: "$res_code
194
+ for ((i = 0; i < 5; i = i + 1)); do
195
+ res_code=$(curl --anyauth --user $MARKLOGIC_ADMIN_USERNAME:$MARKLOGIC_ADMIN_PASSWORD \
196
+ -o /dev/null -m 10 -s -w %{http_code} \
197
+ -i -X POST --data "state=shutdown&failover=true" \
198
+ -H "Content-type: application/x-www-form-urlencoded" \
199
+ http://localhost:8002/manage/v2/hosts/$my_host?format=json)
190
200
191
- while (true)
192
- do
193
- ml_status=$(service MarkLogic status)
194
- log "Info: [prestop] MarkLogic Status: "$ml_status
195
- if [[ "$ml_status" =~ "running" ]]; then
196
- sleep 5s
197
- continue
198
- else
199
- break
200
- fi
201
- done
202
- break
203
- else
204
- log "ERROR: [prestop] Retry Attempt: "$i
205
- log "ERROR: [prestop] Host shut down expected response code 202, got "$res_code
206
- sleep 10s
207
- fi
208
- done
201
+ if [[ ${res_code} -eq 202 ]]; then
202
+ log "Info: [prestop] Host shut down response code: "$res_code
203
+
204
+ while (true)
205
+ do
206
+ ml_status=$(service MarkLogic status)
207
+ log "Info: [prestop] MarkLogic Status: "$ml_status
208
+ if [[ "$ml_status" =~ "running" ]]; then
209
+ sleep 5s
210
+ continue
211
+ else
212
+ break
213
+ fi
214
+ done
215
+ break
216
+ else
217
+ log "ERROR: [prestop] Retry Attempt: "$i
218
+ log "ERROR: [prestop] Host shut down expected response code 202, got "$res_code
219
+ sleep 10s
220
+ fi
221
+ done
209
222
{{- if .Values.containerSecurityContext.enabled }}
210
223
securityContext : {{- omit .Values.containerSecurityContext "enabled" | toYaml | nindent 12 }}
211
224
{{- end }}
@@ -274,7 +287,13 @@ spec:
274
287
imagePullSecrets :
275
288
- name : {{ include "marklogic.fullname" . }}-registry
276
289
{{- end }}
290
+ dnsConfig :
291
+ searches :
292
+ - {{ include "marklogic.headlessURL" . }}
277
293
volumes :
294
+ - name : admin-creds
295
+ secret :
296
+ secretName : {{ include "marklogic.fullname" . }}-admin
278
297
{{- if .Values.logCollection.enabled }}
279
298
- name : {{ include "marklogic.fullname" . }}-fb-config-map
280
299
configMap :
@@ -310,4 +329,4 @@ spec:
310
329
resources :
311
330
requests :
312
331
storage : {{ .Values.persistence.size }}
313
- {{- end }}
332
+ {{- end }}
0 commit comments