Skip to content

Commit 6dd7b5d

Browse files
author
Barkha Choithani
committed
fixes as per review comments
1 parent fea00c9 commit 6dd7b5d

File tree

3 files changed

+36
-29
lines changed

3 files changed

+36
-29
lines changed

charts/templates/secret.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,4 @@ metadata:
88
type: kubernetes.io/basic-auth
99
stringData:
1010
username: {{ .Values.auth.adminUsername}}
11-
password: {{ .Values.auth.adminPassword}}
12-
wallet-password: {{ .Values.auth.walletPassword}}
11+
password: {{ .Values.auth.adminPassword}}

charts/templates/statefulset.yaml

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -23,30 +23,28 @@ spec:
2323
terminationGracePeriodSeconds: {{ .Values.terminationGracePeriod }}
2424
{{- if ne .Values.bootstrapHostName "" }}
2525
initContainers:
26-
- name: check-group-init-container
27-
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
26+
- name: configure-group
27+
image: "{{ .Values.initContainerImage.repository }}:{{ .Values.initContainerImage.tag }}"
2828
command:
29-
- bash
29+
- sh
3030
- '-c'
3131
- |
32-
echo '### Begin init container ###'
32+
echo '### Begin configuring group ###'
3333
3434
GROUP_CFG_TEMPLATE='{"group-name":"%s"}'
3535
GROUP_CFG=$(printf "$GROUP_CFG_TEMPLATE" "$MARKLOGIC_GROUP")
3636
37-
GROUP_RESP_CODE=`curl --anyauth -m 20 -s -o /dev/null -w "%{http_code}" -X GET http://${BOOTSTRAP_HOST_NAME}:8002/manage/v2/groups/${MARKLOGIC_GROUP} --anyauth --user ${MARKLOGIC_ADMIN_USERNAME}:${MARKLOGIC_ADMIN_PASSWORD}`
38-
37+
GROUP_RESP_CODE=`curl --anyauth -m 20 -s -o /dev/null -w "%{http_code}" -X GET http://${MARKLOGIC_BOOTSTRAP_HOST}:8002/manage/v2/groups/${MARKLOGIC_GROUP} --anyauth --user ${MARKLOGIC_ADMIN_USERNAME}:${MARKLOGIC_ADMIN_PASSWORD}`
38+
3939
if [[ ${GROUP_RESP_CODE} -eq 200 ]]; then
4040
echo "Group $MARKLOGIC_GROUP is already configured on the MarkLogic cluster."
4141
else
4242
echo "Group $MARKLOGIC_GROUP does not exist, creating $MARKLOGIC_GROUP on the MarkLogic cluster"
43-
curl --anyauth --user ${MARKLOGIC_ADMIN_USERNAME}:${MARKLOGIC_ADMIN_PASSWORD} -m 20 -s -X POST -d "${GROUP_CFG}" -H "Content-type: application/json" http://${BOOTSTRAP_HOST_NAME}:8002/manage/v2/groups
43+
curl --anyauth --user ${MARKLOGIC_ADMIN_USERNAME}:${MARKLOGIC_ADMIN_PASSWORD} -m 20 -s -X POST -d "${GROUP_CFG}" -H "Content-type: application/json" http://${MARKLOGIC_BOOTSTRAP_HOST}:8002/manage/v2/groups
4444
sleep 20s
4545
fi
4646
echo '### init container execution completed ###'
4747
env:
48-
- name: "BOOTSTRAP_HOST_NAME"
49-
value: {{ .Values.bootstrapHostName }}
5048
- name: MARKLOGIC_GROUP
5149
value: {{ .Values.group.name }}
5250
- name: MARKLOGIC_ADMIN_USERNAME
@@ -59,6 +57,9 @@ spec:
5957
secretKeyRef:
6058
name: {{ include "marklogic.fullname" . }}
6159
key: password
60+
envFrom:
61+
- configMapRef:
62+
name: {{ include "marklogic.fullname" . }}
6263
{{- end }}
6364
containers:
6465
- name: marklogic-server
@@ -81,13 +82,12 @@ spec:
8182
secretKeyRef:
8283
name: {{ include "marklogic.fullname" . }}
8384
key: password
84-
- name: MARKLOGIC_WALLET_PASSWORD
85-
valueFrom:
86-
secretKeyRef:
87-
name: {{ include "marklogic.fullname" . }}
88-
key: walletPassword
8985
- name: MARKLOGIC_GROUP
9086
value: {{ .Values.group.name }}
87+
- name: POD_NAME
88+
valueFrom:
89+
fieldRef:
90+
fieldPath: metadata.name
9191
envFrom:
9292
- configMapRef:
9393
name: {{ include "marklogic.fullname" . }}
@@ -121,19 +121,22 @@ spec:
121121
local TIMESTAMP=$(date +"%Y-%m-%d %T.%3N")
122122
echo "${TIMESTAMP} $@" > /proc/$pid/fd/1
123123
}
124-
125-
while [ ! -f /var/opt/MarkLogic/ready ]; do
126-
sleep 5s
127-
done
128124
log "Info: [poststart] Begin Poststart Hook Execution"
129-
130-
GROUP_CFG_TEMPLATE='{"group-name":"%s"}'
131-
GROUP_CFG=$(printf "$GROUP_CFG_TEMPLATE" "$MARKLOGIC_GROUP")
132-
log "Info: [poststart] Updating Default group on cluster"
133-
AUTH_CURL="curl --anyauth --user "${MARKLOGIC_ADMIN_USERNAME}":"${MARKLOGIC_ADMIN_PASSWORD}" -m 20 -s "
134-
135-
$AUTH_CURL -X PUT -H "Content-type: application/json" -d "${GROUP_CFG}" http://localhost:8002/manage/v2/groups/Default/properties
136-
sleep 10s
125+
if [[ $MARKLOGIC_GROUP == "Default" || $POD_NAME != *-0 ]]; then
126+
log "Info: [poststart] This is not a bootstrap host or group specified is Default"
127+
exit 1
128+
else
129+
while [ ! -f /var/opt/MarkLogic/ready ]; do
130+
sleep 5s
131+
done
132+
133+
GROUP_CFG_TEMPLATE='{"group-name":"%s"}'
134+
GROUP_CFG=$(printf "$GROUP_CFG_TEMPLATE" "$MARKLOGIC_GROUP")
135+
136+
log "Info: [poststart] Updating Default group on cluster"
137+
curl --anyauth -m 20 -s -X PUT -H "Content-type: application/json" -d "${GROUP_CFG}" http://localhost:8002/manage/v2/groups/Default/properties --user ${MARKLOGIC_ADMIN_USERNAME}:${MARKLOGIC_ADMIN_PASSWORD}
138+
sleep 10s
139+
fi
137140
log "Info: [poststart] Poststart Hook Execution Completed"
138141
{{- end }}
139142
preStop:

charts/values.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ image:
2121
tag: latest
2222
pullPolicy: IfNotPresent
2323

24+
# Init container image parameters
25+
initContainerImage:
26+
repository: curlimages/curl
27+
tag: latest
28+
pullPolicy: IfNotPresent
29+
2430
# Configure the imagePullSecret to pull the image from private repository that requires credential
2531
imagePullSecret: {}
2632
## docker hub registry: https://index.docker.io/v1/
@@ -45,7 +51,6 @@ fullnameOverride: ""
4551
auth:
4652
adminUsername: admin
4753
adminPassword: admin
48-
walletPassword: admin
4954

5055
# Configure Affinity property for scheduling pods to nodes
5156
# ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity

0 commit comments

Comments
 (0)