Skip to content

Commit

Permalink
[ADD] initContainers curl method
Browse files Browse the repository at this point in the history
  • Loading branch information
alexnuttinck committed Nov 3, 2023
1 parent 0729096 commit 7f9d24f
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apiVersion: v2
name: plausible-analytics
description: A Helm Chart for Plausible Analytics - Simple, open-source, lightweight (< 1 KB) and privacy-friendly web analytics alternative to Google Analytics.
type: application
version: 0.2.0
version: 0.2.1
appVersion: 2.0.0
keywords:
- web analytics
Expand Down
16 changes: 16 additions & 0 deletions templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,19 @@ data:
sleep 2
done
echo "ClickHouse is ready."
wait-for-clickhouse-with-curl.sh: |
#!/bin/sh
url="$CLICKHOUSE_DATABASE_URL"
info=$(echo $url | awk '{ gsub(/https?:\/\//, "", $0); print }')
host=$(echo $info | awk -F[/:@] '{print $3}')
until curl \
--fail \
--silent \
--connect-timeout 5 \
--output /dev/null "$host"; do
echo "Waiting for ClickHouse to be ready..."
sleep 2
done
echo "ClickHouse is ready."
15 changes: 14 additions & 1 deletion templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ spec:
serviceAccountName: {{ include "plausible-analytics.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
{{- if .Values.initContainers }}
{{- if .Values.initContainers.enabled }}
volumes:
- name: scripts-volume
configMap:
Expand All @@ -46,6 +46,7 @@ spec:
volumeMounts:
- name: scripts-volume
mountPath: /scripts
{{- if not .Values.initContainers.curl.enabled }}
- name: wait-for-clickhouse
image: bitnami/clickhouse:23.3.9
command: ['sh', '/scripts/wait-for-clickhouse.sh']
Expand All @@ -55,6 +56,18 @@ spec:
secretKeyRef:
key: CLICKHOUSE_DATABASE_URL
name: {{ include "plausible-analytics.secretName" . }}
{{- end }}
{{- if .Values.initContainers.curl.enabled }}
- name: wait-for-clickhouse
image: curlimages/curl:8.2.1
command: ['sh', '/scripts/wait-for-clickhouse-with-curl.sh']
env:
- name: CLICKHOUSE_DATABASE_URL
valueFrom:
secretKeyRef:
key: CLICKHOUSE_DATABASE_URL
name: {{ include "plausible-analytics.secretName" . }}
{{- end }}
volumeMounts:
- name: scripts-volume
mountPath: /scripts
Expand Down
5 changes: 4 additions & 1 deletion values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ clickhouseFlushIntervalMS: ""
clickhouseMaxBufferSize: ""

### Check that postgres and clickhouse are accesible before starting plausible
initContainers: true
initContainers:

Check failure on line 29 in values.yaml

View workflow job for this annotation

GitHub Actions / lint-test

29:16 [trailing-spaces] trailing spaces
enabled: true
curl:

Check failure on line 31 in values.yaml

View workflow job for this annotation

GitHub Actions / lint-test

31:8 [trailing-spaces] trailing spaces
enabled: true # use curl method to check if clickhouse is ready. (When port 9000 is not accessible)

### Specifies if the helm chart should create a secret file or use an existingSecret
secret:
Expand Down

0 comments on commit 7f9d24f

Please sign in to comment.