From 591290e4ee33731b2ef87e3463162ec7527c7897 Mon Sep 17 00:00:00 2001 From: Niklas Ye Date: Thu, 21 May 2026 15:26:11 +0200 Subject: [PATCH] Add Helm chart and chart-release workflow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit charts/terdut-server/ — Helm chart for Kubernetes deployment: - Deployment (replicas=1, /healthz probes, TERDUT_DB_PATH=/data/terdut.db) - Service (ClusterIP :8080) - PVC (1Gi, synology-iscsi) mounted at /data - HTTPRoute via envoy-main gateway .github/workflows/chart-release.yml — packages and publishes the chart to gh-pages branch on any push to main that touches charts/; repo URL will be https://yeniklas.github.io/terdut-server once the repo is made public --- .github/workflows/chart-release.yml | 33 +++++++++++++ charts/terdut-server/.helmignore | 17 +++++++ charts/terdut-server/Chart.yaml | 6 +++ charts/terdut-server/templates/_helpers.tpl | 34 +++++++++++++ .../terdut-server/templates/deployment.yaml | 48 +++++++++++++++++++ charts/terdut-server/templates/httpproxy.yaml | 15 ++++++ charts/terdut-server/templates/pvc.yaml | 13 +++++ charts/terdut-server/templates/service.yaml | 16 +++++++ charts/terdut-server/values.yaml | 16 +++++++ 9 files changed, 198 insertions(+) create mode 100644 .github/workflows/chart-release.yml create mode 100644 charts/terdut-server/.helmignore create mode 100644 charts/terdut-server/Chart.yaml create mode 100644 charts/terdut-server/templates/_helpers.tpl create mode 100644 charts/terdut-server/templates/deployment.yaml create mode 100644 charts/terdut-server/templates/httpproxy.yaml create mode 100644 charts/terdut-server/templates/pvc.yaml create mode 100644 charts/terdut-server/templates/service.yaml create mode 100644 charts/terdut-server/values.yaml diff --git a/.github/workflows/chart-release.yml b/.github/workflows/chart-release.yml new file mode 100644 index 0000000..5cf4d07 --- /dev/null +++ b/.github/workflows/chart-release.yml @@ -0,0 +1,33 @@ +name: Release Helm Chart + +on: + push: + branches: + - main + paths: + - charts/** + +jobs: + release: + runs-on: ubuntu-latest + permissions: + contents: write + pages: write + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Configure Git + run: | + git config user.name "$GITHUB_ACTOR" + git config user.email "$GITHUB_ACTOR@users.noreply.github.com" + + - name: Install Helm + uses: azure/setup-helm@v4 + + - name: Run chart-releaser + uses: helm/chart-releaser-action@v1.6.0 + env: + CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}" diff --git a/charts/terdut-server/.helmignore b/charts/terdut-server/.helmignore new file mode 100644 index 0000000..21846e9 --- /dev/null +++ b/charts/terdut-server/.helmignore @@ -0,0 +1,17 @@ +.DS_Store +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +*.swp +*.bak +*.tmp +*.orig +*~ +.project +.idea/ +*.tmproj +.vscode/ diff --git a/charts/terdut-server/Chart.yaml b/charts/terdut-server/Chart.yaml new file mode 100644 index 0000000..0860e56 --- /dev/null +++ b/charts/terdut-server/Chart.yaml @@ -0,0 +1,6 @@ +apiVersion: v2 +name: terdut-server +description: A Helm chart for Terminal Duty — on-call alert management server +type: application +version: 0.1.0 +appVersion: "latest" diff --git a/charts/terdut-server/templates/_helpers.tpl b/charts/terdut-server/templates/_helpers.tpl new file mode 100644 index 0000000..5192fe6 --- /dev/null +++ b/charts/terdut-server/templates/_helpers.tpl @@ -0,0 +1,34 @@ +{{- define "terdut-server.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{- define "terdut-server.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 }} + +{{- define "terdut-server.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{- define "terdut-server.labels" -}} +helm.sh/chart: {{ include "terdut-server.chart" . }} +{{ include "terdut-server.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{- define "terdut-server.selectorLabels" -}} +app.kubernetes.io/name: {{ include "terdut-server.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} diff --git a/charts/terdut-server/templates/deployment.yaml b/charts/terdut-server/templates/deployment.yaml new file mode 100644 index 0000000..1bba251 --- /dev/null +++ b/charts/terdut-server/templates/deployment.yaml @@ -0,0 +1,48 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "terdut-server.fullname" . }} + labels: + {{- include "terdut-server.labels" . | nindent 4 }} +spec: + replicas: 1 + selector: + matchLabels: + {{- include "terdut-server.selectorLabels" . | nindent 6 }} + template: + metadata: + labels: + {{- include "terdut-server.selectorLabels" . | nindent 8 }} + spec: + enableServiceLinks: false + containers: + - name: terdut-server + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + - name: http + containerPort: {{ .Values.service.port }} + protocol: TCP + env: + - name: TERDUT_ADDR + value: ":{{ .Values.service.port }}" + - name: TERDUT_DB_PATH + value: "/data/terdut.db" + volumeMounts: + - name: data + mountPath: /data + livenessProbe: + httpGet: + path: /healthz + port: http + initialDelaySeconds: 5 + readinessProbe: + httpGet: + path: /healthz + port: http + initialDelaySeconds: 5 + volumes: + - name: data + persistentVolumeClaim: + claimName: {{ .Release.Name }}-data diff --git a/charts/terdut-server/templates/httpproxy.yaml b/charts/terdut-server/templates/httpproxy.yaml new file mode 100644 index 0000000..2d06fd7 --- /dev/null +++ b/charts/terdut-server/templates/httpproxy.yaml @@ -0,0 +1,15 @@ +--- +apiVersion: gateway.networking.k8s.io/v1 +kind: HTTPRoute +metadata: + name: {{ .Release.Name }} +spec: + hostnames: + - {{ .Values.networking.hostname | quote }} + parentRefs: + - name: envoy-main + namespace: envoy-gateway-system + rules: + - backendRefs: + - name: {{ include "terdut-server.fullname" . }} + port: {{ .Values.networking.servicePort }} diff --git a/charts/terdut-server/templates/pvc.yaml b/charts/terdut-server/templates/pvc.yaml new file mode 100644 index 0000000..54ee5af --- /dev/null +++ b/charts/terdut-server/templates/pvc.yaml @@ -0,0 +1,13 @@ +--- +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: {{ .Release.Name }}-data + namespace: {{ .Release.Namespace }} +spec: + storageClassName: {{ .Values.storage.storageClass | quote }} + accessModes: + - ReadWriteOnce + resources: + requests: + storage: {{ .Values.storage.size }} diff --git a/charts/terdut-server/templates/service.yaml b/charts/terdut-server/templates/service.yaml new file mode 100644 index 0000000..fe1fade --- /dev/null +++ b/charts/terdut-server/templates/service.yaml @@ -0,0 +1,16 @@ +--- +apiVersion: v1 +kind: Service +metadata: + name: {{ include "terdut-server.fullname" . }} + labels: + {{- include "terdut-server.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + {{- include "terdut-server.selectorLabels" . | nindent 4 }} diff --git a/charts/terdut-server/values.yaml b/charts/terdut-server/values.yaml new file mode 100644 index 0000000..553ec9d --- /dev/null +++ b/charts/terdut-server/values.yaml @@ -0,0 +1,16 @@ +networking: + hostname: "terdut.example.com" + servicePort: 8080 + +image: + repository: ghcr.io/yeniklas/terdut-server + tag: "latest" + pullPolicy: IfNotPresent + +storage: + size: 1Gi + storageClass: synology-iscsi + +service: + type: ClusterIP + port: 8080