8000 feat(helm): allow readiness and liveness probes for operator containers by janeklb · Pull Request #1976 · Altinity/clickhouse-operator · GitHub
[go: up one dir, main page]

Skip to content
8000
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
4 changes: 4 additions & 0 deletions deploy/helm/clickhouse-operator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ crdHook:
| metrics.image.registry | string | `""` | optional image registry prefix (e.g. 1234567890.dkr.ecr.us-east-1.amazonaws.com) |
| metrics.image.repository | string | `"altinity/metrics-exporter"` | image repository |
| metrics.image.tag | string | `""` | image tag (chart's appVersion value will be used if not set) |
| metrics.livenessProbe | string | `nil` | optional liveness probe for the metrics-exporter container check `kubectl explain pod.spec.containers.livenessProbe` for details example: httpGet: path: /metrics port: ch-metrics initialDelaySeconds: 10 periodSeconds: 10 |
| metrics.readinessProbe | string | `nil` | optional readiness probe for the metrics-exporter container check `kubectl explain pod.spec.containers.readinessProbe` for details example: httpGet: path: /metrics port: ch-metrics initialDelaySeconds: 5 periodSeconds: 5 |
| metrics.resources | object | `{}` | custom resource configuration |
| nameOverride | string | `""` | override name of the chart |
| namespaceOverride | string | `""` | |
Expand All @@ -108,7 +110,9 @@ crdHook:
| operator.image.registry | string | `""` | optional image registry prefix (e.g. 1234567890.dkr.ecr.us-east-1.amazonaws.com) |
| operator.image.repository | string | `"altinity/clickhouse-operator"` | image repository |
| operator.image.tag | string | `""` | image tag (chart's appVersion value will be used if not set) |
| operator.livenessProbe | string | `nil` | optional liveness probe for the clickhouse-operator container check `kubectl explain pod.spec.containers.livenessProbe` for details example: httpGet: path: /metrics port: op-metrics initialDelaySeconds: 10 periodSeconds: 10 |
| operator.priorityClassName | string | "" | priority class name for the clickhouse-operator deployment, check `kubectl explain pod.spec.priorityClassName` for details |
| operator.readinessProbe | string | `nil` | optional readiness probe for the clickhouse-operator container check `kubectl explain pod.spec.containers.readinessProbe` for details example: httpGet: path: /metrics port: op-metrics initialDelaySeconds: 5 periodSeconds: 5 |
8000 | operator.resources | object | `{}` | custom resource configuration, check `kubectl explain pod.spec.containers.resources` for details |
| podAnnotations | object | check the `values.yaml` file | annotations to add to the clickhouse-operator pod, check `kubectl explain pod.spec.annotations` for details |
| podLabels | object | `{}` | labels to add to the clickhouse-operator pod |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ subjects:
- kind: ServiceAccount
name: {{ include "altinity-clickhouse-operator.serviceAccountName" . }}
namespace: {{ include "altinity-clickhouse-operator.namespace" . }}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this whitespace (and below) was removed as part of running ./dev/generate_helm_chart.sh

# Template Parameters:
#
# NAMESPACE=kube-system
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,12 @@ spec:
name: op-metrics
resources: {{ toYaml .Values.operator.resources | nindent 12 }}
securityContext: {{ toYaml .Values.operator.containerSecurityContext | nindent 12 }}
{{- with .Values.operator.livenessProbe }}
livenessProbe: {{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.operator.readinessProbe }}
readinessProbe: {{- toYaml . | nindent 12 }}
{{- end }}
{{ if .Values.metrics.enabled }}
- name: metrics-exporter
image: {{ if .Values.metrics.image.registry }}{{ .Values.metrics.image.registry | trimSuffix "/" }}/{{ end }}{{ .Values.metrics.image.repository }}:{{ include "altinity-clickhouse-operator.metrics.tag" . }}
Expand Down Expand Up @@ -220,6 +226,12 @@ spec:
name: ch-metrics
resources: {{ toYaml .Values.metrics.resources | nindent 12 }}
securityContext: {{ toYaml .Values.metrics.containerSecurityContext | nindent 12 }}
{{- with .Values.metrics.livenessProbe }}
livenessProbe: {{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.metrics.readinessProbe }}
readinessProbe: {{- toYaml . | nindent 12 }}
{{- end }}
{{ end }}
imagePullSecrets: {{ toYaml .Values.imagePullSecrets | nindent 8 }}
{{ if .Values.operator.priorityClassName }}priorityClassName: {{ .Values.operator.priorityClassName | quote }}{{ end }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ metadata:
namespace: {{ include "altinity-clickhouse-operator.namespace" . }}
labels: {{ include "altinity-clickhouse-operator.labels" . | nindent 4 }}
annotations: {{ include "altinity-clickhouse-operator.annotations" . | nindent 4 }}{{ if .Values.serviceAccount.annotations }}{{ toYaml .Values.serviceAccount.annotations | nindent 4 }}{{ end }}

# Template Parameters:
#
# NAMESPACE=kube-system
Expand Down
16 changes: 16 additions & 0 deletions deploy/helm/clickhouse-operator/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -694,6 +694,14 @@
"description": "additional environment variables for the deployment of metrics-exporter containers possible format value `[{\"name\": \"SAMPLE\", \"value\": \"text\"}]`",
"type": "array"
},
"livenessProbe": {
"description": "optional liveness probe for the metrics-exporter container, check `kubectl explain pod.spec.containers.livenessProbe` for details",
"type": ["object", "null"]
},
"readinessProbe": {
"description": "optional readiness probe for the metrics-exporter container, check `kubectl explain pod.spec.containers.readinessProbe` for details",
"type": ["object", "null"]
},
"image": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -738,6 +746,10 @@
"description": "additional environment variables for the clickhouse-operator container in deployment possible format value `[{\"name\": \"SAMPLE\", \"value\": \"text\"}]`",
"type": "array"
},
"livenessProbe": {
"description": "optional liveness probe for the clickhouse-operator container, check `kubectl explain pod.spec.containers.livenessProbe` for details",
"type": ["object", "null"]
},
"image": {
"type": "object",
"properties": {
Expand All @@ -759,6 +771,10 @@
"description": "priority class name for the clickhouse-operator deployment, check `kubectl explain pod.spec.priorityClassName` for details",
"type": "string"
},
"readinessProbe": {
"description": "optional readiness probe for the clickhouse-operator container, check `kubectl explain pod.spec.containers.readinessProbe` for details",
"type": ["object", "null"]
},
"resources": {
"description": "custom resource configuration, check `kubectl explain pod.spec.containers.resources` for details",
"type": "object"
Expand Down
36 changes: 36 additions & 0 deletions deploy/helm/clickhouse-operator/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,24 @@ operator:
# operator.env -- additional environment variables for the clickhouse-operator container in deployment
# possible format value `[{"name": "SAMPLE", "value": "text"}]`
env: []
# operator.livenessProbe -- optional liveness probe for the clickhouse-operator container
# check `kubectl explain pod.spec.containers.livenessProbe` for details
# example:
# httpGet:
# path: /metrics
# port: op-metrics
# initialDelaySeconds: 10
# periodSeconds: 10
livenessProbe: null
# operator.readinessProbe -- optional readiness probe for the clickhouse-operator container
# check `kubectl explain pod.spec.containers.readinessProbe` for details
# example:
# httpGet:
# path: /metrics
# port: op-metrics
# initialDelaySeconds: 5
# periodSeconds: 5
readinessProbe: null
metrics:
enabled: true
image:
Expand All @@ -88,6 +106,24 @@ metrics:
# metrics.env -- additional environment variables for the deployment of metrics-exporter containers
# possible format value `[{"name": "SAMPLE", "value": "text"}]`
env: []
# metrics.livenessProbe -- optional liveness probe for the metrics-exporter container
# check `kubectl explain pod.spec.containers.livenessProbe` for details
# example:
# httpGet:
# path: /metrics
# port: ch-metrics
# initialDelaySeconds: 10
# periodSeconds: 10
livenessProbe: null
# metrics.readinessProbe -- optional readiness probe for the metrics-exporter container
# check `kubectl explain pod.spec.containers.readinessProbe` for details
# example:
# httpGet:
# path: /metrics
# port: ch-metrics
# initialDelaySeconds: 5
# periodSeconds: 5
readinessProbe: null
# imagePullSecrets -- image pull secret for private images in clickhouse-operator pod
# possible value format `[{"name":"your-secret-name"}]`,
# check `kubectl explain pod.spec.imagePullSecrets` for details
Expand Down
8 changes: 8 additions & 0 deletions dev/generate_helm_chart.sh
Original file line number Diff line number Diff line change
Expand Up @@ -231,18 +231,26 @@ function update_deployment_resource() {
yq e -i '.spec.template.spec.containers[0].securityContext |= "{{ toYaml .Values.operator.containerSecurityContext | nindent 12 }}"' "${file}"
yq e -i '(.spec.template.spec.containers[0].env[] | select(.valueFrom.resourceFieldRef.containerName == "clickhouse-operator") | .valueFrom.resourceFieldRef.containerName) = "{{ .Chart.Name }}"' "${file}"
yq e -i '.spec.template.spec.containers[0].env += ["{{ with .Values.operator.env }}{{ toYaml . | nindent 12 }}{{ end }}"]' "${file}"
yq e -i '.spec.template.spec.containers[0] += {"__OPERATOR_LIVENESS_PROBE__": null}' "${file}"
yq e -i '.spec.template.spec.containers[0] += {"__OPERATOR_READINESS_PROBE__": null}' "${file}"

yq e -i '.spec.template.spec.containers[1].image |= "{{ if .Values.metrics.image.registry }}{{ .Values.metrics.image.registry | trimSuffix \"/\" }}/{{ end }}{{ .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].securityContext |= "{{ toYaml .Values.metrics.containerSecurityContext | 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}"
yq e -i '.spec.template.spec.containers[1] += {"__METRICS_LIVENESS_PROBE__": null}' "${file}"
yq e -i '.spec.template.spec.containers[1] += {"__METRICS_READINESS_PROBE__": null}' "${file}"

perl -pi -e "s/'{{ if .Values.podAnnotations }}{{ toYaml .Values.podAnnotations \| nindent 8 }}{{ end }}': null/{{ if .Values.podAnnotations }}{{ toYaml .Values.podAnnotations \| nindent 8 }}{{ end }}/g" "${file}"
perl -pi -e "s/'{{ if .Values.operator.priorityClassName }}priorityClassName: {{ .Values.operator.priorityClassName \| quote }}{{ end }}': null/{{ if .Values.operator.priorityClassName }}priorityClassName: {{ .Values.operator.priorityClassName | quote }}{{ end }}/g" "${file}"
perl -pi -e "s/- '{{ with .Values.operator.env }}{{ toYaml . \| nindent 12 }}{{ end }}'/{{ with .Values.operator.env }}{{ toYaml . \| nindent 12 }}{{ end }}/g" "${file}"
perl -pi -e "s/- '{{ with .Values.metrics.env }}{{ toYaml . \| nindent 12 }}{{ end }}'/{{ with .Values.metrics.env }}{{ toYaml . \| nindent 12 }}{{ end }}/g" "${file}"
perl -0pi -e 's/\n\s*__OPERATOR_LIVENESS_PROBE__: null/\n {{- with .Values.operator.livenessProbe }}\n livenessProbe: {{- toYaml . | nindent 12 }}\n {{- end }}/g' "${file}"
perl -0pi -e 's/\n\s*__OPERATOR_READINESS_PROBE__: null/\n {{- with .Values.operator.readinessProbe }}\n readinessProbe: {{- toYaml . | nindent 12 }}\n {{- end }}/g' "${file}"
perl -0pi -e 's/\n\s*__METRICS_LIVENESS_PROBE__: null/\n {{- with .Values.metrics.livenessProbe }}\n livenessProbe: {{- toYaml . | nindent 12 }}\n {{- end }}/g' "${file}"
perl -0pi -e 's/\n\s*__METRICS_READINESS_PROBE__: null/\n {{- with .Values.metrics.readinessProbe }}\n readinessProbe: {{- toYaml . | nindent 12 }}\n {{- end }}/g' "${file}"
perl -pi -e 's/(\s+\- name: metrics-exporter)/{{ if .Values.metrics.enabled }}\n$1/g' "${file}"
perl -pi -e "s/(\s+imagePullSecrets: '\{\{ toYaml \.Values\.imagePullSecrets \| nindent 8 \}\}')/{{ end }}\n\$1/g" "${file}"
perl -pi -e "s/'//g" "${file}"
Expand Down
Loading
0