Skip to content

Commit

Permalink
Add time zone settings and fixed issue where Secret could not find du…
Browse files Browse the repository at this point in the history
…ring helm upgrade. (#188)

* 1.Add time zone settings.
2.Fixed issue where Secret could not find during help upgrade.

Signed-off-by: 张田 <[email protected]>
  • Loading branch information
WholeWorld-Timothy authored Jul 26, 2023
1 parent 23c7801 commit 9b9ac43
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 17 deletions.
7 changes: 7 additions & 0 deletions helm-charts/charts/kube-starrocks/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- print "starrocks" }}
{{- end }}

{{/*
initpassword secret name
*/}}

{{- define "kube-starrocks.initpassword.secret.name" -}}
{{ default (print (include "kube-starrocks.name" .) "-credential") .Values.initPassword.passwordSecret }}
{{- end }}

{{/*
starrockscluster
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
{{- if and .Values.initPassword.enabled .Release.IsInstall }}
{{- if .Values.initPassword.enabled }}
{{- if not .Values.initPassword.passwordSecret }}
apiVersion: v1
kind: Secret
metadata:
name: {{ template "kube-starrocks.initpassword.secret.name" . }}
namespace: {{ template "starrockscluster.namespace" . }}
data:
password: {{ .Values.initPassword.password | b64enc }}
---
{{- end }}
apiVersion: v1
kind: ConfigMap
metadata:
name: init-pwd-shell
namespace: {{ .Release.Namespace }}
namespace: {{ template "starrockscluster.namespace" . }}
data:
fe_initpwd.sh: |-
#!/bin/bash
Expand Down Expand Up @@ -31,5 +41,4 @@ data:
echo "Successfully modified password"
exit 0
{{- end }}
12 changes: 2 additions & 10 deletions helm-charts/charts/kube-starrocks/templates/init-pwd/job.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
{{- if and .Values.initPassword.enabled .Release.IsInstall }}
apiVersion: v1
kind: Secret
metadata:
name: {{ template "kube-starrocks.name" . }}-credential
namespace: {{ .Release.Namespace }}
data:
password: {{ .Values.initPassword.password | b64enc }}
---
apiVersion: batch/v1
kind: Job
metadata:
name: starrocks-initpwd
namespace: {{ .Release.Namespace }}
namespace: {{ template "starrockscluster.namespace" . }}
spec:
template:
spec:
Expand All @@ -30,7 +22,7 @@ spec:
valueFrom:
secretKeyRef:
key: password
name: {{ template "kube-starrocks.name" . }}-credential
name: {{ template "kube-starrocks.initpassword.secret.name" . }}
volumeMounts:
- mountPath: /opt/starrocks/fe_initpwd.sh
name: fe-initpwd-shell
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ spec:
- /sroperator
args:
- --leader-elect
{{- if .Values.timeZone }}
env:
- name: TZ
value: {{ .Values.timeZone }}
{{- end }}
image: "{{ .Values.starrocksOperator.image.repository }}:{{ .Values.starrocksOperator.image.tag }}"
imagePullPolicy: {{ .Values.starrocksOperator.imagePullPolicy }}
name: manager
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,15 @@ spec:
{{- end }}
{{- if or .Values.starrocksFESpec.feEnvVars .Values.initPassword.enabled }}
feEnvVars:
{{- if .Values.timeZone }}
- name: TZ
value: {{ .Values.timeZone }}
{{- end }}
{{- if and .Values.initPassword.enabled (.Values.starrocksFESpec.feEnvVars | toJson | contains "MYSQL_PWD" | not) }}
- name: "MYSQL_PWD"
valueFrom:
secretKeyRef:
name: {{ template "kube-starrocks.name" . }}-credential
name: {{ template "kube-starrocks.initpassword.secret.name" . }}
key: password
{{- end }}
{{- if .Values.starrocksFESpec.feEnvVars }}
Expand Down Expand Up @@ -175,11 +179,15 @@ spec:
{{- end }}
{{- if or .Values.starrocksBeSpec.beEnvVars .Values.initPassword.enabled }}
beEnvVars:
{{- if .Values.timeZone }}
- name: TZ
value: {{ .Values.timeZone }}
{{- end }}
{{- if and .Values.initPassword.enabled (.Values.starrocksBeSpec.beEnvVars | toJson | contains "MYSQL_PWD" | not) }}
- name: "MYSQL_PWD"
valueFrom:
secretKeyRef:
name: {{ template "kube-starrocks.name" . }}-credential
name: {{ template "kube-starrocks.initpassword.secret.name" . }}
key: password
{{- end }}
{{- if .Values.starrocksBeSpec.beEnvVars }}
Expand Down Expand Up @@ -259,11 +267,15 @@ spec:
{{- end }}
{{- if or .Values.starrocksCnSpec.cnEnvVars .Values.initPassword.enabled }}
cnEnvVars:
{{- if .Values.timeZone }}
- name: TZ
value: {{ .Values.timeZone }}
{{- end }}
{{- if and .Values.initPassword.enabled (.Values.starrocksCnSpec.cnEnvVars | toJson | contains "MYSQL_PWD" | not) }}
- name: "MYSQL_PWD"
valueFrom:
secretKeyRef:
name: {{ template "kube-starrocks.name" . }}-credential
name: {{ template "kube-starrocks.initpassword.secret.name" . }}
key: password
{{- end }}
{{- if .Values.starrocksCnSpec.cnEnvVars }}
Expand Down
7 changes: 6 additions & 1 deletion helm-charts/charts/kube-starrocks/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,15 @@ global:
# the starrockscluster crd' name.
nameOverride: ""
# This configuration is used to modify the root password during initial deployment.
# After deployment is completed, modify the password here and upgrade, does not modify the running root password
# After deployment is completed, it won't take effect to modify the password here and to do a `helm upgrade`.
# It also supports providing secret name that contains password, using the password in the secret instead of the plaintext in the values.yaml.
# When both password and passwordSecret are set, only passwordSecret takes effect.
initPassword:
enabled: false
password: ""
passwordSecret: ""
# TimeZone is used to set the environment variable TZ for pod, with Asia/Shanghai as the default.
timeZone: Asia/Shanghai

starrocksOperator:
enabled: true
Expand Down

0 comments on commit 9b9ac43

Please sign in to comment.