CHART NAME: {{ .Chart.Name }}
CHART VERSION: {{ .Chart.Version }}
APP VERSION: {{ .Chart.AppVersion }}

⚠ WARNING: Since August 28th, 2025, only a limited subset of images/charts are available for free.
    Subscribe to Bitnami Secure Images to receive continued support and security updates.
    More info at https://bitnami.com and https://github.com/bitnami/containers/issues/83267

** Please be patient while the chart is being deployed **

{{- if .Values.diagnosticMode.enabled }}
The chart has been deployed in diagnostic mode. All probes have been disabled and the command has been overwritten with:

  command: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.command "context" $) | nindent 4 }}
  args: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.args "context" $) | nindent 4 }}

Get the list of pods by executing:

  kubectl get pods --namespace {{ include "common.names.namespace" . | quote }} -l app.kubernetes.io/instance={{ .Release.Name }}

Access the pod you want to debug by executing

  kubectl exec --namespace {{ include "common.names.namespace" . | quote }} -ti <NAME OF THE POD> -- bash

In order to replicate the container startup scripts execute this command:

    /opt/bitnami/scripts/clickhouse/entrypoint.sh /opt/bitnami/scripts/clickhouse/run.sh

{{- else }}

ClickHouse can be accessed on the following DNS name from within your cluster:

    {{ printf "%s.%s.svc.%s" (include "common.names.fullname" .) (include "common.names.namespace" . ) .Values.clusterDomain }} (port {{ ternary .Values.service.ports.tcpSecure .Values.service.ports.tcp .Values.tls.enabled }})

To connect to your ClickHouse from outside the cluster execute the following commands:

{{- if eq "LoadBalancer" .Values.service.type }}

NOTE: It may take a few minutes for the LoadBalancer IP to be available.

    kubectl get svc --namespace {{ template "common.names.namespace" . }} -l "app.kubernetes.io/name={{ template "common.names.fullname" . }},app.kubernetes.io/instance={{ .Release.Name }},app.kubernetes.io/component=clickhouse" -w
    export SERVICE_IP=$(kubectl get svc --namespace {{ template "common.names.namespace" . }} {{ template "common.names.fullname" . }} --template "{{ "{{ range (index .status.loadBalancer.ingress 0) }}{{ . }}{{ end }}" }}")

{{- else if eq "NodePort" .Values.service.type }}

    export NODE_IP=$(kubectl get nodes --namespace {{ template "common.names.namespace" . }} -o jsonpath="{.items[0].status.addresses[0].address}")
    export NODE_PORT=$(kubectl get --namespace {{ template "common.names.namespace" . }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "common.names.fullname" . }})

{{- else if eq "ClusterIP" .Values.service.type }}

    kubectl port-forward --namespace {{ template "common.names.namespace" . }} svc/{{ template "common.names.fullname" . }} {{ ternary .Values.service.ports.tcpSecure .Values.service.ports.tcp .Values.tls.enabled }}:9000 &

{{- end }}

Credentials:

    echo "Username: {{ .Values.auth.username }}"
    echo "Password: $(kubectl get secret --namespace {{ .Release.Namespace }} {{ include "clickhouse.secretName" . }} -o jsonpath="{.data.{{ include "clickhouse.secretKey" .}}}" | base64 -d)"

{{- if .Values.tls.enabled }}

TLS is enabled, as a consequence please ensure you add the `--secure` flag to your `clickhouse-client` commands.

{{- end }}
{{- end }}

{{- include "common.warnings.rollingTag" .Values.image }}
{{- include "common.warnings.rollingTag" .Values.keeper.image }}
{{- include "common.warnings.rollingTag" .Values.defaultInitContainers.volumePermissions.image }}
{{- include "clickhouse.validateValues" . }}
{{- $resourcesSections := list "" }}
{{- if .Values.keeper.enabled }}
  {{- $resourcesSections = append $resourcesSections "keeper" }}
{{- end }}
{{- if .Values.defaultInitContainers.volumePermissions.enabled }}
  {{- $resourcesSections = append $resourcesSections "defaultInitContainers.volumePermissions" }}
{{- end }}
{{- include "common.warnings.resources" (dict "sections" $resourcesSections "context" $) }}
{{- include "common.warnings.modifiedImages" (dict "images" (list .Values.image .Values.keeper.image .Values.defaultInitContainers.volumePermissions.image) "context" $) }}
{{- include "common.errors.insecureImages" (dict "images" (list .Values.image .Values.keeper.image .Values.defaultInitContainers.volumePermissions.image) "context" $) }}
