Skip to content

Commit 596a389

Browse files
committed
Merge remote-tracking branch 'ml/develop' into feature/CLD-554
2 parents bd94cb0 + 7bbf774 commit 596a389

File tree

8 files changed

+198
-50
lines changed

8 files changed

+198
-50
lines changed

README.md

Lines changed: 123 additions & 28 deletions
Large diffs are not rendered by default.

charts/templates/statefulset.yaml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ spec:
2020
{{- with .Values.affinity }}
2121
affinity: {{- toYaml . | nindent 8}}
2222
{{- end }}
23+
terminationGracePeriodSeconds: {{ .Values.terminationGracePeriod }}
2324
containers:
2425
- name: marklogic-server
2526
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
@@ -60,6 +61,53 @@ spec:
6061
{{- if .Values.extraContainerPorts }}
6162
{{- toYaml .Values.extraContainerPorts | nindent 12 }}
6263
{{- end }}
64+
lifecycle:
65+
preStop:
66+
exec:
67+
command:
68+
- bash
69+
- '-c'
70+
- |
71+
log () {
72+
local TIMESTAMP=$(date +"%Y-%m-%d %T.%3N")
73+
echo "${TIMESTAMP} $@" > /proc/$pid/fd/1
74+
}
75+
76+
pid=$(ps aux | grep -i '/bin/bas[h] /usr' | awk {'print $2'})
77+
log "Info: [prestop] Prestop Hook Execution"
78+
79+
my_host=$(hostname -f)
80+
81+
log "Info: [prestop] MarkLogic Pod Hostname: "$my_host
82+
83+
for ((i = 0; i < 5; i = i + 1)); do
84+
res_code=$(curl --anyauth --user $MARKLOGIC_ADMIN_USERNAME:$MARKLOGIC_ADMIN_PASSWORD \
85+
-o /dev/null -m 10 -s -w %{http_code} \
86+
-i -X POST --data "state=shutdown&failover=true" \
87+
-H "Content-type: application/x-www-form-urlencoded" \
88+
http://localhost:8002/manage/v2/hosts/$my_host?format=json)
89+
90+
if [[ ${res_code} -eq 202 ]]; then
91+
log "Info: [prestop] Host shut down response code: "$res_code
92+
93+
while (true)
94+
do
95+
ml_status=$(service MarkLogic status)
96+
log "Info: [prestop] MarkLogic Status: "$ml_status
97+
if [[ "$ml_status" =~ "running" ]]; then
98+
sleep 5s
99+
continue
100+
else
101+
break
102+
fi
103+
done
104+
break
105+
else
106+
log "ERROR: [prestop] Retry Attempt: "$i
107+
log "ERROR: [prestop] Host shut down expected response code 202, got "$res_code
108+
sleep 10s
109+
fi
110+
done
63111
{{- if .Values.livenessProbe.enabled }}
64112
livenessProbe:
65113
httpGet:
@@ -114,6 +162,9 @@ spec:
114162
fieldRef:
115163
fieldPath: metadata.name
116164
{{- end }}
165+
{{- with .Values.nodeSelector }}
166+
nodeSelector: {{- toYaml . | nindent 8}}
167+
{{- end }}
117168
dnsConfig:
118169
searches:
119170
- {{ include "marklogic.headlessURL" . }}

charts/values.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
# Number of Marklogic nodes
44
replicaCount: 1
55

6+
# Termination Grace Period
7+
terminationGracePeriod: 120
8+
69
# Marklogic image parameters
710
image:
811
repository: marklogic-centos/marklogic-server-centos
@@ -38,6 +41,10 @@ auth:
3841
# ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity
3942
affinity: {}
4043

44+
# Configure NodeSelector property for scheduling pods to nodes
45+
# ref: https://kubernetes.io/docs/tasks/configure-pod-container/assign-pods-nodes/#create-a-pod-that-gets-scheduled-to-your-chosen-node
46+
nodeSelector: {}
47+
4148
# Configure persistence using persistent Volume Claim
4249
# ref: https://kubernetes.io/docs/concepts/storage/persistent-volumes/#persistentvolumeclaims
4350
# The "" storageClass will use the default storage class for your cluster. (gp2 for EKS, standard for Minikube)

docs/Local_Development_Tutorial.md

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# Local Development Tutorial: Getting Started with MarkLogic in Kubernetes
22

3-
# Table of contents
43
* [Introduction](#Introduction)
54
* [Prerequisites](##Prerequisites)
65
* [Procedure](#Procedure)
@@ -21,13 +20,12 @@ This tutorial describes how to set up local Kubernetes development environment w
2120

2221

2322
## Prerequisites
24-
The following steps assume you are running this tutorial from a desktop environment. Mobile environments will likely experience problems and may not work.
25-
- [Docker](https://docs.docker.com/engine/install/): Subscribe to Docker Hub and pulldown the latest image from: https://hub.docker.com/_/marklogic
23+
The following steps assume you are running this tutorial from a desktop environment.
24+
- [Docker](https://docs.docker.com/engine/install/): Pull the latest MarkLogic Server image from: https://hub.docker.com/r/marklogicdb/marklogic-db
2625
```sh
27-
# Something similar to this, with the latest version tag, which can be found on the dockerhub link above
28-
docker pull store/marklogicdb/marklogic-server:10.0-9-centos-1.0.0-ea4
26+
docker pull marklogicdb/marklogic-db:latest
2927
```
30-
- [KubeCTL](https://kubernetes.io/docs/tasks/tools/): Download and install this tool to assist with debugging in a Kubernetes environment.
28+
- [Kubectl](https://kubernetes.io/docs/tasks/tools/): Download and install this tool to assist with debugging in a Kubernetes environment.
3129
- [Helm](https://helm.sh/docs/intro/install/): Clone or download the chart repository: https://github.com/marklogic/marklogic-kubernetes
3230
- [Minikube](https://k8s-docs.netlify.app/en/docs/tasks/tools/install-minikube/): Download the Minikube Kubernetes environment, which will host the MarkLogic Server applications.
3331
- Browser: The latest version of a supported web browser. See the list here: [Web Browser](https://developer.marklogic.com/products/support-matrix/)
@@ -53,17 +51,14 @@ NAME STATUS ROLES AGE VERSION
5351
minikube Ready control-plane,master 1d v1.23.3
5452
```
5553

56-
To enable addons run the follow Minikube command for ingress:
57-
`minikube addons enable ingress`
5854
## Installing a Single MarkLogic Host to Minikube
59-
- Push the image used for MarkLogic Server to the VM:
60-
`minikube image load store/marklogicdb/marklogic-server:10.0-9-centos-1.0.0-ea4`
61-
The image ID used in the example is `store/marklogicdb/marklogic-server:10.0-9-centos-1.0.0-ea4`, which may not be the latest image. To find the latest ID go to https://hub.docker.com/_/marklogic
62-
- Add the helm repository
55+
- Push the image used for MarkLogic Server to the Minikube:
56+
`minikube image load marklogicdb/marklogic-db:latest`
57+
- Add the Helm repository
6358
`helm repo add marklogic https://marklogic.github.io/marklogic-kubernetes/`
6459
Additionally create a `values.yaml` file for your installation, like the one found in the repository under `/charts`: https://marklogic.github.io/marklogic-kubernetes/. The `values.yaml` file controls configuration for MarkLogic Server running in kubernetes.
65-
Run `helm install RELEASE_NAME marklogic/marklogic --version=1.0.0-ea1 -f values.yaml` where the `RELEASE_NAME` can be any name you want to use to identify this deployment.
66-
For example: `helm install marklogic-local-dev-env marklogic/marklogic --version=1.0.0-ea1 -f values.yaml`
60+
Run `helm install RELEASE_NAME marklogic/marklogic --version=1.0.0-ea1 --values values.yaml` where the `RELEASE_NAME` can be any name you want to use to identify this deployment.
61+
For example: `helm install marklogic-local-dev-env marklogic/marklogic --version=1.0.0-ea1 --values values.yaml`
6762
## Installing Multiple MarkLogic Hosts to Minikube
6863
To create a MarkLogic cluster in Minikube, change the `replicaCount` in the `values.yaml` file to 3, or any other odd number to avoid the [split brain problem](https://help.marklogic.com/Knowledgebase/Article/View/119/0/start-up-quorum-and-forest-level-failover). Then follow the procedure outlined in the [Installing a Single MarkLogic Host to Minikube](##Installing-a-Single-MarkLogic-Host-to-Minikube) section.
6964

@@ -112,7 +107,7 @@ Events:
112107
Type Reason Age From Message
113108
---- ------ ---- ---- -------
114109
Normal Scheduled 13m default-scheduler Successfully assigned default/marklogic-0 to minikube
115-
Normal Pulled 13m kubelet Container image "store/marklogicdb/marklogic-server:10.0-8.3-centos-1.0.0-ea3" already present on machine
110+
Normal Pulled 13m kubelet Container image "marklogicdb/marklogic-db:latest" already present on machine
116111
Normal Created 13m kubelet Created container marklogic
117112
Normal Started 13m kubelet Started container marklogic
118113
Warning Unhealthy 13m kubelet Startup probe failed: ls: cannot access /var/opt/MarkLogic/ready: No such file or directory

index.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ entries:
55
category: Database
66
apiVersion: v2
77
appVersion: 10.0-9.1
8-
created: "2022-05-17T09:57:32.858679-07:00"
8+
created: "2022-07-27T11:08:21.005111-07:00"
99
description: MarkLogic Server is a multi-model database that has both NoSQL and
1010
trusted enterprise data management capabilities.
11-
digest: 9aa4ac1a4d76a12b2417095057922dac60634ef11d73745d2c393636614f5377
11+
digest: 2d9588d42beaaef3267d1375b50ab5d972863c259ebb4d843c4b24c480467321
1212
keywords:
1313
- marklogic
1414
- database
@@ -21,4 +21,4 @@ entries:
2121
urls:
2222
- marklogic-1.0.0-ea1.tgz
2323
version: 1.0.0-ea1
24-
generated: "2022-05-17T09:57:32.855369-07:00"
24+
generated: "2022-07-27T11:08:21.002809-07:00"

marklogic-1.0.0-ea1.tgz

51 Bytes
Binary file not shown.

test/e2e/e2e.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ echo "=====Installing minikube cluster"
44
minikube start --driver=docker -n=1
55

66
echo "=====Loading marklogc images to minikube cluster"
7-
minikube image load marklogic-centos/marklogic-server-centos:10-internal
7+
minikube image load marklogicdb/marklogic-db:latest
88

99
echo "=====Running tests"
1010
go test -v -count=1 ./test/e2e/...

test/e2e/install_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ import (
1515
)
1616

1717
func TestHelmInstall(t *testing.T) {
18-
// Path to the helm chart we will test
18+
// Path to the helm chart we will test
1919
helmChartPath, e := filepath.Abs("../../charts")
20-
if (e != nil) {
20+
if e != nil {
2121
t.Fatalf(e.Error())
2222
}
2323
namespaceName := "marklogic-" + strings.ToLower(random.UniqueId())
@@ -34,7 +34,7 @@ func TestHelmInstall(t *testing.T) {
3434

3535
t.Logf("====Creating namespace: " + namespaceName)
3636
k8s.CreateNamespace(t, kubectlOptions, namespaceName)
37-
37+
3838
defer t.Logf("====Deleting namespace: " + namespaceName)
3939
defer k8s.DeleteNamespace(t, kubectlOptions, namespaceName)
4040

0 commit comments

Comments
 (0)