Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
160 changes: 150 additions & 10 deletions charts/ozone/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -51,22 +51,116 @@ app.kubernetes.io/instance: {{ .Release.Name }}
{{- $pods | join "," }}
{{- end }}

{{/* Common configuration environment variables */}}
{{- define "ozone.configuration.env" -}}
{{/* List of comma separated om ids */}}
{{- define "ozone.om.cluster.ids" -}}
{{- $pods := list }}
{{- $replicas := .Values.om.replicas | int }}
{{- range $i := until $replicas }}
{{- $pods = append $pods (printf "%s-om-%d" $.Release.Name $i) }}
{{- end }}
{{- $pods | join "," }}
{{- end }}

{{/* List of comma separated scm ids */}}
{{- define "ozone.scm.cluster.ids" -}}
{{- $pods := list }}
{{- $replicas := .Values.scm.replicas | int }}
{{- range $i := until $replicas }}
{{- $pods = append $pods (printf "%s-scm-%d" $.Release.Name $i) }}
{{- end }}
{{- $pods | join "," }}
{{- end }}

{{/* List of decommission om nodes */}}
{{- define "ozone.om.decommissioned.nodes" -}}
{{- $nodes := list }}
{{- $statefulset := lookup "apps/v1" "StatefulSet" $.Release.Namespace (printf "%s-om" $.Release.Name) -}}
{{- if $statefulset }}
{{- $oldCount := $statefulset.spec.replicas | int -}}
{{- $newCount := .Values.om.replicas | int }}
{{- range $i := until $oldCount }}
{{- $minCount := max $newCount 1 -}}
{{- if ge $i $minCount }}
{{- $nodes = append $nodes (printf "%s-om-%d" $.Release.Name $i) }}
{{- end }}
{{- end }}
{{- end }}
{{- $nodes | join "," }}
{{- end }}

{{/* List of bootstrap om nodes */}}
{{- define "ozone.om.bootstrap.nodes" -}}
{{- $nodes := list }}
{{- $statefulset := lookup "apps/v1" "StatefulSet" $.Release.Namespace (printf "%s-om" $.Release.Name) -}}
{{- if $statefulset }}
{{- $oldCount := $statefulset.spec.replicas | int -}}
{{- $newCount := .Values.om.replicas | int }}
{{- range $i := until $newCount }}
{{- if ge $i $oldCount }}
{{- $nodes = append $nodes (printf "%s-om-%d" $.Release.Name $i) }}
{{- end }}
{{- end }}
{{- end }}
{{- $nodes | join ","}}
{{- end }}

{{/* List of decommission scm nodes */}}
{{- define "ozone.scm.decommissioned.nodes" -}}
{{- $nodes := list }}
{{- $statefulset := lookup "apps/v1" "StatefulSet" $.Release.Namespace (printf "%s-scm" $.Release.Name) -}}
{{- if $statefulset }}
{{- $oldCount := $statefulset.spec.replicas | int -}}
{{- $newCount := .Values.scm.replicas | int }}
{{- range $i := until $oldCount }}
{{- if ge $i $newCount }}
{{- $nodes = append $nodes (printf "%s-scm-%d" $.Release.Name $i) }}
{{- end }}
{{- end }}
{{- end }}
{{- $nodes | join "," -}}
{{- end }}

{{/* List of decommission data nodes */}}
{{- define "ozone.data.decommissioned.hosts" -}}
{{- $hosts := list }}
{{- $statefulset := lookup "apps/v1" "StatefulSet" $.Release.Namespace (printf "%s-datanode" $.Release.Name) -}}
{{- if $statefulset }}
{{- $oldCount := $statefulset.spec.replicas | int -}}
{{- $newCount := .Values.datanode.replicas | int }}
{{- range $i := until $oldCount }}
{{- if ge $i $newCount }}
{{- $hosts = append $hosts (printf "%s-datanode-%d.%s-datanode-headless.%s.svc.cluster.local" $.Release.Name $i $.Release.Name $.Release.Namespace) }}
{{- end }}
{{- end }}
{{- end }}
{{- $hosts | join "," -}}
{{- end }}

{{- define "ozone.configuration.env.common" -}}
- name: OZONE-SITE.XML_hdds.datanode.dir
value: /data/storage
- name: OZONE-SITE.XML_ozone.scm.datanode.id.dir
value: /data/metadata
- name: OZONE-SITE.XML_ozone.metadata.dirs
value: /data/metadata
- name: OZONE-SITE.XML_ozone.scm.block.client.address
value: {{ include "ozone.scm.pods" . }}
- name: OZONE-SITE.XML_ozone.scm.client.address
value: {{ include "ozone.scm.pods" . }}
- name: OZONE-SITE.XML_ozone.scm.names
value: {{ include "ozone.scm.pods" . }}
- name: OZONE-SITE.XML_ozone.om.address
value: {{ include "ozone.om.pods" . }}
- name: OZONE-SITE.XML_ozone.scm.ratis.enable
value: "true"
- name: OZONE-SITE.XML_ozone.scm.service.ids
value: {{ .Values.clusterId }}
- name: OZONE-SITE.XML_ozone.scm.nodes.{{ .Values.clusterId }}
value: {{ include "ozone.scm.cluster.ids" . }}
{{/*- name: OZONE-SITE.XML_ozone.scm.skip.bootstrap.validation*/}}
{{/* value: {{ quote .Values.scm.skipBootstrapValidation }}*/}}
{{- range $i, $val := until ( .Values.scm.replicas | int ) }}
- name: {{ printf "OZONE-SITE.XML_ozone.scm.address.%s.%s-scm-%d" $.Values.clusterId $.Release.Name $i }}
value: {{ printf "%s-scm-%d.%s-scm-headless.%s.svc.cluster.local" $.Release.Name $i $.Release.Name $.Release.Namespace }}
{{- end }}
- name: OZONE-SITE.XML_ozone.scm.primordial.node.id
value: {{ printf "%s-scm-0" $.Release.Name }}
- name: OZONE-SITE.XML_ozone.om.ratis.enable
value: "true"
- name: OZONE-SITE.XML_ozone.om.service.ids
value: {{ .Values.clusterId }}
- name: OZONE-SITE.XML_hdds.scm.safemode.min.datanode
value: "3"
- name: OZONE-SITE.XML_ozone.datanode.pipeline.limit
Expand All @@ -78,3 +172,49 @@ app.kubernetes.io/instance: {{ .Release.Name }}
value: "{{- printf "%s-recon.%s.svc.cluster.local" $.Release.Name $.Release.Namespace }}:9891"
{{- end }}
{{- end }}

{{/* Common configuration environment variables */}}
{{- define "ozone.configuration.env" -}}
{{- $bOmNodes := ternary (splitList "," (include "ozone.om.bootstrap.nodes" .)) (list) (ne "" (include "ozone.om.bootstrap.nodes" .)) }}
{{- $dOmNodes := ternary (splitList "," (include "ozone.om.decommissioned.nodes" .)) (list) (ne "" (include "ozone.om.decommissioned.nodes" .)) }}
{{- $activeOmNodes := ternary (splitList "," (include "ozone.om.cluster.ids" .)) (list) (ne "" (include "ozone.om.cluster.ids" .)) }}
{{ include "ozone.configuration.env.common" . }}
{{- if gt (len $dOmNodes) 0 }}
{{- $decomIds := $dOmNodes | join "," }}
- name: OZONE-SITE.XML_ozone.om.decommissioned.nodes.{{ .Values.clusterId }}
value: {{ $decomIds }}
{{- else}}
- name: OZONE-SITE.XML_ozone.om.decommissioned.nodes.{{ .Values.clusterId }}
value: ""
{{- end }}
- name: OZONE-SITE.XML_ozone.om.nodes.{{ .Values.clusterId }}
value: {{ $activeOmNodes | join "," }}
{{- range $tempId := $activeOmNodes }}
- name: {{ printf "OZONE-SITE.XML_ozone.om.address.%s.%s" $.Values.clusterId $tempId }}
value: {{ printf "%s.%s-om-headless.%s.svc.cluster.local" $tempId $.Release.Name $.Release.Namespace }}
{{- end }}
{{- range $tempId := $dOmNodes }}
- name: {{ printf "OZONE-SITE.XML_ozone.om.address.%s.%s" $.Values.clusterId $tempId }}
value: {{ printf "%s-helm-manager-decommission-%s-svc.%s.svc.cluster.local" $.Release.Name $tempId $.Release.Namespace }}
{{- end }}
{{- end }}

{{/* Common configuration environment variables for pre hook */}}
{{- define "ozone.configuration.env.prehook" -}}
{{- $bOmNodes := ternary (splitList "," (include "ozone.om.bootstrap.nodes" .)) (list) (ne "" (include "ozone.om.bootstrap.nodes" .)) }}
{{- $dOmNodes := ternary (splitList "," (include "ozone.om.decommissioned.nodes" .)) (list) (ne "" (include "ozone.om.decommissioned.nodes" .)) }}
{{- $activeOmNodes := ternary (splitList "," (include "ozone.om.cluster.ids" .)) (list) (ne "" (include "ozone.om.cluster.ids" .)) }}
{{- $allOmNodes := concat $activeOmNodes $dOmNodes }}
{{ include "ozone.configuration.env.common" . }}
- name: OZONE-SITE.XML_ozone.om.decommissioned.nodes.{{ .Values.clusterId }}
value: ""
{{- range $tempId := $allOmNodes }}
- name: {{ printf "OZONE-SITE.XML_ozone.om.address.%s.%s" $.Values.clusterId $tempId }}
value: {{ printf "%s.%s-om-headless.%s.svc.cluster.local" $tempId $.Release.Name $.Release.Namespace }}
{{- end }}
{{ $allOmNodes = append $allOmNodes "om-leader-transfer"}}
- name: OZONE-SITE.XML_ozone.om.nodes.{{ .Values.clusterId }}
value: {{ $allOmNodes | join "," }}
- name: "OZONE-SITE.XML_ozone.om.address.{{ .Values.clusterId }}.om-leader-transfer"
value: localhost
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ spec:
ports:
- name: ui
port: {{ .Values.datanode.service.port }}
- name: ratis-ipc
port: {{ .Values.datanode.service.ratisIpcPort }}
- name: ipc
port: {{ .Values.datanode.service.ipcPort }}
selector:
{{- include "ozone.selectorLabels" . | nindent 4 }}
app.kubernetes.io/component: datanode
8 changes: 6 additions & 2 deletions charts/ozone/templates/datanode/datanode-statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

{{- $env := concat .Values.env .Values.datanode.env }}
{{- $envFrom := concat .Values.envFrom .Values.datanode.envFrom }}
{{- $podAnnotations := mergeOverwrite (deepCopy .Values.podAnnotations) .Values.datanode.podAnnotations }}
{{- $podAnnotations := mergeOverwrite (deepCopy (default dict .Values.podAnnotations)) (default dict .Values.datanode.podAnnotations) }}
{{- $nodeSelector := or .Values.datanode.nodeSelector .Values.nodeSelector }}
{{- $affinity := or .Values.datanode.affinity .Values.affinity }}
{{- $tolerations := or .Values.datanode.tolerations .Values.tolerations }}
Expand All @@ -40,7 +40,7 @@ spec:
template:
metadata:
annotations:
checksum/config: {{ include (print $.Template.BasePath "/ozone-configmap.yaml") . | sha256sum }}
checksum/config: {{ include (print $.Template.BasePath "/ozone-configmap.yaml") . | cat (include "ozone.configuration.env" .) | sha256sum }}
{{- with $podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
Expand Down Expand Up @@ -69,6 +69,10 @@ spec:
ports:
- name: ui
containerPort: {{ .Values.datanode.service.port }}
- name: ratis-ipc
containerPort: {{ .Values.datanode.service.ratisIpcPort }}
- name: ipc
containerPort: {{ .Values.datanode.service.ipcPort }}
livenessProbe:
httpGet:
path: /
Expand Down
105 changes: 105 additions & 0 deletions charts/ozone/templates/helm/om-decommission-job.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
{{- if .Values.om.persistence.enabled }}
{{- $dnodes := ternary (splitList "," (include "ozone.om.decommissioned.nodes" .)) (list) (ne "" (include "ozone.om.decommissioned.nodes" .)) }}
{{- $env := concat .Values.env .Values.helm.env }}
{{- $envFrom := concat .Values.envFrom .Values.helm.envFrom }}
{{- $nodeSelector := or .Values.helm.nodeSelector .Values.nodeSelector }}
{{- $affinity := or .Values.helm.affinity .Values.affinity }}
{{- $tolerations := or .Values.helm.tolerations .Values.tolerations }}
{{- $securityContext := or .Values.helm.securityContext .Values.securityContext }}
{{- if (gt (len $dnodes) 0) }}
{{- range $dnode := $dnodes }}
---
apiVersion: batch/v1
kind: Job
metadata:
name: {{ printf "%s-helm-manager-decommission-%s" $.Release.Name $dnode }}
labels:
{{- include "ozone.labels" $ | nindent 4 }}
app.kubernetes.io/component: helm-manager
annotations:
"helm.sh/hook": post-upgrade
"helm.sh/hook-weight": "0"
"helm.sh/hook-delete-policy": hook-succeeded, hook-failed
spec:
backoffLimit: {{ $.Values.helm.backoffLimit }}
template:
metadata:
labels:
{{- include "ozone.selectorLabels" $ | nindent 8 }}
app.kubernetes.io/component: helm-manager
spec:
containers:
- name: om-decommission
image: "{{ $.Values.image.repository }}:{{ $.Values.image.tag | default $.Chart.AppVersion }}"
imagePullPolicy: {{ $.Values.image.pullPolicy }}
{{- with $.Values.om.command }}
command: {{- tpl (toYaml .) $ | nindent 12 }}
{{- end }}
args:
- sh
- -c
- |
set -e
decommission_finalizer() {
echo "Init decommission finalizer process..."
while true; do
IFS= read -r line;
echo "$line"
if echo "$line" | grep -q "Successfully decommissioned OM {{ $dnode }}"; then
echo "{{ $dnode }} was successfully decommissioned!"
if [ -d /old{{ $.Values.om.persistence.path }} ]; then
echo "Delete old data on pvc to enable rescheduling without manual PVC deletion!"
rm -rf /old{{ $.Values.om.persistence.path }}/*
echo "Data deleted!"
fi
break;
fi
done
echo "Decommission finalizer process finished!"
exit 0
}
exec ozone admin om decommission -id={{ $.Values.clusterId }} -nodeid={{ $dnode }} -hostname={{ printf "%s-helm-manager-decommission-%s-svc.%s.svc.cluster.local" $.Release.Name $dnode $.Release.Namespace }} | decommission_finalizer
env:
{{- include "ozone.configuration.env" $ | nindent 12 }}
{{- with $env }}
{{- tpl (toYaml .) $ | nindent 12 }}
{{- end }}
{{- with $envFrom }}
envFrom: {{- tpl (toYaml .) $ | nindent 12 }}
{{- end }}
ports:
- name: om-rpc
containerPort: {{ $.Values.om.service.rpcPort }}
- name: om-ratis
containerPort: {{ $.Values.om.service.ratisPort }}
volumeMounts:
- name: config
mountPath: {{ $.Values.configuration.dir }}
- name: om-data
mountPath: {{ $.Values.om.persistence.path }}
- name: om-data-old
mountPath: /old{{ $.Values.om.persistence.path }}
{{- with $nodeSelector }}
nodeSelector: {{- toYaml . | nindent 8 }}
{{- end }}
{{- with $securityContext }}
securityContext: {{- toYaml . | nindent 8 }}
{{- end }}
volumes:
- name: om-data-old
persistentVolumeClaim:
claimName: {{ $.Release.Name}}-om-{{ $dnode }}
- name: om-data
emptyDir: { }
- name: config
projected:
sources:
- configMap:
name: {{ $.Release.Name }}-ozone
{{- with $.Values.configuration.filesFrom }}
{{- tpl (toYaml .) $ | nindent 14 }}
{{- end }}
restartPolicy: Never
{{- end }}
{{- end }}
{{- end }}
30 changes: 30 additions & 0 deletions charts/ozone/templates/helm/om-decommission-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{{- if .Values.om.persistence.enabled }}
{{- $dnodes := ternary (splitList "," (include "ozone.om.decommissioned.nodes" .)) (list) (ne "" (include "ozone.om.decommissioned.nodes" .)) }}
{{- if (gt (len $dnodes) 0) }}
{{- range $dnode := $dnodes }}
---
apiVersion: v1
kind: Service
metadata:
name: {{ printf "%s-helm-manager-decommission-%s-svc" $.Release.Name $dnode }}
labels:
{{- include "ozone.labels" $ | nindent 4 }}
app.kubernetes.io/component: helm-manager
annotations:
"helm.sh/hook": post-upgrade
"helm.sh/hook-weight": "-10"
"helm.sh/hook-delete-policy": hook-succeeded, hook-failed
spec:
selector:
job-name: {{ printf "%s-helm-manager-decommission-%s" $.Release.Name $dnode }}
ports:
- name: rpc
port: {{ $.Values.om.service.rpcPort }}
targetPort: {{ $.Values.om.service.rpcPort }}
- name: ratis
port: {{ $.Values.om.service.ratisPort }}
targetPort: {{ $.Values.om.service.ratisPort }}
type: ClusterIP
{{- end }}
{{- end }}
{{- end }}
Loading