Skip to content

Commit 47ec860

Browse files
author
rwinieski
committed
change secret file location and fix indentation
1 parent 03bddac commit 47ec860

File tree

1 file changed

+78
-78
lines changed

1 file changed

+78
-78
lines changed

charts/templates/statefulset.yaml

Lines changed: 78 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@ spec:
2828
- name: configure-group
2929
image: "{{ .Values.initContainerImage.repository }}:{{ .Values.initContainerImage.tag }}"
3030
volumeMounts:
31-
- name: admin-creds
32-
mountPath: "/run/secrets/creds"
33-
readOnly: false
31+
- name: mladmin-secrets
32+
mountPath: /run/secrets/ml-secrets
33+
readOnly: true
3434
command:
3535
- sh
3636
- '-c'
3737
- |
38-
MARKLOGIC_ADMIN_USERNAME="$(< /run/secrets/creds/username)"
39-
MARKLOGIC_ADMIN_PASSWORD="$(< /run/secrets/creds/password)"
38+
MARKLOGIC_ADMIN_USERNAME="$(< /run/secrets/ml-secrets/username)"
39+
MARKLOGIC_ADMIN_PASSWORD="$(< /run/secrets/ml-secrets/password)"
4040
log () {
4141
local TIMESTAMP=$(date +"%Y-%m-%d %T.%3N")
4242
echo "${TIMESTAMP} $@"
@@ -76,9 +76,9 @@ spec:
7676
fi
7777
env:
7878
- name: MARKLOGIC_ADMIN_USERNAME_FILE
79-
value: "creds/username"
79+
value: "ml-secrets/username"
8080
- name: MARKLOGIC_ADMIN_PASSWORD_FILE
81-
value: "creds/password"
81+
value: "ml-secrets/password"
8282
- name: POD_NAME
8383
valueFrom:
8484
fieldRef:
@@ -92,8 +92,8 @@ spec:
9292
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
9393
imagePullPolicy: {{ .Values.image.pullPolicy}}
9494
volumeMounts:
95-
- name: admin-creds
96-
mountPath: "/run/secrets/creds"
95+
- name: mladmin-secrets
96+
mountPath: "/run/secrets/ml-secrets"
9797
readOnly: false
9898
- name: datadir
9999
mountPath: {{ .Values.persistence.mountPath }}
@@ -102,9 +102,9 @@ spec:
102102
{{- end }}
103103
env:
104104
- name: MARKLOGIC_ADMIN_USERNAME_FILE
105-
value: "creds/username"
105+
value: "ml-secrets/username"
106106
- name: MARKLOGIC_ADMIN_PASSWORD_FILE
107-
value: "creds/password"
107+
value: "ml-secrets/password"
108108
- name: POD_NAME
109109
valueFrom:
110110
fieldRef:
@@ -136,89 +136,89 @@ spec:
136136
- bash
137137
- '-c'
138138
- |
139-
MARKLOGIC_ADMIN_USERNAME="$(< /run/secrets/creds/username)"
140-
MARKLOGIC_ADMIN_PASSWORD="$(< /run/secrets/creds/password)"
139+
MARKLOGIC_ADMIN_USERNAME="$(< /run/secrets/ml-secrets/username)"
140+
MARKLOGIC_ADMIN_PASSWORD="$(< /run/secrets/ml-secrets/password)"
141141
142-
pid=$(pgrep start.marklogic)
142+
pid=$(pgrep start.marklogic)
143143
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
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
166150
fi
167-
log "Info: [poststart] Poststart Hook Execution Completed"
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"
168168
{{- end }}
169169
preStop:
170170
exec:
171171
command:
172172
- bash
173173
- '-c'
174174
- |
175-
MARKLOGIC_ADMIN_USERNAME="$(< /run/secrets/creds/username)"
176-
MARKLOGIC_ADMIN_PASSWORD="$(< /run/secrets/creds/password)"
175+
MARKLOGIC_ADMIN_USERNAME="$(< /run/secrets/ml-secrets/username)"
176+
MARKLOGIC_ADMIN_PASSWORD="$(< /run/secrets/ml-secrets/password)"
177177
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-
}
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+
}
186186
187-
pid=$(pgrep start.marklogic)
188-
log "Info: [prestop] Prestop Hook Execution"
187+
pid=$(pgrep start.marklogic)
188+
log "Info: [prestop] Prestop Hook Execution"
189189
190-
my_host=$(hostname -f)
190+
my_host=$(hostname -f)
191191
192-
log "Info: [prestop] MarkLogic Pod Hostname: "$my_host
192+
log "Info: [prestop] MarkLogic Pod Hostname: "$my_host
193193
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)
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)
200200
201-
if [[ ${res_code} -eq 202 ]]; then
202-
log "Info: [prestop] Host shut down response code: "$res_code
201+
if [[ ${res_code} -eq 202 ]]; then
202+
log "Info: [prestop] Host shut down response code: "$res_code
203203
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
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
222222
{{- if .Values.containerSecurityContext.enabled }}
223223
securityContext: {{- omit .Values.containerSecurityContext "enabled" | toYaml | nindent 12 }}
224224
{{- end }}
@@ -291,7 +291,7 @@ spec:
291291
searches:
292292
- {{ include "marklogic.headlessURL" . }}
293293
volumes:
294-
- name: admin-creds
294+
- name: mladmin-secrets
295295
secret:
296296
secretName: {{ include "marklogic.fullname" . }}-admin
297297
{{- if .Values.logCollection.enabled }}

0 commit comments

Comments
 (0)