From 6cac8b54b53cd7ab6f6dd77e9a93590ff646f05f Mon Sep 17 00:00:00 2001 From: Alexandre Nuttinck Date: Thu, 24 Aug 2023 16:55:39 +0200 Subject: [PATCH] [ADD] set extraEnv, secret, refactoring Squashed commit of the following: commit d06032e856f6c973c75788143a889a2311062e43 Author: Alexandre Nuttinck Date: Thu Aug 24 16:48:26 2023 +0200 update chart commit 581e5bcd1851c0044143d3fc40cb8ee918f230f3 Author: Alexandre Nuttinck Date: Thu Aug 24 13:55:47 2023 +0200 [MOD] fix lint errors commit aeec37aa5c49752ea46b8bf92a23f0621d59f88c Author: Alexandre Nuttinck Date: Thu Aug 24 11:20:52 2023 +0200 [MOD] fix typo in gh action commit af4109939c8537c18759ec540a02fe282a76d77f Author: Alexandre Nuttinck Date: Thu Aug 24 10:58:37 2023 +0200 test gh action commit 6875a6de161f1770145351a1a5c8c145c70223a0 Author: Alexandre Nuttinck Date: Thu Aug 24 10:54:54 2023 +0200 [MOD] typo in gh action commit 0c2705fcda35d5835375c502faa7e00bc5150ea7 Author: Alexandre Nuttinck Date: Thu Aug 24 10:52:28 2023 +0200 [ADD] charts-dir and chart in gh action commit fa5316438880d428769d1f1e8ed3d9cd487b5dbb Author: Alexandre Nuttinck Date: Thu Aug 24 10:42:08 2023 +0200 add secret create option commit a45a5b70c4dfa9ac780e76c13c2f28ebd8fd3d98 Author: Alexandre Nuttinck Date: Thu Aug 24 09:31:24 2023 +0200 [ADD] extraEnv + some refactoring --- .github/workflows/test.yaml | 15 +------- Chart.yaml | 6 +-- README.md | 2 + templates/deployment.yaml | 24 +++++++++--- templates/ingress.yaml | 2 +- templates/secret.yaml | 7 ++-- values.yaml | 74 +++++++++++++++++++++---------------- 7 files changed, 72 insertions(+), 58 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index e2263a3..26d53e8 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -25,23 +25,12 @@ jobs: - name: Set up chart-testing uses: helm/chart-testing-action@v2.4.0 - - name: Run chart-testing (list-changed) - id: list-changed - run: | - changed=$(ct list-changed --target-branch ${{ github.event.repository.default_branch }}) - if [[ -n "$changed" ]]; then - echo "changed=true" >> "$GITHUB_OUTPUT" - fi - - name: Run chart-testing (lint) - if: steps.list-changed.outputs.changed == 'true' - run: ct lint --target-branch ${{ github.event.repository.default_branch }} + run: ct lint --chart-dirs . --charts . --target-branch ${{ github.event.repository.default_branch }} - name: Create kind cluster - if: steps.list-changed.outputs.changed == 'true' uses: helm/kind-action@v1.7.0 - name: Run chart-testing (install) - if: steps.list-changed.outputs.changed == 'true' - run: ct install --target-branch ${{ github.event.repository.default_branch }} + run: ct install --chart-dirs . --charts . --target-branch ${{ github.event.repository.default_branch }} \ No newline at end of file diff --git a/Chart.yaml b/Chart.yaml index a386d4d..0d7c138 100644 --- a/Chart.yaml +++ b/Chart.yaml @@ -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.1.0 +version: 0.1.1 appVersion: 2.0.0 keywords: - web analytics @@ -25,6 +25,6 @@ dependencies: condition: postgresql.enabled - name: clickhouse alias: clickhouse - version: 3.6.8 + version: 3.6.7 repository: https://charts.bitnami.com/bitnami - condition: clickhouse.enabled \ No newline at end of file + condition: clickhouse.enabled diff --git a/README.md b/README.md index c6e22d8..60d90a4 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,8 @@ The following items can be set via `--set` flag during installation or configure Feel free to modify the options in the [values.yaml file](values.yaml) before installation. +You will need to set the sensitive values in the values.yaml file before installing the chart. (Passwords and URL of the databases). + ### Install the chart ```bash diff --git a/templates/deployment.yaml b/templates/deployment.yaml index 712059c..1761251 100644 --- a/templates/deployment.yaml +++ b/templates/deployment.yaml @@ -34,7 +34,13 @@ spec: command: ['sh', '-c', 'until pg_isready -h {{ .Values.postgresql.host }} -p {{ .Values.postgresql.port }} -U {{ .Values.postgresql.auth.username }}; do echo "Waiting for PostgreSQL to be ready..."; sleep 2; done;'] - name: wait-for-clickhouse image: bitnami/clickhouse:23.3.9 - command: ['sh', '-c', 'until clickhouse-client --host {{ .Values.clickhouse.host }} --port 9000 --user {{ .Values.clickhouse.auth.username }} --password {{ .Values.clickhouse.auth.password }} --query "SELECT version()"; do echo "Waiting for ClickHouse to be ready..."; sleep 2; done;'] + command: ['sh', '-c', 'until clickhouse-client --host {{ .Values.clickhouse.host }} --port 9000 --user {{ .Values.clickhouse.auth.username }} --password "$CLICKHOUSE_PASSWORD" --query "SELECT version()"; do echo "Waiting for ClickHouse to be ready..."; sleep 2; done;'] + env: + - name: CLICKHOUSE_PASSWORD + valueFrom: + secretKeyRef: + key: CLICKHOUSE_PASSWORD + name: {{ include "plausible-analytics.fullname" . }} containers: - name: {{ .Chart.Name }} securityContext: @@ -62,21 +68,20 @@ spec: key: ADMIN_USER_EMAIL name: {{ include "plausible-analytics.fullname" . }} {{- end }} - {{- if .Values.adminUser.email }} + {{- if .Values.adminUser.name }} - name: ADMIN_USER_NAME valueFrom: secretKeyRef: key: ADMIN_USER_NAME name: {{ include "plausible-analytics.fullname" . }} {{- end }} - {{- if .Values.adminUser.email }} + {{- if .Values.adminUser.password }} - name: ADMIN_USER_PWD valueFrom: secretKeyRef: key: ADMIN_USER_PWD name: {{ include "plausible-analytics.fullname" . }} {{- end }} - {{- if .Values.postgresql.enabled }} {{- if .Values.postgresql.url }} - name: DATABASE_URL valueFrom: @@ -84,13 +89,11 @@ spec: key: DATABASE_URL name: {{ include "plausible-analytics.fullname" . }} {{- end }} - {{- end }} - name: SECRET_KEY_BASE valueFrom: secretKeyRef: key: SECRET_KEY_BASE name: {{ include "plausible-analytics.fullname" . }} - {{- if .Values.clickhouse.enabled }} {{- if .Values.clickhouse.url }} - name: CLICKHOUSE_DATABASE_URL valueFrom: @@ -98,11 +101,14 @@ spec: key: CLICKHOUSE_DATABASE_URL name: {{ include "plausible-analytics.fullname" . }} {{- end }} + {{- if .Values.clickhouse.auth.username }} - name: CLICKHOUSE_USER valueFrom: secretKeyRef: key: CLICKHOUSE_USER name: {{ include "plausible-analytics.fullname" . }} + {{- end }} + {{- if .Values.clickhouse.auth.password }} - name: CLICKHOUSE_PASSWORD valueFrom: secretKeyRef: @@ -243,6 +249,12 @@ spec: - name: http containerPort: 8000 protocol: TCP + startupProbe: + httpGet: + path: / + port: http + failureThreshold: 30 + periodSeconds: 5 livenessProbe: httpGet: path: / diff --git a/templates/ingress.yaml b/templates/ingress.yaml index 5acecfb..852e2fd 100644 --- a/templates/ingress.yaml +++ b/templates/ingress.yaml @@ -56,4 +56,4 @@ spec: {{- end }} {{- end }} {{- end }} - {{- end }} \ No newline at end of file + {{- end }} diff --git a/templates/secret.yaml b/templates/secret.yaml index b9474a1..22318ef 100644 --- a/templates/secret.yaml +++ b/templates/secret.yaml @@ -1,4 +1,4 @@ ---- +{{- if .Values.secret.create -}} apiVersion: v1 kind: Secret metadata: @@ -26,7 +26,7 @@ data: {{- if .Values.clickhouse.auth.username }} CLICKHOUSE_USER: {{ .Values.clickhouse.auth.username | toString | b64enc }} {{- end }} - {{- if .Values.clickhouse.auth.password }} + {{- if .Values.clickhouse.auth.password }} CLICKHOUSE_PASSWORD: {{ .Values.clickhouse.auth.password | toString | b64enc }} {{- end }} SECRET_KEY_BASE: {{ randAlphaNum 90 | toString | b64enc }} @@ -82,4 +82,5 @@ data: {{- end }} {{- if .Values.geolocation.license_key }} GEOIPUPDATE_LICENSE_KEY: {{ .Values.geolocation.license_key | toString | b64enc }} - {{- end }} \ No newline at end of file + {{- end }} +{{- end }} diff --git a/values.yaml b/values.yaml index 0f008a7..1738026 100644 --- a/values.yaml +++ b/values.yaml @@ -6,56 +6,55 @@ # plausible analytics configuration ## see https://plausible.io/docs/self-hosting-configuration -disableAuth: false # Disables authentication completely, no registration, login will be shown. -disableRegistration: false # Disables registration of new users. -baseURL: http://plausible-analytics.local # The hosting url of the server, used for URL generation. In production systems, this should be your ingress host. +disableAuth: false # Disables authentication completely, no registration, login will be shown. +disableRegistration: false # Disables registration of new users. +baseURL: http://plausible-analytics.local # The hosting url of the server, used for URL generation. In production systems, this should be your ingress host. listenIP: 0.0.0.0 adminUser: email: admin@example.com # Admin user's email - name: Administrator # Display name admin user - password: secr3t # Admin user password + name: Administrator # Display name admin user + password: secr3t # Admin user password # SECRET_KEY_BASE is Helm randAlphaNum 90 -smtp: # Plausible uses and SMTP server to send transactional emails e.g. account activation, password reset, weekly reports, etc. - enabled: false # Enable/Disable SMTP functionality +smtp: # Plausible uses and SMTP server to send transactional emails e.g. account activation, password reset, weekly reports, etc. + enabled: false # Enable/Disable SMTP functionality mailer: - emailAddress: # the email address of the email sender + emailAddress: # the email address of the email sender adapter: - host: # The host address of your smtp server. - port: # The port of your smtp server. - username: # The username/email in case SMTP auth is enabled. - password: # The password in case SMTP auth is enabled. + host: # The host address of your smtp server. + port: # The port of your smtp server. + username: # The username/email in case SMTP auth is enabled. + password: # The password in case SMTP auth is enabled. ssl: - enabled: false # If SSL is enabled for SMTP connection - retries: 2 # Number of retries to make until mailer gives up. + enabled: false # If SSL is enabled for SMTP connection + retries: 2 # Number of retries to make until mailer gives up. -postmark: #Alternatively, you can use Postmark to send transactional emails. In this case, use the following parameters: +postmark: # Alternatively, you can use Postmark to send transactional emails. In this case, use the following parameters: apiKey: -geolocation: # MaxMind geolocation database# - enabled: false # Enable/Disable the automated fetch of - account_id: # Account/User ID from maxmind.com - license_key: # My License Key from maxmind.com +geolocation: # MaxMind geolocation database# + enabled: false # Enable/Disable the automated fetch of + account_id: # Account/User ID from maxmind.com + license_key: # My License Key from maxmind.com # Google Search Integration # See: https://docs.plausible.io/self-hosting-configuration#google-search-integration google: - clientID: # The Client ID from the Google API Console for your Plausible Analytics project - clientSecret: # The Client Secret from the Google API Console for your Plausible Analytics project -#Twitter Integration + clientID: # The Client ID from the Google API Console for your Plausible Analytics project + clientSecret: # The Client Secret from the Google API Console for your Plausible Analytics project +# Twitter Integration # https://docs.plausible.io/self-hosting-configuration#twitter-integration twitter: consumer: - key: # The API key from the Twitter Developer Portal - secret: # The API key secret from the Twitter Developer Portal + key: # The API key from the Twitter Developer Portal + secret: # The API key secret from the Twitter Developer Portal access: - token: # The access token you generated in the steps above - secret: # The access token secret you generated in the steps above + token: # The access token you generated in the steps above + secret: # The access token secret you generated in the steps above -labels: {} # Extra Labels to apply on your k8s deployment -extraEnv: [] # Extra Env Variables that are passed down to plausible 1:1 +labels: {} # Extra Labels to apply on your k8s deployment # ------------------------------------------------------------------------------ # Postgresql: @@ -66,9 +65,11 @@ postgresql: ## ref: https://github.com/bitnami/charts/blob/master/bitnami/postgresql/values.yaml enabled: true # The URL to the Postgres Database Connection String see -> https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING + # url postgres://postgres:postgres@plausible-analytics-postgresql:5432/plausible_db url: postgres://postgres:postgres@plausible-analytics-postgresql:5432/plausible_db auth: username: postgres + # check auth.existingSecret from https://github.com/bitnami/charts/tree/main/bitnami/postgresql password: postgres database: plausible_db port: 5432 @@ -84,17 +85,19 @@ postgresql: # Clickhouse: # ------------------------------------------------------------------------------ -clickhouse: # Clickhouse Database +clickhouse: # Clickhouse Database enabled: true # The URL Connection String to clickhouse DB see -> https://clickhouse.tech/docs/en/interfaces/http/ url: http://clickhouse:password@plausible-analytics-clickhouse:8123/plausible_events_db auth: username: clickhouse + # password: password or check auth.existingSecret from https://github.com/bitnami/charts/tree/main/bitnami/clickhouse password: password + database: plausible_events_db host: plausible-analytics-clickhouse - initdbScripts: {CREATE DATABASE IF NOT EXISTS plausible_events_db} - -#CLICKHOUSE_DATABASE_URL=http://user:password@plausible-events-db.plausible:8123/plausible + initdbScripts: + db-init.sql: | + CREATE DATABASE IF NOT EXISTS plausible_events_db # kubernetes ressources @@ -110,6 +113,10 @@ imagePullSecrets: [] nameOverride: "" fullnameOverride: "" +secret: + # Specifies if the helm chart should create a secret file + create: true + serviceAccount: # Specifies whether a service account should be created create: true @@ -176,3 +183,6 @@ nodeSelector: {} tolerations: [] affinity: {} + +## Extra environment variables definition +extraEnv: []