From 8388e003860e635bbd0dd54c941089ce7c95896e Mon Sep 17 00:00:00 2001 From: Caleb Woodbine Date: Tue, 20 Oct 2020 22:17:01 +1300 Subject: [PATCH] Add Helm chart --- chart/README.org | 26 ++ chart/plausible-analytics/.helmignore | 23 ++ chart/plausible-analytics/Chart.yaml | 23 ++ chart/plausible-analytics/templates/NOTES.txt | 21 ++ .../templates/_helpers.tpl | 62 ++++ .../templates/deployment.yaml | 319 ++++++++++++++++++ chart/plausible-analytics/templates/hpa.yaml | 33 ++ .../templates/ingress.yaml | 46 +++ .../plausible-analytics/templates/secret.yaml | 75 ++++ .../templates/service.yaml | 20 ++ .../templates/serviceaccount.yaml | 17 + .../templates/tests/test-connection.yaml | 15 + chart/plausible-analytics/values.yaml | 129 +++++++ 13 files changed, 809 insertions(+) create mode 100644 chart/README.org create mode 100644 chart/plausible-analytics/.helmignore create mode 100644 chart/plausible-analytics/Chart.yaml create mode 100644 chart/plausible-analytics/templates/NOTES.txt create mode 100644 chart/plausible-analytics/templates/_helpers.tpl create mode 100644 chart/plausible-analytics/templates/deployment.yaml create mode 100644 chart/plausible-analytics/templates/hpa.yaml create mode 100644 chart/plausible-analytics/templates/ingress.yaml create mode 100644 chart/plausible-analytics/templates/secret.yaml create mode 100644 chart/plausible-analytics/templates/service.yaml create mode 100644 chart/plausible-analytics/templates/serviceaccount.yaml create mode 100644 chart/plausible-analytics/templates/tests/test-connection.yaml create mode 100644 chart/plausible-analytics/values.yaml diff --git a/chart/README.org b/chart/README.org new file mode 100644 index 0000000..7dda07c --- /dev/null +++ b/chart/README.org @@ -0,0 +1,26 @@ +#+TITLE: Helm chart + +* Installation + +#+begin_src shell :pwd ./ :results silent + helm install plausible -n plausible \ + --debug \ + --set baseURL=http://localhost:8000 \ + --set adminUser.email=myemail@example.com \ + --set adminUser.name="Test User" \ + --set adminUser.password="password" \ + --set database.url="postgres://plausible:plausible@postgres/plausible?ssl=false" \ + --set clickhouse.url="http://plausible-events-db:8123/plausible" \ + --set disableRegistration=true \ + --set disableAuth=true \ + --set image.tag=dev \ + plausible-analytics +#+end_src + +#+begin_src shell :pwd ./ + kubectl -n plausible get pods,svc +#+end_src + +#+begin_src shell :pwd ./ :results silent + helm uninstall plausible -n plausible +#+end_src diff --git a/chart/plausible-analytics/.helmignore b/chart/plausible-analytics/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/chart/plausible-analytics/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/chart/plausible-analytics/Chart.yaml b/chart/plausible-analytics/Chart.yaml new file mode 100644 index 0000000..d761f83 --- /dev/null +++ b/chart/plausible-analytics/Chart.yaml @@ -0,0 +1,23 @@ +apiVersion: v2 +name: plausible-analytics +description: Simple and privacy-friendly alternative to Google Analytics + +# A chart can be either an 'application' or a 'library' chart. +# +# Application charts are a collection of templates that can be packaged into versioned archives +# to be deployed. +# +# Library charts provide useful utilities or functions for the chart developer. They're included as +# a dependency of application charts to inject those utilities and functions into the rendering +# pipeline. Library charts do not define any templates and therefore cannot be deployed. +type: application + +# This is the chart version. This version number should be incremented each time you make changes +# to the chart and its templates, including the app version. +# Versions are expected to follow Semantic Versioning (https://semver.org/) +version: 0.0.1 + +# This is the version number of the application being deployed. This version number should be +# incremented each time you make changes to the application. Versions are not expected to +# follow Semantic Versioning. They should reflect the version the application is using. +appVersion: v1.1.1 diff --git a/chart/plausible-analytics/templates/NOTES.txt b/chart/plausible-analytics/templates/NOTES.txt new file mode 100644 index 0000000..62f0bb0 --- /dev/null +++ b/chart/plausible-analytics/templates/NOTES.txt @@ -0,0 +1,21 @@ +1. Get the application URL by running these commands: +{{- if .Values.ingress.enabled }} +{{- range $host := .Values.ingress.hosts }} + {{- range .paths }} + http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ . }} + {{- end }} +{{- end }} +{{- else if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "plausible-analytics.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "plausible-analytics.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "plausible-analytics.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "plausible-analytics.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:80 +{{- end }} diff --git a/chart/plausible-analytics/templates/_helpers.tpl b/chart/plausible-analytics/templates/_helpers.tpl new file mode 100644 index 0000000..2709323 --- /dev/null +++ b/chart/plausible-analytics/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "plausible-analytics.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "plausible-analytics.fullname" -}} +{{- if .Values.fullnameOverride }} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.nameOverride }} +{{- if contains $name .Release.Name }} +{{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} +{{- end }} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "plausible-analytics.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "plausible-analytics.labels" -}} +helm.sh/chart: {{ include "plausible-analytics.chart" . }} +{{ include "plausible-analytics.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "plausible-analytics.selectorLabels" -}} +app.kubernetes.io/name: {{ include "plausible-analytics.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "plausible-analytics.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "plausible-analytics.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/chart/plausible-analytics/templates/deployment.yaml b/chart/plausible-analytics/templates/deployment.yaml new file mode 100644 index 0000000..6ccd3f7 --- /dev/null +++ b/chart/plausible-analytics/templates/deployment.yaml @@ -0,0 +1,319 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "plausible-analytics.fullname" . }} + labels: + app: plausible + {{- include "plausible-analytics.labels" . | nindent 4 }} +{{- if .Values.labels }} +{{- with .Values.labels }} + {{- toYaml . | nindent 4 }} +{{- end }} +{{- end }} + annotations: + checksum/secret: {{ include (print $.Template.BasePath "/secret.yaml") . | sha256sum }} +spec: +{{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount }} +{{- end }} + selector: + matchLabels: + app: plausible + {{- include "plausible-analytics.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + app: plausible + {{- include "plausible-analytics.selectorLabels" . | nindent 8 }} + {{- if .Values.labels }} + {{- with .Values.labels }} + {{- toYaml . | nindent 8 }} + {{- end }} + {{- end }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "plausible-analytics.serviceAccountName" . }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + command: + - /entrypoint.sh + - run + env: + {{- if .Values.adminUser.email }} + - name: ADMIN_USER_EMAIL + valueFrom: + secretKeyRef: + key: ADMIN_USER_EMAIL + name: {{ include "plausible-analytics.fullname" . }} + {{- end }} + {{- if .Values.adminUser.email }} + - name: ADMIN_USER_NAME + valueFrom: + secretKeyRef: + key: ADMIN_USER_NAME + name: {{ include "plausible-analytics.fullname" . }} + {{- end }} + {{- if .Values.adminUser.email }} + - name: ADMIN_USER_PWD + valueFrom: + secretKeyRef: + key: ADMIN_USER_PWD + name: {{ include "plausible-analytics.fullname" . }} + {{- end }} + {{- if .Values.database.enabled }} + {{- if .Values.database.url }} + - name: DATABASE_URL + valueFrom: + secretKeyRef: + 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: + secretKeyRef: + key: CLICKHOUSE_DATABASE_URL + name: {{ include "plausible-analytics.fullname" . }} + {{- end }} + {{- end }} + {{- if .Values.baseURL }} + - name: BASE_URL + value: {{ .Values.baseURL | toString | quote }} + {{- end }} + ports: + - name: http + containerPort: {{ .Values.service.port }} + protocol: TCP + volumeMounts: + - name: app-tmp + mountPath: /app/tmp + livenessProbe: + httpGet: + path: / + port: http + readinessProbe: + httpGet: + path: / + port: http + resources: + {{- toYaml .Values.resources | nindent 12 }} + initContainers: + - name: plausible-init + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + command: + - /bin/sh + - -x + - -c + - /entrypoint.sh db createdb && /entrypoint.sh db migrate && /entrypoint.sh db init-admin + env: + {{- if .Values.adminUser.email }} + - name: ADMIN_USER_EMAIL + valueFrom: + secretKeyRef: + key: ADMIN_USER_EMAIL + name: {{ include "plausible-analytics.fullname" . }} + {{- end }} + {{- if .Values.adminUser.email }} + - name: ADMIN_USER_NAME + valueFrom: + secretKeyRef: + key: ADMIN_USER_NAME + name: {{ include "plausible-analytics.fullname" . }} + {{- end }} + {{- if .Values.adminUser.email }} + - name: ADMIN_USER_PWD + valueFrom: + secretKeyRef: + key: ADMIN_USER_PWD + name: {{ include "plausible-analytics.fullname" . }} + {{- end }} + {{- if .Values.database.enabled }} + {{- if .Values.database.url }} + - name: DATABASE_URL + valueFrom: + secretKeyRef: + 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: + secretKeyRef: + key: CLICKHOUSE_DATABASE_URL + name: {{ include "plausible-analytics.fullname" . }} + {{- end }} + {{- end }} + {{- if .Values.disableAuth }} + - name: DISABLE_AUTH + value: {{ .Values.disableAuth | toString | quote }} + {{- end }} + {{- if .Values.disableRegistration }} + - name: DISABLE_REGISTRATION + value: {{ .Values.disableRegistration | toString | quote }} + {{- end }} + {{- if .Values.disableAuth }} + - name: BASE_URL + value: {{ .Values.baseURL | toString | quote }} + {{- end }} + {{- if .Values.smtp.enabled }} + {{- if .Values.smtp.mailer.emailAddress }} + - name: MAILER_EMAIL + valueFrom: + secretKeyRef: + key: MAILER_EMAIL + name: {{ include "plausible-analytics.fullname" . }} + {{- end }} + {{- if .Values.smtp.adapter }} + - name: MAILER_ADAPTER + valueFrom: + secretKeyRef: + key: MAILER_ADAPTER + name: {{ include "plausible-analytics.fullname" . }} + {{- end }} + {{- if .Values.smtp.host }} + - name: SMTP_HOST_ADDR + valueFrom: + secretKeyRef: + key: SMTP_HOST_ADDR + name: {{ include "plausible-analytics.fullname" . }} + {{- end }} + {{- if .Values.smtp.port }} + - name: SMTP_HOST_PORT + valueFrom: + secretKeyRef: + key: SMTP_HOST_PORT + name: {{ include "plausible-analytics.fullname" . }} + {{- end }} + {{- if .Values.smtp.username }} + - name: SMTP_USER_NAME + valueFrom: + secretKeyRef: + key: SMTP_USER_NAME + name: {{ include "plausible-analytics.fullname" . }} + {{- end }} + {{- if .Values.smtp.password }} + - name: SMTP_USER_PWD + valueFrom: + secretKeyRef: + key: SMTP_USER_PWD + name: {{ include "plausible-analytics.fullname" . }} + {{- end }} + {{- if .Values.smtp.ssl.enabled }} + - name: SMTP_HOST_SSL_ENABLED + valueFrom: + secretKeyRef: + key: SMTP_HOST_SSL_ENABLED + name: {{ include "plausible-analytics.fullname" . }} + {{- end }} + {{- if .Values.smtp.retires }} + - name: SMTP_RETRIES + valueFrom: + secretKeyRef: + key: SMTP_HOST_SSL_ENABLED + name: {{ include "plausible-analytics.fullname" . }} + {{- end }} + {{- end }} + {{- if .Values.google.clientID }} + - name: GOOGLE_CLIENT_ID + valueFrom: + secretKeyRef: + key: GOOGLE_CLIENT_ID + name: {{ include "plausible-analytics.fullname" . }} + {{- end }} + {{- if .Values.google.clientSecret }} + - name: GOOGLE_CLIENT_SECRET + valueFrom: + secretKeyRef: + key: GOOGLE_CLIENT_SECRET + name: {{ include "plausible-analytics.fullname" . }} + {{- end }} + {{- if .Values.twitter.consumer.key }} + - name: TWITTER_CONSUMER_KEY + valueFrom: + secretKeyRef: + key: TWITTER_CONSUMER_KEY + name: {{ include "plausible-analytics.fullname" . }} + {{- end }} + {{- if .Values.twitter.consumer.secret }} + - name: TWITTER_CONSUMER_SECRET + valueFrom: + secretKeyRef: + key: TWITTER_CONSUMER_SECRET + name: {{ include "plausible-analytics.fullname" . }} + {{- end }} + {{- if .Values.twitter.access.token }} + - name: TWITTER_ACCESS_TOKEN + valueFrom: + secretKeyRef: + key: TWITTER_ACCESS_TOKEN + name: {{ include "plausible-analytics.fullname" . }} + {{- end }} + {{- if .Values.twitter.access.secret }} + - name: TWITTER_ACCESS_TOKEN_SECRET + valueFrom: + secretKeyRef: + key: TWITTER_ACCESS_TOKEN_SECRET + name: {{ include "plausible-analytics.fullname" . }} + {{- end }} + {{- if .Values.postmark.apiKey }} + - name: POSTMARK_API_KEY + valueFrom: + secretKeyRef: + key: POSTMARK_API_KEY + name: {{ include "plausible-analytics.fullname" . }} + {{- end }} + {{- if .Values.geoliteCountryDB }} + - name: GEOLITE2_COUNTRY_DB + valueFrom: + secretKeyRef: + key: GEOLITE2_COUNTRY_DB + name: {{ include "plausible-analytics.fullname" . }} + {{- end }} + volumeMounts: + - name: app-tmp + mountPath: /app/tmp + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} + volumes: + - name: app-tmp + emptyDir: {} diff --git a/chart/plausible-analytics/templates/hpa.yaml b/chart/plausible-analytics/templates/hpa.yaml new file mode 100644 index 0000000..03fe61c --- /dev/null +++ b/chart/plausible-analytics/templates/hpa.yaml @@ -0,0 +1,33 @@ +{{- if .Values.autoscaling.enabled }} +apiVersion: autoscaling/v2beta1 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "plausible-analytics.fullname" . }} + labels: + {{- include "plausible-analytics.labels" . | nindent 4 }} +{{- if .Values.labels }} +{{- with .Values.labels }} + {{- toYaml . | nindent 4 }} +{{- end }} +{{- end }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "plausible-analytics.fullname" . }} + minReplicas: {{ .Values.autoscaling.minReplicas }} + maxReplicas: {{ .Values.autoscaling.maxReplicas }} + metrics: + {{- if .Values.autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} + {{- end }} + {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} +{{- end }} diff --git a/chart/plausible-analytics/templates/ingress.yaml b/chart/plausible-analytics/templates/ingress.yaml new file mode 100644 index 0000000..ea869e3 --- /dev/null +++ b/chart/plausible-analytics/templates/ingress.yaml @@ -0,0 +1,46 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "plausible-analytics.fullname" . -}} +{{- $svcPort := .Values.service.port -}} +{{- if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1beta1 +{{- else -}} +apiVersion: extensions/v1beta1 +{{- end }} +kind: Ingress +metadata: + name: {{ $fullName }} + labels: + {{- include "plausible-analytics.labels" . | nindent 4 }} +{{- if .Values.labels }} +{{- with .Values.labels }} + {{- toYaml . | nindent 4 }} +{{- end }} +{{- end }} + {{- with .Values.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- if .Values.ingress.tls }} + tls: + {{- range .Values.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} + {{- end }} + rules: + {{- range .Values.ingress.hosts }} + - host: {{ .host | quote }} + http: + paths: + {{- range .paths }} + - path: {{ . }} + backend: + serviceName: {{ $fullName }} + servicePort: {{ $svcPort }} + {{- end }} + {{- end }} + {{- end }} diff --git a/chart/plausible-analytics/templates/secret.yaml b/chart/plausible-analytics/templates/secret.yaml new file mode 100644 index 0000000..3248240 --- /dev/null +++ b/chart/plausible-analytics/templates/secret.yaml @@ -0,0 +1,75 @@ +apiVersion: v1 +kind: Secret +metadata: + name: {{ include "plausible-analytics.fullname" . }} + labels: + app: plausible + {{- include "plausible-analytics.labels" . | nindent 4 }} +type: Opaque +data: + {{- if .Values.adminUser.email }} + ADMIN_USER_EMAIL: {{ .Values.adminUser.email | toString | b64enc }} + {{- end }} + {{- if .Values.adminUser.password }} + ADMIN_USER_PWD: {{ .Values.adminUser.password | toString | b64enc }} + {{- end }} + {{- if .Values.adminUser.name }} + ADMIN_USER_NAME: {{ .Values.adminUser.name | toString | b64enc }} + {{- end }} + {{- if .Values.database.url }} + DATABASE_URL: {{ .Values.database.url | toString | b64enc }} + {{- end }} + {{- if .Values.clickhouse.url }} + CLICKHOUSE_DATABASE_URL: {{ .Values.clickhouse.url | toString | b64enc }} + {{- end }} + SECRET_KEY_BASE: {{ randAlphaNum 90 | toString | b64enc }} +{{- if .Values.smtp.enabled }} + {{- if .Values.smtp.mailer.emailAddress }} + MAILER_EMAIL: {{ .Values.smtp.mailer.emailAddress | toString | b64enc }} + {{- end }} + {{- if .Values.smtp.adapter }} + MAILER_ADAPTER: {{ .Values.smtp.mailer.adapter | toString | b64enc }} + {{- end }} + {{- if .Values.smtp.host }} + SMTP_HOST_ADDR: {{ .Values.smtp.host | toString | b64enc }} + {{- end }} + {{- if .Values.smtp.port }} + SMTP_HOST_PORT: {{ .Values.smtp.port | toString | b64enc }} + {{- end }} + {{- if .Values.smtp.username }} + SMTP_USER_NAME: {{ .Values.smtp.username | toString | b64enc }} + {{- end }} + {{- if .Values.smtp.password }} + SMTP_USER_PWD: {{ .Values.smtp.password | toString | b64enc }} + {{- end }} + {{- if .Values.smtp.ssl.enabled }} + SMTP_HOST_SSL_ENABLED: {{ .Values.smtp.ssl.enabled | toString | b64enc }} + {{- end }} + {{- if .Values.smtp.retries }} + SMTP_RETRIES: {{ .Values.smtp.retries | toString | b64enc }} + {{- end }} + {{- if .Values.google.clientID }} + GOOGLE_CLIENT_ID: {{ .Values.google.clientID | toString | b64enc }} + {{- end }} + {{- if .Values.google.clientSecret }} + GOOGLE_CLIENT_SECRET: {{ .Values.google.clientSecret | toString | b64enc }} + {{- end }} + {{- if .Values.twitter.consumer.key }} + TWITTER_CONSUMER_KEY: {{ .Values.twitter.consumer.key | toString | b64enc }} + {{- end }} + {{- if .Values.twitter.consumer.secret }} + TWITTER_CONSUMER_SECRET: {{ .Values.twitter.consumer.secret | toString | b64enc }} + {{- end }} + {{- if .Values.twitter.access.token }} + TWITTER_ACCESS_TOKEN: {{ .Values.twitter.access.token | toString | b64enc }} + {{- end }} + {{- if .Values.twitter.access.secret }} + TWITTER_ACCESS_TOKEN_SECRET: {{ .Values.twitter.access.secret | toString | b64enc }} + {{- end }} +{{- end }} + {{- if .Values.postmark.apiKey }} + POSTMARK_API_KEY: {{ .Values.postmark.apiKey | toString | b64enc }} + {{- end }} + {{- if .Values.geoliteCountryDB }} + GEOLITE2_COUNTRY_DB: {{ .Values.geoliteCountryDB | toString | b64enc }} + {{- end }} diff --git a/chart/plausible-analytics/templates/service.yaml b/chart/plausible-analytics/templates/service.yaml new file mode 100644 index 0000000..164a34b --- /dev/null +++ b/chart/plausible-analytics/templates/service.yaml @@ -0,0 +1,20 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "plausible-analytics.fullname" . }} + labels: + {{- include "plausible-analytics.labels" . | nindent 4 }} +{{- if .Values.labels }} +{{- with .Values.labels }} + {{- toYaml . | nindent 4 }} +{{- end }} +{{- end }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + {{- include "plausible-analytics.selectorLabels" . | nindent 4 }} diff --git a/chart/plausible-analytics/templates/serviceaccount.yaml b/chart/plausible-analytics/templates/serviceaccount.yaml new file mode 100644 index 0000000..98682f0 --- /dev/null +++ b/chart/plausible-analytics/templates/serviceaccount.yaml @@ -0,0 +1,17 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "plausible-analytics.serviceAccountName" . }} + labels: + {{- include "plausible-analytics.labels" . | nindent 4 }} +{{- if .Values.labels }} +{{- with .Values.labels }} + {{- toYaml . | nindent 4 }} +{{- end }} +{{- end }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end }} diff --git a/chart/plausible-analytics/templates/tests/test-connection.yaml b/chart/plausible-analytics/templates/tests/test-connection.yaml new file mode 100644 index 0000000..24ed8e2 --- /dev/null +++ b/chart/plausible-analytics/templates/tests/test-connection.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Pod +metadata: + name: "{{ include "plausible-analytics.fullname" . }}-test-connection" + labels: + {{- include "plausible-analytics.labels" . | nindent 4 }} + annotations: + "helm.sh/hook": test-success +spec: + containers: + - name: wget + image: busybox + command: ['wget'] + args: ['{{ include "plausible-analytics.fullname" . }}:{{ .Values.service.port }}'] + restartPolicy: Never diff --git a/chart/plausible-analytics/values.yaml b/chart/plausible-analytics/values.yaml new file mode 100644 index 0000000..328017f --- /dev/null +++ b/chart/plausible-analytics/values.yaml @@ -0,0 +1,129 @@ +# Default values for plausible-analytics. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +disableAuth: false +disableRegistration: false +baseURL: + +adminUser: + email: + name: + password: + +# SECRET_KEY_BASE is Helm randAlphaNum 90 + +database: + enabled: true + url: + +clickhouse: + enabled: true + url: + +smtp: + enabled: true + mailer: + emailAddress: + adapter: + host: + port: + username: + password: + ssl: + enabled: false + retries: 2 + +postmark: + apiKey: + +geoliteCountryDB: + +google: + clientID: + clientSecret: + +twitter: + consumer: + key: + secret: + access: + token: + secret: + +labels: {} +extraEnv: [] + +replicaCount: 1 + +image: + repository: plausible/analytics + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "" + +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" + +serviceAccount: + # Specifies whether a service account should be created + create: false + # Annotations to add to the service account + annotations: {} + # The name of the service account to use. + # If not set and create is true, a name is generated using the fullname template + name: "" + +podAnnotations: {} + +podSecurityContext: {} + # fsGroup: 2000 + +securityContext: + readOnlyRootFilesystem: true + runAsNonRoot: true + runAsUser: 1000 + runAsGroup: 1000 + +service: + type: ClusterIP + port: 8000 + +ingress: + enabled: false + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + hosts: + - host: chart-example.local + paths: [] + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + +resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + +autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + +nodeSelector: {} + +tolerations: [] + +affinity: {}