Skip to content

Commit e176fee

Browse files
author
Barkha Choithani
committed
updated code to resolve scaling issue
1 parent f5de37d commit e176fee

File tree

3 files changed

+24
-39
lines changed

3 files changed

+24
-39
lines changed

charts/templates/configmap.yaml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,11 @@ metadata:
66
labels:
77
{{- include "marklogic.labels" . | nindent 4 }}
88
data:
9-
{{- if ne .Values.bootstrapClusterName "" }}
10-
MARKLOGIC_BOOTSTRAP_HOST: {{ .Values.bootstrapClusterName }}
11-
MARKLOGIC_JOIN_CLUSTER: "true"
9+
{{- if ne .Values.bootstrapHostName "" }}
10+
MARKLOGIC_BOOTSTRAP_HOST: {{ .Values.bootstrapHostName }}
1211
{{- else }}
1312
MARKLOGIC_BOOTSTRAP_HOST: {{ include "marklogic.fullname" . }}-0
14-
MARKLOGIC_JOIN_CLUSTER: "false"
1513
{{- end }}
1614
MARKLOGIC_FQDN_SUFFIX: {{ include "marklogic.headlessURL" . }}
1715
MARKLOGIC_INIT: "true"
16+
MARKLOGIC_JOIN_CLUSTER: "true"

charts/templates/statefulset.yaml

Lines changed: 21 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,52 @@
11
apiVersion: apps/v1
22
kind: StatefulSet
33
metadata:
4-
name: {{ include "marklogic.fullname" . }}-{{ .Values.group.name}}
4+
name: {{ include "marklogic.fullname" . }}
55
namespace: {{ .Release.Namespace }}
66
labels:
7-
app.kubernetes.io/component: marklogic-{{ .Values.group.name}}
87
{{- include "marklogic.labels" . | nindent 4 }}
98
spec:
109
serviceName: {{ include "marklogic.headlessServiceName" . }}
1110
replicas: {{ .Values.replicaCount }}
1211
selector:
1312
matchLabels:
1413
{{- include "marklogic.selectorLabels" . | nindent 6 }}
15-
app.kubernetes.io/component: marklogic-{{ .Values.group.name}}
1614
template:
1715
metadata:
1816
labels:
1917
{{- include "marklogic.selectorLabels" . | nindent 8 }}
20-
app.kubernetes.io/component: marklogic-{{ .Values.group.name}}
2118
spec:
2219
serviceAccountName: {{ include "marklogic.serviceAccountName" . }}
2320
{{- with .Values.affinity }}
2421
affinity: {{- toYaml . | nindent 8}}
2522
{{- end }}
2623
terminationGracePeriodSeconds: {{ .Values.terminationGracePeriod }}
27-
{{- if and (ne .Values.bootstrapClusterName "") (eq .Values.bootstrapHostName "") }}
28-
initContainers:
29-
- name: init-checkGroup
24+
{{- if ne .Values.bootstrapHostName "" }}
25+
initContainers:
26+
- name: check-group-init-container
3027
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
3128
command:
3229
- bash
3330
- '-c'
3431
- |
35-
echo '### Begin init Container ###'
36-
37-
echo "BOOTSTRAP_CLUSTER_NAME: $BOOTSTRAP_CLUSTER_NAME"
38-
echo "MARKLOGIC_GROUP: $MARKLOGIC_GROUP"
32+
echo '### Begin init container ###'
3933
4034
GROUP_CFG_TEMPLATE='{"group-name":"%s"}'
4135
GROUP_CFG=$(printf "$GROUP_CFG_TEMPLATE" "$MARKLOGIC_GROUP")
4236
43-
echo "GROUP_CFG: $GROUP_CFG"
44-
45-
ML_GROUPS=`curl --anyauth -m 20 -s -X GET http://${BOOTSTRAP_CLUSTER_NAME}:8002/manage/v2/groups?format=json --anyauth --user ${MARKLOGIC_ADMIN_USERNAME}:${MARKLOGIC_ADMIN_PASSWORD} | jq '."group-default-list"."list-items"."list-item"'`;
46-
echo ML_GROUPS: $ML_GROUPS;
47-
if [[ $(jq <<< "${ML_GROUPS}" --arg MARKLOGIC_GROUP "$MARKLOGIC_GROUP" 'any(.nameref==$MARKLOGIC_GROUP)') == "true" ]]; then
48-
echo "Group is already configured."
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+
39+
if [[ ${GROUP_RESP_CODE} -eq 200 ]]; then
40+
echo "Group $MARKLOGIC_GROUP is already configured on the MarkLogic cluster."
4941
else
50-
echo $MARKLOGIC_GROUP does not exist, creating $MARKLOGIC_GROUP on ML cluster;
51-
resp=`curl --anyauth --user ${MARKLOGIC_ADMIN_USERNAME}:${MARKLOGIC_ADMIN_PASSWORD} -m 20 -s -X POST -d "${GROUP_CFG}" -H "Content-type: application/json" http://${BOOTSTRAP_CLUSTER_NAME}:8002/manage/v2/groups`;
42+
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
5244
sleep 20s
5345
fi
46+
echo '### init container execution completed ###'
5447
env:
55-
- name: "BOOTSTRAP_CLUSTER_NAME"
56-
value: {{ .Values.bootstrapClusterName }}
48+
- name: "BOOTSTRAP_HOST_NAME"
49+
value: {{ .Values.bootstrapHostName }}
5750
- name: MARKLOGIC_GROUP
5851
value: {{ .Values.group.name }}
5952
- name: MARKLOGIC_ADMIN_USERNAME
@@ -66,7 +59,7 @@ spec:
6659
secretKeyRef:
6760
name: {{ include "marklogic.fullname" . }}
6861
key: password
69-
{{- end }}
62+
{{- end }}
7063
containers:
7164
- name: marklogic-server
7265
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
@@ -93,8 +86,6 @@ spec:
9386
secretKeyRef:
9487
name: {{ include "marklogic.fullname" . }}
9588
key: password
96-
- name: "BOOTSTRAP_CLUSTER_NAME"
97-
value: {{ .Values.bootstrapClusterName }}
9889
- name: MARKLOGIC_GROUP
9990
value: {{ .Values.group.name }}
10091
envFrom:
@@ -117,7 +108,7 @@ spec:
117108
{{- toYaml .Values.extraContainerPorts | nindent 12 }}
118109
{{- end }}
119110
lifecycle:
120-
{{- if eq .Values.bootstrapClusterName "" }}
111+
{{- if eq .Values.bootstrapHostName "" }}
121112
postStart:
122113
exec:
123114
command:
@@ -131,20 +122,18 @@ spec:
131122
echo "${TIMESTAMP} $@" > /proc/$pid/fd/1
132123
}
133124
134-
log "Info: [poststart] Poststart Hook Execution"
135-
136125
while [ ! -f /var/opt/MarkLogic/ready ]; do
137-
sleep 5
126+
sleep 5s
138127
done
139-
140-
log "Info: [poststart] Updating Default group on cluster"
128+
log "Info: [poststart] Begin Poststart Hook Execution"
129+
141130
GROUP_CFG_TEMPLATE='{"group-name":"%s"}'
142131
GROUP_CFG=$(printf "$GROUP_CFG_TEMPLATE" "$MARKLOGIC_GROUP")
143-
132+
log "Info: [poststart] Updating Default group on cluster"
144133
AUTH_CURL="curl --anyauth --user "${MARKLOGIC_ADMIN_USERNAME}":"${MARKLOGIC_ADMIN_PASSWORD}" -m 20 -s "
145134
146135
$AUTH_CURL -X PUT -H "Content-type: application/json" -d "${GROUP_CFG}" http://localhost:8002/manage/v2/groups/Default/properties
147-
136+
sleep 10s
148137
log "Info: [poststart] Poststart Hook Execution Completed"
149138
{{- end }}
150139
preStop:

charts/values.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@ group:
1111
# the group name of the current Marklogic Helm Deployment
1212
name: Default
1313

14-
# The name of the cluster to join. If not provided, the deployment is a bootstrap cluster.
15-
bootstrapClusterName: ""
16-
1714
# The name of the host to join. If not provided, the deployment is a bootstrap host.
1815
bootstrapHostName: ""
1916

0 commit comments

Comments
 (0)