Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update helm chart generator to treat config.yaml as yaml in values #1317

Merged
merged 1 commit into from
Jan 28, 2024
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
16 changes: 16 additions & 0 deletions deploy/helm/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,19 @@ metadata:
labels:
{{- include "altinity-clickhouse-operator.labels" . | nindent 4 }}
{{- end }}

{{/*
*/}}
{{- define "altinity-clickhouse-operator.configmap-data" }}
{{- $root := index . 0 }}
{{- $data := index . 1 }}
{{- if not $data -}}
null
{{ end }}
{{- range $k, $v := $data }}
{{- if not (kindIs "string" $v) }}
{{- $v = toYaml $v }}
{{- end }}
{{- tpl (toYaml (dict $k $v)) $root }}
{{ end }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ metadata:
name: {{ printf "%s-confd-files" (include "altinity-clickhouse-operator.fullname" .) }}
namespace: {{ .Release.Namespace }}
labels: {{ include "altinity-clickhouse-operator.labels" . | nindent 4 }}
data: {{ tpl (toYaml .Values.configs.confdFiles) . | nindent 2 }}
data: {{ include "altinity-clickhouse-operator.configmap-data" (list . .Values.configs.confdFiles) | nindent 2 }}
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ metadata:
name: {{ printf "%s-configd-files" (include "altinity-clickhouse-operator.fullname" .) }}
namespace: {{ .Release.Namespace }}
labels: {{ include "altinity-clickhouse-operator.labels" . | nindent 4 }}
data: {{ tpl (toYaml .Values.configs.configdFiles) . | nindent 2 }}
data: {{ include "altinity-clickhouse-operator.configmap-data" (list . .Values.configs.configdFiles) | nindent 2 }}
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ metadata:
name: {{ printf "%s-files" (include "altinity-clickhouse-operator.fullname" .) }}
namespace: {{ .Release.Namespace }}
labels: {{ include "altinity-clickhouse-operator.labels" . | nindent 4 }}
data: {{ tpl (toYaml .Values.configs.files) . | nindent 2 }}
data: {{ include "altinity-clickhouse-operator.configmap-data" (list . .Values.configs.files) | nindent 2 }}
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ metadata:
name: {{ printf "%s-templatesd-files" (include "altinity-clickhouse-operator.fullname" .) }}
namespace: {{ .Release.Namespace }}
labels: {{ include "altinity-clickhouse-operator.labels" . | nindent 4 }}
data: {{ tpl (toYaml .Values.configs.templatesdFiles) . | nindent 2 }}
data: {{ include "altinity-clickhouse-operator.configmap-data" (list . .Values.configs.templatesdFiles) | nindent 2 }}
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ metadata:
name: {{ printf "%s-usersd-files" (include "altinity-clickhouse-operator.fullname" .) }}
namespace: {{ .Release.Namespace }}
labels: {{ include "altinity-clickhouse-operator.labels" . | nindent 4 }}
data: {{ tpl (toYaml .Values.configs.usersdFiles) . | nindent 2 }}
data: {{ include "altinity-clickhouse-operator.configmap-data" (list . .Values.configs.usersdFiles) | nindent 2 }}
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
26 changes: 2 additions & 24 deletions deploy/helm/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ configs:
</trace_log>
</yandex>
files:
config.yaml: |-
config.yaml:
# IMPORTANT
# This file is auto-generated
# Do not edit this file - all changes would be lost
Expand All @@ -196,7 +196,6 @@ configs:
# Regexp is applicable.
#namespaces: ["dev", "test"]
namespaces: []

clickhouse:
configuration:
################################################
Expand Down Expand Up @@ -254,7 +253,6 @@ configs:
network:
# Default host_regexp to limit network connectivity from outside
hostRegexpTemplate: "(chi-{chi}-[^.]+\\d+-\\d+|clickhouse\\-{chi})\\.{namespace}\\.svc\\.cluster\\.local$"

################################################
##
## Configuration restart policy section
Expand All @@ -279,19 +277,15 @@ configs:
- settings/max_concurrent_queries: "no"
- settings/models_config: "no"
- settings/user_defined_executable_functions_config: "no"

- zookeeper/*: "yes"

- files/*.xml: "yes"
- files/config.d/*.xml: "yes"
- files/config.d/*dict*.xml: "no"

- profiles/default/background_*_pool_size: "yes"
- profiles/default/max_*_for_server: "yes"
- version: "21.*"
rules:
- settings/logger: "yes"

#################################################
##
## Access to ClickHouse instances
Expand All @@ -313,7 +307,6 @@ configs:
username: ""
password: ""
rootCA: ""

# Location of the k8s Secret with username and password to be used by the operator to connect to ClickHouse instances.
# Can be used instead of explicitly specified username and password available in sections:
# - clickhouse.access.username
Expand All @@ -325,24 +318,21 @@ configs:
# Empty `namespace` means that k8s secret would be looked in the same namespace where operator's pod is running.
namespace: ""
# Empty `name` means no k8s Secret would be looked for
name: "{{ include "altinity-clickhouse-operator.fullname" . }}"
name: '{{ include "altinity-clickhouse-operator.fullname" . }}'
# Port where to connect to ClickHouse instances to
port: 8123

# Timeouts used to limit connection and queries from the operator to ClickHouse instances
# Specified in seconds.
timeouts:
# Timout to setup connection from the operator to ClickHouse instances. In seconds.
connect: 1
# Timout to perform SQL query from the operator to ClickHouse instances. In seconds.
query: 4

#################################################
##
## Metrics collection
##
################################################

metrics:
# Timeouts used to limit connection and queries from the metrics exporter to ClickHouse instances
# Specified in seconds.
Expand All @@ -351,7 +341,6 @@ configs:
# Upon reaching this timeout metrics collection is aborted and no more metrics are collected in this cycle.
# All collected metrics are returned.
collect: 9

################################################
##
## Template(s) management section
Expand All @@ -364,12 +353,10 @@ configs:
# - ReadOnStart. Accept CHIT updates on the operators start only.
# - ApplyOnNextReconcile. Accept CHIT updates at all time. Apply news CHITs on next regular reconcile of the CHI
policy: ApplyOnNextReconcile

# Path to the folder where ClickHouseInstallation templates .yaml manifests are located.
# Templates are added to the list of all templates and used when CHI is reconciled.
# Templates are applied in sorted alpha-numeric order.
path: templates.d

################################################
##
## Reconcile section
Expand All @@ -380,7 +367,6 @@ configs:
runtime:
# Max number of concurrent CHI reconciles in progress
reconcileCHIsThreadsNumber: 10

# The operator reconciles shards concurrently in each CHI with the following limitations:
# 1. Number of shards being reconciled (and thus having hosts down) in each CHI concurrently
# can not be greater than 'reconcileShardsThreadsNumber'.
Expand All @@ -393,7 +379,6 @@ configs:
reconcileShardsThreadsNumber: 5
# Max percentage of concurrent shard reconciles within one CHI in progress
reconcileShardsMaxConcurrencyPercent: 50

# Reconcile StatefulSet scenario
statefulSet:
# Create StatefulSet scenario
Expand All @@ -406,7 +391,6 @@ configs:
# 2. delete - delete newly created problematic StatefulSet and follow 'abort' path afterwards.
# 3. ignore - ignore an error, pretend nothing happened, continue reconcile and move on to the next StatefulSet.
onFailure: ignore

# Update StatefulSet scenario
update:
# How many seconds to wait for created/updated StatefulSet to be 'Ready'
Expand All @@ -423,7 +407,6 @@ configs:
# Follow 'abort' path afterwards.
# 3. ignore - ignore an error, pretend nothing happened, continue reconcile and move on to the next StatefulSet.
onFailure: abort

# Reconcile Host scenario
host:
# Whether the operator during reconcile procedure should wait for a ClickHouse host:
Expand All @@ -435,7 +418,6 @@ configs:
exclude: true
queries: true
include: false

################################################
##
## Annotations management section
Expand All @@ -450,7 +432,6 @@ configs:
include: []
# Exclude annotations from the following list:
exclude: []

################################################
##
## Labels management section
Expand Down Expand Up @@ -479,15 +460,13 @@ configs:
# LabelClusterScopeCycleIndex
# LabelClusterScopeCycleOffset
appendScope: "no"

################################################
##
## StatefulSet management section
##
################################################
statefulSet:
revisionHistoryLimit: 0

################################################
##
## Pod management section
Expand All @@ -499,7 +478,6 @@ configs:
# SIGTERM and SIGKILL during Pod termination process.
# Increase this number is case of slow shutdown.
terminationGracePeriod: 30

################################################
##
## Log parameters section
Expand Down
10 changes: 7 additions & 3 deletions dev/generate_helm_chart.sh
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,12 @@ function update_configmap_resource() {
data=$(yq e '.data' "${file}")

if [ "${name}" = "etc-clickhouse-operator-files" ]; then
readonly search='name: "clickhouse-operator"'
readonly replace='name: "{{ include "altinity-clickhouse-operator.fullname" . }}"'
local search='name: "clickhouse-operator"'
local replace="name: '{{ include \"altinity-clickhouse-operator.fullname\" . }}'"
data=${data/"${search}"/"${replace}"}

search='config.yaml: |'
replace='config.yaml:'
data=${data/"${search}"/"${replace}"}
fi

Expand All @@ -241,7 +245,7 @@ function update_configmap_resource() {
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 |= "{{ tpl (toYaml .Values.configs.'"${cameled_name}"') . | nindent 2 }}"' "${file}"
yq e -i '.data |= "{{ include \"altinity-clickhouse-operator.configmap-data\" (list . .Values.configs.'"${cameled_name}"') | nindent 2 }}"' "${file}"

if [ -z "${data}" ]; then
yq e -i '.configs.'"${cameled_name}"' |= null' "${values_yaml}"
Expand Down