Skip to content

Commit

Permalink
Merge pull request #1531 from Altinity/fix_helm_release
Browse files Browse the repository at this point in the history
fix Helm release
  • Loading branch information
alex-zaitsev authored Oct 15, 2024
2 parents d963502 + f5966e8 commit 2a829e9
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 29 deletions.
3 changes: 1 addition & 2 deletions deploy/helm/clickhouse-operator/README.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ printf "%s-etc-keeper-operator-confd-files" (include "altinity-clickhouse-operator.fullname" .) }}
name: {{ printf "%s-keeper-confd-files" (include "altinity-clickhouse-operator.fullname" .) }}
namespace: {{ .Release.Namespace }}
labels: {{ include "altinity-clickhouse-operator.labels" . | nindent 4 }}
data: {{ include "altinity-clickhouse-operator.configmap-data" (list . .Values.configs.etcKeeperOperatorConfdFiles) | nindent 2 }}
data: {{ include "altinity-clickhouse-operator.configmap-data" (list . .Values.configs.keeperConfdFiles) | nindent 2 }}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ printf "%s-etc-keeper-operator-configd-files" (include "altinity-clickhouse-operator.fullname" .) }}
name: {{ printf "%s-keeper-configd-files" (include "altinity-clickhouse-operator.fullname" .) }}
namespace: {{ .Release.Namespace }}
labels: {{ include "altinity-clickhouse-operator.labels" . | nindent 4 }}
data: {{ include "altinity-clickhouse-operator.configmap-data" (list . .Values.configs.etcKeeperOperatorConfigdFiles) | nindent 2 }}
data: {{ include "altinity-clickhouse-operator.configmap-data" (list . .Values.configs.keeperConfigdFiles) | nindent 2 }}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ printf "%s-etc-keeper-operator-templatesd-files" (include "altinity-clickhouse-operator.fullname" .) }}
name: {{ printf "%s-keeper-templatesd-files" (include "altinity-clickhouse-operator.fullname" .) }}
namespace: {{ .Release.Namespace }}
labels: {{ include "altinity-clickhouse-operator.labels" . | nindent 4 }}
data: {{ include "altinity-clickhouse-operator.configmap-data" (list . .Values.configs.etcKeeperOperatorTemplatesdFiles) | nindent 2 }}
data: {{ include "altinity-clickhouse-operator.configmap-data" (list . .Values.configs.keeperTemplatesdFiles) | nindent 2 }}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ printf "%s-etc-keeper-operator-usersd-files" (include "altinity-clickhouse-operator.fullname" .) }}
name: {{ printf "%s-keeper-usersd-files" (include "altinity-clickhouse-operator.fullname" .) }}
namespace: {{ .Release.Namespace }}
labels: {{ include "altinity-clickhouse-operator.labels" . | nindent 4 }}
data: {{ include "altinity-clickhouse-operator.configmap-data" (list . .Values.configs.etcKeeperOperatorUsersdFiles) | nindent 2 }}
data: {{ include "altinity-clickhouse-operator.configmap-data" (list . .Values.configs.keeperUsersdFiles) | nindent 2 }}
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ spec:
checksum/configd-files: {{ include (print $.Template.BasePath "/generated/ConfigMap-etc-clickhouse-operator-configd-files.yaml") . | sha256sum }}
checksum/templatesd-files: {{ include (print $.Template.BasePath "/generated/ConfigMap-etc-clickhouse-operator-templatesd-files.yaml") . | sha256sum }}
checksum/usersd-files: {{ include (print $.Template.BasePath "/generated/ConfigMap-etc-clickhouse-operator-usersd-files.yaml") . | sha256sum }}
checksum/etc-keeper-operator-confd-files: {{ include (print $.Template.BasePath "/generated/ConfigMap-etc-clickhouse-operator-etc-keeper-operator-confd-files.yaml") . | sha256sum }}
checksum/etc-keeper-operator-configd-files: {{ include (print $.Template.BasePath "/generated/ConfigMap-etc-clickhouse-operator-etc-keeper-operator-configd-files.yaml") . | sha256sum }}
checksum/etc-keeper-operator-templatesd-files: {{ include (print $.Template.BasePath "/generated/ConfigMap-etc-clickhouse-operator-etc-keeper-operator-templatesd-files.yaml") . | sha256sum }}
checksum/etc-keeper-operator-usersd-files: {{ include (print $.Template.BasePath "/generated/ConfigMap-etc-clickhouse-operator-etc-keeper-operator-usersd-files.yaml") . | sha256sum }}
checksum/keeper-confd-files: {{ include (print $.Template.BasePath "/generated/ConfigMap-etc-keeper-operator-confd-files.yaml") . | sha256sum }}
checksum/keeper-configd-files: {{ include (print $.Template.BasePath "/generated/ConfigMap-etc-keeper-operator-configd-files.yaml") . | sha256sum }}
checksum/keeper-templatesd-files: {{ include (print $.Template.BasePath "/generated/ConfigMap-etc-keeper-operator-templatesd-files.yaml") . | sha256sum }}
checksum/keeper-usersd-files: {{ include (print $.Template.BasePath "/generated/ConfigMap-etc-keeper-operator-usersd-files.yaml") . | sha256sum }}
spec:
serviceAccountName: {{ include "altinity-clickhouse-operator.serviceAccountName" . }}
volumes:
Expand All @@ -53,16 +53,16 @@ spec:
name: {{ include "altinity-clickhouse-operator.fullname" . }}-usersd-files
- name: etc-keeper-operator-confd-folder
configMap:
name: etc-keeper-operator-confd-files
name: {{ include "altinity-clickhouse-operator.fullname" . }}-keeper-confd-files
- name: etc-keeper-operator-configd-folder
configMap:
name: etc-keeper-operator-configd-files
name: {{ include "altinity-clickhouse-operator.fullname" . }}-keeper-configd-files
- name: etc-keeper-operator-templatesd-folder
configMap:
name: etc-keeper-operator-templatesd-files
name: {{ include "altinity-clickhouse-operator.fullname" . }}-keeper-templatesd-files
- name: etc-keeper-operator-usersd-folder
configMap:
name: etc-keeper-operator-usersd-files
name: {{ include "altinity-clickhouse-operator.fullname" . }}-keeper-usersd-files
containers:
- name: {{ .Chart.Name }}
image: {{ .Values.operator.image.repository }}:{{ include "altinity-clickhouse-operator.operator.tag" . }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ metadata:
namespace: {{ .Release.Namespace }}
labels: {{ include "altinity-clickhouse-operator.labels" . | nindent 4 }}
annotations: {{ toYaml .Values.serviceAccount.annotations | nindent 4 }}

# Template Parameters:
#
# NAMESPACE=kube-system
Expand Down
8 changes: 4 additions & 4 deletions deploy/helm/clickhouse-operator/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -697,8 +697,8 @@ configs:
</default>
</profiles>
</yandex>
etcKeeperOperatorConfdFiles: null
etcKeeperOperatorConfigdFiles:
keeperConfdFiles: null
keeperConfigdFiles:
01-keeper-01-default-config.xml: |
<!-- IMPORTANT -->
<!-- This file is auto-generated -->
Expand Down Expand Up @@ -759,10 +759,10 @@ configs:
</http_control>
</keeper_server>
</clickhouse>
etcKeeperOperatorTemplatesdFiles:
keeperTemplatesdFiles:
readme: |-
Templates in this folder are packaged with an operator and available via 'useTemplate'
etcKeeperOperatorUsersdFiles: null
keeperUsersdFiles: null
# additionalResources -- list of additional resources to create (are processed via `tpl` function), useful for create ClickHouse clusters together with clickhouse-operator, look `kubectl explain chi` for details

additionalResources: []
Expand Down
15 changes: 9 additions & 6 deletions dev/generate_helm_chart.sh
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,11 @@ function update_deployment_resource() {
for cm in $(yq e '.spec.template.spec.volumes[].configMap.name' "${file}"); do
local prefix='{{ include \"altinity-clickhouse-operator.fullname\" . }}'
local newCm="${cm/etc-clickhouse-operator/$prefix}"
newCm="${newCm/etc-keeper-operator/${prefix}-keeper}"
yq e -i '(.spec.template.spec.volumes[].configMap.name | select(. == "'"${cm}"'") | .) |= "'"${newCm}"'"' "${file}"
local cmName="${cm/etc-clickhouse-operator-/}"
yq e -i '.spec.template.metadata.annotations += {"checksum/'"${cmName}"'": "{{ include (print $.Template.BasePath \"/generated/ConfigMap-etc-clickhouse-operator-'"${cmName}"'.yaml\") . | sha256sum }}"}' "${file}"
cmName="${cmName/etc-keeper-operator-/keeper-}"
yq e -i '.spec.template.metadata.annotations += {"checksum/'"${cmName}"'": "{{ include (print $.Template.BasePath \"/generated/ConfigMap-'"${cm}"'.yaml\") . | sha256sum }}"}' "${file}"
done

yq e -i '.spec.template.spec.containers[0].name |= "{{ .Chart.Name }}"' "${file}"
Expand Down Expand Up @@ -245,18 +247,19 @@ function update_configmap_resource() {
fi

local name_suffix="${name/etc-clickhouse-operator-/}"
local cameled_name
cameled_name=$(to_camel_case "${name_suffix}")
local name_suffix="${name_suffix/etc-keeper-operator-/keeper-}"
local camel_cased_name
camel_cased_name=$(to_camel_case "${name_suffix}")

yq e -i '.metadata.name |= "{{ printf \"%s-'"${name_suffix}"'\" (include \"altinity-clickhouse-operator.fullname\" .) }}"' "${file}"
yq e -i '.metadata.namespace |= "{{ .Release.Namespace }}"' "${file}"
yq e -i '.metadata.labels |= "{{ include \"altinity-clickhouse-operator.labels\" . | nindent 4 }}"' "${file}"
yq e -i '.data |= "{{ include \"altinity-clickhouse-operator.configmap-data\" (list . .Values.configs.'"${cameled_name}"') | nindent 2 }}"' "${file}"
yq e -i '.data |= "{{ include \"altinity-clickhouse-operator.configmap-data\" (list . .Values.configs.'"${camel_cased_name}"') | nindent 2 }}"' "${file}"

if [ -z "${data}" ]; then
yq e -i '.configs.'"${cameled_name}"' |= null' "${values_yaml}"
yq e -i '.configs.'"${camel_cased_name}"' |= null' "${values_yaml}"
else
data_arg="${data}" yq e -i '.configs.'"${cameled_name}"' |= env(data_arg)' "${values_yaml}"
data_arg="${data}" yq e -i '.configs.'"${camel_cased_name}"' |= env(data_arg)' "${values_yaml}"
fi

perl -pi -e "s/'//g" "${file}"
Expand Down

0 comments on commit 2a829e9

Please sign in to comment.