Skip to content

Commit

Permalink
upgrade altinity-clickhouse-operator
Browse files Browse the repository at this point in the history
  • Loading branch information
slamdev committed Nov 13, 2022
1 parent eb9f160 commit 4ea740e
Show file tree
Hide file tree
Showing 10 changed files with 485 additions and 826 deletions.
4 changes: 2 additions & 2 deletions charts/altinity-clickhouse-operator/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ description: |-
Refer to operator repo for additional information.
type: application
version: 0.1.1
appVersion: 0.19.3
version: 0.1.2
appVersion: 0.20.0
home: https://github.com/slamdev/helm-charts/tree/master/charts/altinity-clickhouse-operator
icon: https://artifacthub.io/image/2d6aa29c-c74f-4bff-bede-ba7e6e0315a7@2x
maintainers:
Expand Down
7 changes: 5 additions & 2 deletions charts/altinity-clickhouse-operator/README.md

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ kind: CustomResourceDefinition
metadata:
name: clickhouseoperatorconfigurations.clickhouse.altinity.com
labels:
clickhouse.altinity.com/chop: 0.19.3
clickhouse.altinity.com/chop: 0.20.0
spec:
group: clickhouse.altinity.com
scope: Namespaced
Expand Down Expand Up @@ -51,6 +51,7 @@ spec:
properties:
watch:
type: object
description: "Parameters for watch kubernetes resources which used by clickhouse-operator deployment"
properties:
namespaces:
type: array
Expand All @@ -59,6 +60,7 @@ spec:
type: string
clickhouse:
type: object
description: "Clickhouse related parameters used by clickhouse-operator"
properties:
configuration:
type: object
Expand All @@ -77,9 +79,10 @@ spec:
description: "Path to the folder where ClickHouse configuration files unique for each instance (host) within a CHI are located. Default - conf.d"
user:
type: string
description: "Path to the folder where ClickHouse configuration files with users settings are located. Files are common for all instances within a CHI."
description: "Path to the folder where ClickHouse configuration files with users settings are located. Files are common for all instances within a CHI. Default - users.d"
user:
type: object
description: "Default parameters for any user which will create"
properties:
default:
type: object
Expand All @@ -100,12 +103,14 @@ spec:
description: "ClickHouse server configuration `<password>...</password>` for any <user>"
network:
type: object
description: "Default network parameters for any user which will create"
properties:
hostRegexpTemplate:
type: string
description: "ClickHouse server configuration `<host_regexp>...</host_regexp>` for any <user>"
access:
type: object
description: "parameters which use for connect to clickhouse from clickhouse-operator deployment"
properties:
scheme:
type: string
Expand All @@ -132,9 +137,24 @@ spec:
type: integer
minimum: 1
maximum: 65535
description: "port to be used by operator to connect to ClickHouse instances"
description: "Port to be used by operator to connect to ClickHouse instances"
timeouts:
type: object
description: "Timeouts used to limit connection and queries from the operator to ClickHouse instances, In seconds"
properties:
connect:
type: integer
minimum: 1
maximum: 10
description: "Connect timeout. In seconds."
query:
type: integer
minimum: 1
maximum: 600
description: "Query timeout. In seconds."
template:
type: object
description: "Parameters which are used if you want to generate ClickHouseInstallationTemplate custom resources from files which are stored inside clickhouse-operator deployment"
properties:
chi:
type: object
Expand All @@ -144,9 +164,11 @@ spec:
description: "Path to folder where ClickHouseInstallationTemplate .yaml manifests are located."
reconcile:
type: object
description: "allow tuning reconciling process"
properties:
runtime:
type: object
description: "runtime parameters for clickhouse-operator process which use during reconciling"
properties:
threadsNumber:
type: integer
Expand All @@ -155,9 +177,11 @@ spec:
description: "How many goroutines will be used to reconcile in parallel, 10 by default"
statefulSet:
type: object
description: "Allow change default behavior for reconciling StatefulSet which generated by clickhouse-operator"
properties:
create:
type: object
description: "Behavior during create StatefulSet"
properties:
onFailure:
type: string
Expand All @@ -169,6 +193,7 @@ spec:
3. ignore (default) - ignore error, pretend nothing happened and move on to the next StatefulSet.
update:
type: object
description: "Behavior during update StatefulSet"
properties:
timeout:
type: integer
Expand All @@ -186,30 +211,69 @@ spec:
3. ignore - ignore error, pretend nothing happened and move on to the next StatefulSet.
host:
type: object
description: "allow define how to wait host include to system.cluster behavior during scale up and scale down cluster operations"
properties:
wait:
type: object
properties:
exclude:
type: boolean
exclude: &TypeStringBool
type: string
description: "wait when a pod will be removed from the cluster"
enum:
# List StringBoolXXX constants from model
- ""
- "0"
- "1"
- "False"
- "false"
- "True"
- "true"
- "No"
- "no"
- "Yes"
- "yes"
- "Off"
- "off"
- "On"
- "on"
- "Disable"
- "disable"
- "Enable"
- "enable"
- "Disabled"
- "disabled"
- "Enabled"
- "enabled"
include:
type: boolean
!!merge <<: *TypeStringBool
description: "wait when a pod will be added to the cluster"
annotation:
type: object
description: "defines which metadata.annotations items will include or exclude during render StatefulSet, Pod, PVC resources"
properties:
include:
type: array
description: |
When propagating labels from the chi's `metadata.annotations` section to child objects' `metadata.annotations`,
include annotations with names from the following list
items:
type: string
exclude:
type: array
description: |
When propagating labels from the chi's `metadata.annotations` section to child objects' `metadata.annotations`,
exclude annotations with names from the following list
items:
type: string
label:
type: object
description: "defines which metadata.labels will include or exclude during render StatefulSet, Pod, PVC resources"
properties:
include:
type: array
description: |
When propagating labels from the chi's `metadata.labels` section to child objects' `metadata.labels`,
include labels from the following list
items:
type: string
exclude:
Expand All @@ -220,7 +284,7 @@ spec:
When propagating labels from the chi's `metadata.labels` section to child objects' `metadata.labels`,
exclude labels from the following list
appendScope:
type: string
!!merge <<: *TypeStringBool
description: |
Whether to append *Scope* labels to StatefulSet and Pod
- "LabelShardScopeIndex"
Expand All @@ -233,43 +297,23 @@ spec:
- "LabelClusterScopeCycleSize"
- "LabelClusterScopeCycleIndex"
- "LabelClusterScopeCycleOffset"
enum:
# List StringBoolXXX constants from model
- ""
- "0"
- "1"
- "False"
- "false"
- "True"
- "true"
- "No"
- "no"
- "Yes"
- "yes"
- "Off"
- "off"
- "On"
- "on"
- "Disable"
- "disable"
- "Enable"
- "enable"
- "Disabled"
- "disabled"
- "Enabled"
- "enabled"
statefulSet:
type: object
description: "define StatefulSet-specific parameters"
properties:
revisionHistoryLimit:
type: integer
description: "revisionHistoryLimit is the maximum number of revisions that will be\nmaintained in the StatefulSet's revision history. \nLook details in `statefulset.spec.revisionHistoryLimit`\n"
pod:
type: object
description: "define pod specific parameters"
properties:
terminationGracePeriod:
type: integer
description: "Optional duration in seconds the pod needs to terminate gracefully. \nLook details in `pod.spec.terminationGracePeriodSeconds`\n"
logger:
type: object
description: "allow setup clickhouse-operator logger behavior"
properties:
logtostderr:
type: string
Expand Down
34 changes: 34 additions & 0 deletions charts/altinity-clickhouse-operator/hacks/sync-yamls.sh
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ function process() {
ServiceAccount)
update_serviceaccount_resource "${processed_file}"
;;
Secret)
update_secret_resource "${processed_file}"
;;
CustomResourceDefinition) ;;

*)
Expand Down Expand Up @@ -151,6 +154,7 @@ function update_deployment_resource() {
yq e -i '.spec.template.spec.containers[1].image |= "{{ .Values.metrics.image.repository }}:{{ include \"altinity-clickhouse-operator.metrics.tag\" . }}"' "${file}"
yq e -i '.spec.template.spec.containers[1].imagePullPolicy |= "{{ .Values.metrics.image.pullPolicy }}"' "${file}"
yq e -i '.spec.template.spec.containers[1].resources |= "{{ toYaml .Values.metrics.resources | nindent 12 }}"' "${file}"
yq e -i '(.spec.template.spec.containers[1].env[] | select(.valueFrom.resourceFieldRef.containerName == "clickhouse-operator") | .valueFrom.resourceFieldRef.containerName) = "{{ .Chart.Name }}"' "${file}"
yq e -i '.spec.template.spec.containers[1].env += ["{{ with .Values.metrics.env }}{{ toYaml . | nindent 12 }}{{ end }}"]' "${file}"

perl -pi -e "s/'{{ toYaml .Values.podAnnotations \| nindent 8 }}': null/{{ toYaml .Values.podAnnotations \| nindent 8 }}/g" "${file}"
Expand Down Expand Up @@ -239,6 +243,36 @@ function update_serviceaccount_resource() {
perl -pi -e "s/'//g" "${file}"
}

function update_secret_resource() {
readonly file="${1}"
readonly name=$(yq e '.metadata.name' "${file}")

if [ "${name}" != 'clickhouse-operator' ]; then
echo "do not know how to process ${name} secret"
exit 1
fi

yq e -i '.metadata.name |= "{{ 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.username |= "{{ .Values.secret.username | b64enc }}"' "${file}"
yq e -i '.data.password |= "{{ .Values.secret.password | b64enc }}"' "${file}"

readonly username=$(yq e '.stringData.username' "${file}")
yq e -i '.secret.username |= "'"${username}"'"' "${values_yaml}"

readonly password=$(yq e '.stringData.password' "${file}")
yq e -i '.secret.password |= "'"${password}"'"' "${values_yaml}"

yq e -i 'del(.stringData)' "${file}"

printf '%s\n%s\n' '{{- if .Values.secret.create -}}' "$(cat "${file}")" >"${file}"
printf '%s\n%s\n' "$(cat "${file}")" '{{- end -}}' >"${file}"

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

function to_camel_case() {
readonly str="${1}"
echo "${str}" | awk -F - '{printf "%s", $1; for(i=2; i<=NF; i++) printf "%s", toupper(substr($i,1,1)) substr($i,2); print"";}'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ rules:
resources:
- configmaps
- services
- persistentvolumeclaims
verbs:
- get
- list
Expand All @@ -42,17 +43,6 @@ rules:
- events
verbs:
- create
- apiGroups:
- ""
resources:
- persistentvolumeclaims
verbs:
- get
- list
- patch
- update
- watch
- delete
- apiGroups:
- ""
resources:
Expand Down
Loading

0 comments on commit 4ea740e

Please sign in to comment.