commit 1aef84f0941f8364f0a2dfcc84e6353fcbb0d73c Author: 0xFEEDC0DE64 Date: Fri Oct 23 12:04:04 2026 +0200 Package InfluxDB 2.7.12 as adoptable Helm chart diff --git a/.gitea/workflows/chart.yml b/.gitea/workflows/chart.yml new file mode 100644 index 0000000..0999751 --- /dev/null +++ b/.gitea/workflows/chart.yml @@ -0,0 +1,57 @@ +name: Validate, publish and promote InfluxDB 2 chart +on: + push: + pull_request: +jobs: + validate: + runs-on: linux_amd64 + steps: + - uses: actions/checkout@v4 + with: {fetch-depth: 0} + - run: ./scripts/test-chart.sh + publish: + if: gitea.event_name == 'push' && gitea.ref == 'refs/heads/main' + needs: validate + runs-on: linux_amd64 + steps: + - uses: actions/checkout@v4 + with: {fetch-depth: 0} + - name: Derive chart version + run: echo "CHART_VERSION=$(./scripts/chart-version.sh)" >> "$GITHUB_ENV" + - name: Publish public chart + env: + PACKAGE_USERNAME: ${{ secrets.PACKAGE_USERNAME }} + PACKAGE_TOKEN: ${{ secrets.PACKAGE_TOKEN }} + run: | + set -euo pipefail + test -n "$PACKAGE_USERNAME" && test -n "$PACKAGE_TOKEN" + helm package chart --destination "$RUNNER_TEMP" --version "$CHART_VERSION" + curl --fail --silent --show-error --user "$PACKAGE_USERNAME:$PACKAGE_TOKEN" --request POST --upload-file "$RUNNER_TEMP/influxdb2-$CHART_VERSION.tgz" https://code.brunner.ninja/api/packages/feedc0de/helm/api/charts + - name: Confirm current main + env: + COMMIT_SHA: ${{ gitea.sha }} + run: | + git fetch --no-tags origin main + test "$(git rev-parse FETCH_HEAD)" = "$COMMIT_SHA" + - uses: actions/checkout@v4 + with: + repository: feedc0de/homelab-gitops + ref: main + token: ${{ secrets.GITOPS_TOKEN }} + path: homelab-gitops + - name: Promote exact chart + working-directory: homelab-gitops + run: | + set -euo pipefail + ./scripts/update-chart-version.sh influxdb2 "$CHART_VERSION" + git config user.name feedc0de + git config user.email feedc0de@users.noreply.code.brunner.ninja + git add bootstrap/influxdb2.yaml + if git diff --cached --quiet; then exit 0; fi + git commit -m "Deploy influxdb2 chart $CHART_VERSION" + for attempt in 1 2 3; do + git push origin HEAD:main && exit 0 + test "$attempt" = 3 && exit 1 + git fetch origin main + git rebase origin/main + done diff --git a/README.md b/README.md new file mode 100644 index 0000000..9116b05 --- /dev/null +++ b/README.md @@ -0,0 +1,16 @@ +# InfluxDB 2 Helm chart + +This chart runs the official InfluxDB 2 image using a pre-existing PVC. It +keeps the Deployment and Service names stable during adoption. It does not +create or initialize the database, and never deletes the claim. + +```sh +helm repo add brunner.ninja https://brunner.ninja/charts +helm repo update brunner.ninja +helm upgrade --install influxdb2 brunner.ninja/influxdb2 --namespace default \ + --set persistence.existingClaim=influxdb2-pvc --wait --timeout 10m +``` + +The homelab instance is reconciled by Argo CD from `homelab-gitops`. +The separate `influxdb/` folder was an InfluxDB 3 experiment and is not part +of this chart. diff --git a/chart/Chart.yaml b/chart/Chart.yaml new file mode 100644 index 0000000..f2396f5 --- /dev/null +++ b/chart/Chart.yaml @@ -0,0 +1,6 @@ +apiVersion: v2 +name: influxdb2 +description: InfluxDB 2 with an existing persistent volume +type: application +version: 0.0.0 +appVersion: "2.7.12" diff --git a/chart/templates/alerts.yaml b/chart/templates/alerts.yaml new file mode 100644 index 0000000..2df9dbf --- /dev/null +++ b/chart/templates/alerts.yaml @@ -0,0 +1,28 @@ +{{- if .Values.monitoring.storageAlerts }} +apiVersion: monitoring.coreos.com/v1 +kind: PrometheusRule +metadata: + name: {{ .Release.Name }}-storage +spec: + groups: + - name: {{ .Release.Name }}.storage + rules: + - alert: InfluxDBVolumeFillingUp + expr: | + 100 * kubelet_volume_stats_used_bytes{namespace="{{ .Release.Namespace }}", persistentvolumeclaim="{{ .Values.persistence.existingClaim }}"} + / kubelet_volume_stats_capacity_bytes{namespace="{{ .Release.Namespace }}", persistentvolumeclaim="{{ .Values.persistence.existingClaim }}"} > 80 + for: 30m + labels: {severity: warning} + annotations: + summary: InfluxDB volume is more than 80% full + description: Add capacity or shorten bucket retention before compactions run out of working space. + - alert: InfluxDBVolumeAlmostFull + expr: | + 100 * kubelet_volume_stats_used_bytes{namespace="{{ .Release.Namespace }}", persistentvolumeclaim="{{ .Values.persistence.existingClaim }}"} + / kubelet_volume_stats_capacity_bytes{namespace="{{ .Release.Namespace }}", persistentvolumeclaim="{{ .Values.persistence.existingClaim }}"} > 90 + for: 10m + labels: {severity: critical} + annotations: + summary: InfluxDB volume is more than 90% full + description: InfluxDB is at risk of WAL and TSM compaction failures. +{{- end }} diff --git a/chart/templates/workload.yaml b/chart/templates/workload.yaml new file mode 100644 index 0000000..ad9c36f --- /dev/null +++ b/chart/templates/workload.yaml @@ -0,0 +1,95 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ .Release.Name }} +spec: + replicas: 1 + strategy: + type: Recreate + selector: + matchLabels: + app: {{ .Release.Name }} + template: + metadata: + labels: + app: {{ .Release.Name }} + spec: + imagePullSecrets: [] + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + containers: + - name: influxdb2 + image: {{ .Values.image.repository }}:{{ .Values.image.tag }} + imagePullPolicy: IfNotPresent + ports: + - name: http + containerPort: 8086 + startupProbe: + httpGet: {path: /health, port: http} + failureThreshold: 60 + periodSeconds: 5 + timeoutSeconds: 3 + readinessProbe: + httpGet: {path: /health, port: http} + failureThreshold: 3 + periodSeconds: 10 + timeoutSeconds: 3 + livenessProbe: + httpGet: {path: /health, port: http} + failureThreshold: 6 + periodSeconds: 10 + timeoutSeconds: 3 + {{- with .Values.resources }} + resources: + {{- toYaml . | nindent 10 }} + {{- end }} + {{- with .Values.env }} + env: + {{- toYaml . | nindent 10 }} + {{- end }} + volumeMounts: + - name: influxdb2 + mountPath: /var/lib/influxdb2 + volumes: + - name: influxdb2 + persistentVolumeClaim: + claimName: {{ required "persistence.existingClaim is required" .Values.persistence.existingClaim }} +--- +apiVersion: v1 +kind: Service +metadata: + name: {{ .Release.Name }} +spec: + type: ClusterIP + selector: + app: {{ .Release.Name }} + ports: + - name: http + port: 80 + targetPort: 8086 +{{- if .Values.ingress.enabled }} +--- +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: {{ .Release.Name }} + {{- with .Values.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + ingressClassName: {{ .Values.ingress.className }} + rules: + - host: {{ required "ingress.host is required" .Values.ingress.host }} + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: {{ .Release.Name }} + port: + name: http +{{- end }} diff --git a/chart/values.yaml b/chart/values.yaml new file mode 100644 index 0000000..04e7a94 --- /dev/null +++ b/chart/values.yaml @@ -0,0 +1,15 @@ +image: + repository: influxdb + tag: "2.7.12" +persistence: + existingClaim: "" +resources: {} +affinity: {} +env: [] +ingress: + enabled: false + host: "" + className: "" + annotations: {} +monitoring: + storageAlerts: false diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..6198f3a --- /dev/null +++ b/install.sh @@ -0,0 +1,7 @@ +#!/bin/sh +set -eu +helm repo add brunner.ninja https://brunner.ninja/charts --force-update +helm repo update brunner.ninja +helm upgrade --install influxdb2 brunner.ninja/influxdb2 \ + --namespace default --set persistence.existingClaim=influxdb2-pvc \ + --wait --timeout 10m diff --git a/scripts/chart-version.sh b/scripts/chart-version.sh new file mode 100755 index 0000000..b0e4519 --- /dev/null +++ b/scripts/chart-version.sh @@ -0,0 +1,7 @@ +#!/bin/sh +set -eu +description=$(git describe --tags --long --match 'v[0-9]*' --dirty) +case "$description" in *-dirty) echo 'Refusing dirty tree' >&2; exit 1 ;; esac +version=${description#v} +case "$version" in *-0-g*) version=${version%%-0-g*} ;; esac +printf '%s\n' "$version" diff --git a/scripts/test-chart.sh b/scripts/test-chart.sh new file mode 100755 index 0000000..97deffb --- /dev/null +++ b/scripts/test-chart.sh @@ -0,0 +1,5 @@ +#!/bin/sh +set -eu +cd "$(dirname "$0")/.." +helm lint chart --set persistence.existingClaim=example-data +helm template influxdb2 chart --namespace default --set persistence.existingClaim=example-data --set ingress.enabled=true --set ingress.host=influx.example.test --set monitoring.storageAlerts=true > /dev/null