Skip to content

Commit 1a1ebae

Browse files
sumanthravipatisumanthravipati
andauthored
MLE-14605: Changes to set permissions to mount paths for root to rootless upgrade (#257)
Co-authored-by: sumanthravipati <[email protected]>
1 parent d6abfbd commit 1a1ebae

File tree

5 files changed

+60
-6
lines changed

5 files changed

+60
-6
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@ Following table lists all the parameters supported by the latest MarkLogic Helm
124124
| `image.pullPolicy` | Image pull policy for MarkLogic image | `IfNotPresent` |
125125
| `initContainers.configureGroup.image` | Image for configureGroup InitContainer | `curlimages/curl:8.6.0` |
126126
| `initContainers.configureGroup.pullPolicy` | Pull policy for configureGroup InitContainer | `IfNotPresent` |
127-
| `initContainers.copyCerts.image` | Image for copyCerts InitContainer | `redhat/ubi9:9.3` |
128-
| `initContainers.copyCerts.pullPolicy` | Pull policy for copyCerts InitContainer | `IfNotPresent` |
127+
| `initContainers.utilContainer.image` | Image for copyCerts and volume permission change for root to rootless upgrade InitContainer | `redhat/ubi9:9.3` |
128+
| `initContainers.utilContainer.pullPolicy` | Pull policy for copyCerts and volume permission change for root to rootless upgrade InitContainer | `IfNotPresent` |
129129
| `imagePullSecrets` | Registry secret names as an array | `[]` |
130130
| `hugepages.enabled` | Parameter to enable Hugepage on MarkLogic | `false` |
131131
| `hugepages.mountPath` | Mountpath for Hugepages | `/dev/hugepages` |

charts/templates/_helpers.tpl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,18 @@ Validate values file
210210
{{- end }}
211211
{{- end }}
212212

213+
{{/*
214+
Validate root to rootless upgrade
215+
*/}}
216+
{{- define "marklogic.rootToRootlessUpgrade" -}}
217+
{{- if .Values.rootToRootlessUpgrade }}
218+
{{- if not (.Values.image.tag | contains "rootless") }}
219+
{{- $errorMessage := printf "%s" "Root to Rootless Upgrade is supported only if rootToRootlessUpgrade flag is true and image type is rootless." }}
220+
{{- fail $errorMessage }}
221+
{{- end }}
222+
{{- end }}
223+
{{- end }}
224+
213225
{{/*
214226
Name to distinguish marklogic image whether root or rootless
215227
*/}}

charts/templates/configmap-scripts.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -828,5 +828,29 @@ data:
828828
fi
829829
830830
info "helm script completed"
831+
832+
root-rootless-upgrade.sh: |
833+
#!/bin/bash
834+
log () {
835+
local TIMESTAMP=$(date +"%Y-%m-%d %T.%3N")
836+
# Check to make sure pod doesn't terminate if PID value is empty for any reason
837+
if [ -n "$pid" ]; then
838+
echo "${TIMESTAMP} $@" > /proc/$pid/fd/1
839+
fi
840+
}
841+
842+
pid=$(pgrep start.marklogic)
843+
844+
log "Info: [root-rootless-upgrade] Execution Start"
845+
846+
# Change the permission on default data directory
847+
chown -R 1000:100 /var/opt/MarkLogic
848+
log "Info: [root-rootless-upgrade] Data Directory Permission Update Completed"
849+
850+
# Logic to set permission for additional volume mounts
851+
{{ range $_, $v := .Values.additionalVolumeMounts }}
852+
chown -R 1000:100 {{ $v.mountPath }}
853+
log "Info: [root-rootless-upgrade] Additional Mount Path Permission Update Completed: {{ $v.mountPath }}"
854+
{{ end }}
831855
832856

charts/templates/statefulset.yaml

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232

3333
{{- include "marklogic.checkUpgradeError" . -}}
3434
{{- include "marklogic.checkInputError" . }}
35+
{{- include "marklogic.rootToRootlessUpgrade" . }}
3536
apiVersion: apps/v1
3637
kind: StatefulSet
3738
metadata:
@@ -69,11 +70,11 @@ spec:
6970
topologySpreadConstraints: {{- toYaml . | nindent 6}}
7071
{{- end }}
7172
terminationGracePeriodSeconds: {{ .Values.terminationGracePeriod }}
72-
{{- if eq .Values.tls.enableOnDefaultAppServers true }}
7373
initContainers:
74+
{{- if eq .Values.tls.enableOnDefaultAppServers true }}
7475
- name: copy-certs
75-
image: {{ .Values.initContainers.copyCerts.image | quote }}
76-
imagePullPolicy: {{ .Values.initContainers.copyCerts.pullPolicy | quote }}
76+
image: {{ .Values.initContainers.utilContainer.image | quote }}
77+
imagePullPolicy: {{ .Values.initContainers.utilContainer.pullPolicy | quote }}
7778
command: ["/bin/sh", "/tmp/helm-scripts/copy-certs.sh"]
7879
volumeMounts:
7980
{{- if .Values.tls.certSecretNames }}
@@ -102,6 +103,20 @@ spec:
102103
- configMapRef:
103104
name: {{ include "marklogic.fullname" . }}
104105
{{- end }}
106+
{{- if eq .Values.rootToRootlessUpgrade true }}
107+
- name: root-rootless-upgrade
108+
image: {{ .Values.initContainers.utilContainer.image | quote }}
109+
imagePullPolicy: {{ .Values.initContainers.utilContainer.pullPolicy | quote }}
110+
command: ["/bin/sh", "/tmp/helm-scripts/root-rootless-upgrade.sh"]
111+
volumeMounts:
112+
- name: datadir
113+
mountPath: /var/opt/MarkLogic
114+
{{- if .Values.additionalVolumeMounts }}
115+
{{- toYaml .Values.additionalVolumeMounts | nindent 10 }}
116+
{{- end }}
117+
- name: helm-scripts
118+
mountPath: /tmp/helm-scripts
119+
{{- end }}
105120
containers:
106121
- name: marklogic-server
107122
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"

charts/values.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ group:
3939
## The name of the host to join. If not provided, the deployment is a bootstrap host.
4040
bootstrapHostName: ""
4141

42+
## Flag to enable to migrate from MarkLogic root to rootless image
43+
rootToRootlessUpgrade: false
44+
4245
## Marklogic image parameters
4346
image:
4447
repository: marklogicdb/marklogic-db
@@ -50,7 +53,7 @@ initContainers:
5053
configureGroup:
5154
image: "curlimages/curl:8.6.0"
5255
pullPolicy: IfNotPresent
53-
copyCerts:
56+
utilContainer:
5457
image: "redhat/ubi9:9.3"
5558
pullPolicy: IfNotPresent
5659

0 commit comments

Comments
 (0)