Skip to content

Commit

Permalink
[Feature] Add preStartScriptLocation field and support in helm chart
Browse files Browse the repository at this point in the history
Signed-off-by: yandongxiao <[email protected]>
  • Loading branch information
yandongxiao committed Apr 22, 2024
1 parent 2829c25 commit 5df9d2c
Show file tree
Hide file tree
Showing 16 changed files with 325 additions and 10 deletions.
12 changes: 12 additions & 0 deletions config/crd/bases/starrocks.com_starrocksclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2585,6 +2585,10 @@ spec:
type: string
description: the pod labels for user select or classify pods.
type: object
preStartScriptLocation:
description: PreStartScriptLocation is the location of the pre-start
script. It will be executed before the starrocks process starts.
type: string
readinessProbeFailureSeconds:
description: |-
ReadinessProbeFailureSeconds defines the total failure seconds of readiness Probe.
Expand Down Expand Up @@ -7275,6 +7279,10 @@ spec:
type: string
description: the pod labels for user select or classify pods.
type: object
preStartScriptLocation:
description: PreStartScriptLocation is the location of the pre-start
script. It will be executed before the starrocks process starts.
type: string
readinessProbeFailureSeconds:
description: |-
ReadinessProbeFailureSeconds defines the total failure seconds of readiness Probe.
Expand Down Expand Up @@ -12645,6 +12653,10 @@ spec:
type: string
description: the pod labels for user select or classify pods.
type: object
preStartScriptLocation:
description: PreStartScriptLocation is the location of the pre-start
script. It will be executed before the starrocks process starts.
type: string
readinessProbeFailureSeconds:
description: |-
ReadinessProbeFailureSeconds defines the total failure seconds of readiness Probe.
Expand Down
4 changes: 4 additions & 0 deletions config/crd/bases/starrocks.com_starrockswarehouses.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3196,6 +3196,10 @@ spec:
type: string
description: the pod labels for user select or classify pods.
type: object
preStartScriptLocation:
description: PreStartScriptLocation is the location of the pre-start
script. It will be executed before the starrocks process starts.
type: string
readinessProbeFailureSeconds:
description: |-
ReadinessProbeFailureSeconds defines the total failure seconds of readiness Probe.
Expand Down
6 changes: 6 additions & 0 deletions deploy/starrocks.com_starrocksclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1272,6 +1272,8 @@ spec:
additionalProperties:
type: string
type: object
preStartScriptLocation:
type: string
readinessProbeFailureSeconds:
format: int32
type: integer
Expand Down Expand Up @@ -3545,6 +3547,8 @@ spec:
additionalProperties:
type: string
type: object
preStartScriptLocation:
type: string
readinessProbeFailureSeconds:
format: int32
type: integer
Expand Down Expand Up @@ -6108,6 +6112,8 @@ spec:
additionalProperties:
type: string
type: object
preStartScriptLocation:
type: string
readinessProbeFailureSeconds:
format: int32
type: integer
Expand Down
2 changes: 2 additions & 0 deletions deploy/starrocks.com_starrockswarehouses.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1594,6 +1594,8 @@ spec:
additionalProperties:
type: string
type: object
preStartScriptLocation:
type: string
readinessProbeFailureSeconds:
format: int32
type: integer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,22 @@ be.conf: |
{{- print "/opt/starrocks/cn/log" }}
{{- end }}

{{- define "starrockscluster.pre.start.script.name" -}}
{{- print "start.sh" }}
{{- end }}

{{- define "starrockscluster.fe.pre.start.configmap.name" -}}
{{- print (include "starrockscluster.name" .) "-fe-pre-start-script" }}
{{- end }}

{{- define "starrockscluster.be.pre.start.configmap.name" -}}
{{- print (include "starrockscluster.name" .) "-be-pre-start-script" }}
{{- end }}

{{- define "starrockscluster.cn.pre.start.configmap.name" -}}
{{- print (include "starrockscluster.name" .) "-cn-pre-start-script" }}
{{- end }}

{{/*
Define a function to handle resource limits for fe
*/}}
Expand Down Expand Up @@ -227,6 +243,33 @@ the first 8 digits are taken, which will be used as the annotations for pods.
{{- end }}
{{- end }}

{{- define "starrockscluster.fe.prestart.script.hash" }}
{{- if .Values.starrocksFESpec.preStart }}
{{- $hash := toJson .Values.starrocksFESpec.preStart.script | sha256sum | trunc 8 }}
{{- printf "%s" $hash }}
{{- else }}
{{- printf "no-config" }}
{{- end }}
{{- end }}

{{- define "starrockscluster.be.prestart.script.hash" }}
{{- if .Values.starrocksBeSpec.preStart }}
{{- $hash := toJson .Values.starrocksBeSpec.preStart.script | sha256sum | trunc 8 }}
{{- printf "%s" $hash }}
{{- else }}
{{- printf "no-config" }}
{{- end }}
{{- end }}

{{- define "starrockscluster.cn.prestart.script.hash" }}
{{- if .Values.starrocksCnSpec.preStart }}
{{- $hash := toJson .Values.starrocksCnSpec.preStart.script | sha256sum | trunc 8 }}
{{- printf "%s" $hash }}
{{- else }}
{{- printf "no-config" }}
{{- end }}
{{- end }}

{{- define "starrockscluster.fe.http.port" -}}
{{- $config := index .Values.starrocksFESpec.config -}}
{{- $configMap := dict -}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,40 @@ data:
{{- end }}
{{- end }}
---
{{- end }}
{{- end }}

---

{{- if .Values.starrocksFESpec.preStart }}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "starrockscluster.fe.pre.start.configmap.name" .}}
data:
{{ template "starrockscluster.pre.start.script.name" .}}: |
{{- .Values.starrocksFESpec.preStart.script | nindent 4 }}
{{- end }}

---

{{- if .Values.starrocksBeSpec.preStart }}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "starrockscluster.be.pre.start.configmap.name" .}}
data:
{{ template "starrockscluster.pre.start.script.name" .}}: |
{{- .Values.starrocksBeSpec.preStart.script | nindent 4 }}
{{- end }}

---

{{- if .Values.starrocksCnSpec.preStart }}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "starrockscluster.cn.pre.start.configmap.name" .}}
data:
{{ template "starrockscluster.pre.start.script.name" .}}: |
{{- .Values.starrocksCnSpec.preStart.script | nindent 4 }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ spec:
{{- toYaml .Values.starrocksFESpec.initContainers | nindent 6 }}
{{- end }}
image: "{{ .Values.starrocksFESpec.image.repository }}:{{ include "starrockscluster.fe.image.tag" . }}"
{{- if .Values.starrocksFESpec.preStart }}
preStartScriptLocation: {{ .Values.starrocksFESpec.preStart.mountPath }}/{{template "starrockscluster.pre.start.script.name" .}}
{{- end }}
replicas: {{ .Values.starrocksFESpec.replicas }}
imagePullPolicy: {{ .Values.starrocksFESpec.imagePullPolicy }}
{{- /*
Expand Down Expand Up @@ -58,6 +61,9 @@ spec:
ad.datadoghq.com/fe.logs: {{ printf "[%s]" (printf "{%s, \"source\": \"fe\", \"service\": \"starrocks\"}" (trimAll " {}" .Values.datadog.log.logConfig) | fromJson | toJson) | squote }}
{{- end }}
{{- end }}
{{- if .Values.starrocksFESpec.preStart }}
app.starrocks.io/fe-pre-start-hash: {{template "starrockscluster.fe.prestart.script.hash" . }}
{{- end }}
{{- if .Values.starrocksFESpec.annotations }}
{{- toYaml .Values.starrocksFESpec.annotations | nindent 6 }}
{{- end }}
Expand Down Expand Up @@ -174,14 +180,20 @@ spec:
subPath: {{ .subPath }}
{{- end }}
{{- end }}
{{- if .Values.starrocksFESpec.configMaps }}
{{- if or .Values.starrocksFESpec.configMaps .Values.starrocksFESpec.preStart }}
configMaps:
{{- if .Values.starrocksFESpec.configMaps }}
{{- range .Values.starrocksFESpec.configMaps }}
- name: {{ .name }}
mountPath: {{ .mountPath }}
subPath: {{ .subPath }}
{{- end }}
{{- end }}
{{- if .Values.starrocksFESpec.preStart }}
- name: {{template "starrockscluster.fe.pre.start.configmap.name" .}}
mountPath: {{ .Values.starrocksFESpec.preStart.mountPath }}
{{- end }}
{{- end }}
configMapInfo:
configMapName: {{ template "starrockscluster.fe.configmap.name" . }}
resolveKey: fe.conf
Expand Down Expand Up @@ -222,6 +234,9 @@ spec:
{{- toYaml .Values.starrocksBeSpec.initContainers | nindent 6 }}
{{- end }}
image: "{{ .Values.starrocksBeSpec.image.repository }}:{{ include "starrockscluster.be.image.tag" . }}"
{{- if .Values.starrocksBeSpec.preStart }}
preStartScriptLocation: {{ .Values.starrocksBeSpec.preStart.mountPath }}/{{ template "starrockscluster.pre.start.script.name" . }}
{{- end }}
replicas: {{ .Values.starrocksBeSpec.replicas }}
imagePullPolicy: {{ .Values.starrocksBeSpec.imagePullPolicy }}
{{- /*
Expand Down Expand Up @@ -266,6 +281,9 @@ spec:
{{- if .Values.starrocksBeSpec.annotations }}
{{- toYaml .Values.starrocksBeSpec.annotations | nindent 6 }}
{{- end }}
{{- if .Values.starrocksBeSpec.preStart }}
app.starrocks.io/be-pre-start-hash: {{template "starrockscluster.be.prestart.script.hash" . }}
{{- end }}
{{- if or .Values.starrocksBeSpec.imagePullSecrets .Values.starrocksCluster.componentValues.imagePullSecrets }}
imagePullSecrets:
{{- include "starrockscluster.be.imagePullSecrets" . | nindent 6 }}
Expand Down Expand Up @@ -392,14 +410,20 @@ spec:
subPath: {{ .subPath }}
{{- end }}
{{- end }}
{{- if .Values.starrocksBeSpec.configMaps }}
{{- if or .Values.starrocksBeSpec.configMaps .Values.starrocksBeSpec.preStart }}
configMaps:
{{- if .Values.starrocksBeSpec.configMaps }}
{{- range .Values.starrocksBeSpec.configMaps }}
- name: {{ .name }}
mountPath: {{ .mountPath }}
subPath: {{ .subPath }}
{{- end }}
{{- end }}
{{- if .Values.starrocksBeSpec.preStart }}
- name: {{template "starrockscluster.be.pre.start.configmap.name" .}}
mountPath: {{ .Values.starrocksBeSpec.preStart.mountPath }}
{{- end }}
{{- end }}
configMapInfo:
configMapName: {{template "starrockscluster.be.configmap.name" . }}
resolveKey: be.conf
Expand Down Expand Up @@ -440,6 +464,9 @@ spec:
{{- toYaml .Values.starrocksCnSpec.initContainers | nindent 6 }}
{{- end }}
image: "{{ .Values.starrocksCnSpec.image.repository }}:{{ include "starrockscluster.cn.image.tag" . }}"
{{- if .Values.starrocksCnSpec.preStart }}
preStartScriptLocation: {{ .Values.starrocksCnSpec.preStart.mountPath }}/{{template "starrockscluster.pre.start.script.name" .}}
{{- end }}
{{- if .Values.starrocksCnSpec.replicas }}
replicas: {{ .Values.starrocksCnSpec.replicas }}
{{- end }}
Expand Down Expand Up @@ -605,6 +632,9 @@ spec:
{{- if .Values.starrocksCnSpec.annotations }}
{{- toYaml .Values.starrocksCnSpec.annotations | nindent 6 }}
{{- end }}
{{- if .Values.starrocksCnSpec.preStart }}
app.starrocks.io/cn-pre-start-hash: {{template "starrockscluster.cn.prestart.script.hash" . }}
{{- end }}
{{- if or .Values.starrocksCnSpec.imagePullSecrets .Values.starrocksCluster.componentValues.imagePullSecrets }}
imagePullSecrets:
{{- include "starrockscluster.cn.imagePullSecrets" . | nindent 6 }}
Expand All @@ -617,14 +647,20 @@ spec:
subPath: {{ .subPath }}
{{- end }}
{{- end }}
{{- if .Values.starrocksCnSpec.configMaps }}
{{- if or .Values.starrocksCnSpec.configMaps .Values.starrocksCnSpec.preStart }}
configMaps:
{{- if .Values.starrocksCnSpec.configMaps }}
{{- range .Values.starrocksCnSpec.configMaps }}
- name: {{ .name }}
mountPath: {{ .mountPath }}
subPath: {{ .subPath }}
{{- end }}
{{- end }}
{{- if .Values.starrocksCnSpec.preStart }}
- name: {{template "starrockscluster.cn.pre.start.configmap.name" .}}
mountPath: {{ .Values.starrocksCnSpec.preStart.mountPath }}
{{- end }}
{{- end }}
configMapInfo:
configMapName: {{template "starrockscluster.cn.configmap.name" . }}
resolveKey: cn.conf
Expand Down
21 changes: 21 additions & 0 deletions helm-charts/charts/kube-starrocks/charts/starrocks/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,13 @@ starrocksFESpec:
repository: starrocks/fe-ubuntu
tag: ""
imagePullPolicy: IfNotPresent
# specify the preStart for fe.
preStart: {}
# script: |
# #! /bin/bash
# echo "do something before start fe"
# # a configmap with name fe-pre-start-script will be created, and the script will be mounted to /etc/init-script/start.sh
# mountPath: /etc/init-script
# add annotations for fe pods. For example, if you want to config monitor for datadog, you can config the annotations.
annotations: {}
# If runAsNonRoot is true, the container is run as non-root user.
Expand Down Expand Up @@ -341,6 +348,13 @@ starrocksCnSpec:
repository: starrocks/cn-ubuntu
tag: ""
imagePullPolicy: IfNotPresent
# specify the preStart for cn.
preStart: {}
# script: |
# #! /bin/bash
# echo "do something before start cn"
# # a configmap with name cn-pre-start-script will be created, and the script will be mounted to /etc/init-script/start.sh
# mountPath: /etc/init-script/start.sh
# serviceAccount for cn access cloud service.
serviceAccount: ""
# add annotations for cn pods. example, if you want to config monitor for datadog, you can config the annotations.
Expand Down Expand Up @@ -580,6 +594,13 @@ starrocksBeSpec:
repository: starrocks/be-ubuntu
tag: ""
imagePullPolicy: IfNotPresent
# specify the preStart for be.
preStart: {}
# script: |
# #! /bin/bash
# echo "do something before start be"
# # a configmap with name be-pre-start-script will be created, and the script will be mounted to /etc/init-script/start.sh
# mountPath: /etc/init-script
# serviceAccount for be access cloud service.
serviceAccount: ""
# add annotations for be pods. example, if you want to config monitor for datadog, you can config the annotations.
Expand Down
21 changes: 21 additions & 0 deletions helm-charts/charts/kube-starrocks/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,13 @@ starrocks:
repository: starrocks/fe-ubuntu
tag: ""
imagePullPolicy: IfNotPresent
# specify the preStart for fe.
preStart: {}
# script: |
# #! /bin/bash
# echo "do something before start fe"
# # a configmap with name fe-pre-start-script will be created, and the script will be mounted to /etc/init-script/start.sh
# mountPath: /etc/init-script
# add annotations for fe pods. For example, if you want to config monitor for datadog, you can config the annotations.
annotations: {}
# If runAsNonRoot is true, the container is run as non-root user.
Expand Down Expand Up @@ -449,6 +456,13 @@ starrocks:
repository: starrocks/cn-ubuntu
tag: ""
imagePullPolicy: IfNotPresent
# specify the preStart for cn.
preStart: {}
# script: |
# #! /bin/bash
# echo "do something before start cn"
# # a configmap with name cn-pre-start-script will be created, and the script will be mounted to /etc/init-script/start.sh
# mountPath: /etc/init-script/start.sh
# serviceAccount for cn access cloud service.
serviceAccount: ""
# add annotations for cn pods. example, if you want to config monitor for datadog, you can config the annotations.
Expand Down Expand Up @@ -688,6 +702,13 @@ starrocks:
repository: starrocks/be-ubuntu
tag: ""
imagePullPolicy: IfNotPresent
# specify the preStart for be.
preStart: {}
# script: |
# #! /bin/bash
# echo "do something before start be"
# # a configmap with name be-pre-start-script will be created, and the script will be mounted to /etc/init-script/start.sh
# mountPath: /etc/init-script
# serviceAccount for be access cloud service.
serviceAccount: ""
# add annotations for be pods. example, if you want to config monitor for datadog, you can config the annotations.
Expand Down
Loading

0 comments on commit 5df9d2c

Please sign in to comment.