From 55bf81ff149b9114f556d21aa7fbe8e12919381d Mon Sep 17 00:00:00 2001 From: Olof Pettersson Date: Wed, 10 Dec 2025 20:29:40 +0100 Subject: [PATCH] Initial chart commit --- .gitea/workflows/publish-chart.yaml | 43 ++++++++++++++++++++ Chart.yaml | 11 +++++ templates/_helpers.tpl | 62 +++++++++++++++++++++++++++++ templates/configmap.yaml | 11 +++++ templates/deployment-app.yaml | 33 +++++++++++++++ templates/deployment-worker.yaml | 33 +++++++++++++++ templates/ingress.yaml | 0 templates/secret.yaml | 8 ++++ templates/service.yaml | 16 ++++++++ values.yaml | 33 +++++++++++++++ 10 files changed, 250 insertions(+) create mode 100644 .gitea/workflows/publish-chart.yaml create mode 100644 Chart.yaml create mode 100644 templates/_helpers.tpl create mode 100644 templates/configmap.yaml create mode 100644 templates/deployment-app.yaml create mode 100644 templates/deployment-worker.yaml create mode 100644 templates/ingress.yaml create mode 100644 templates/secret.yaml create mode 100644 templates/service.yaml create mode 100644 values.yaml diff --git a/.gitea/workflows/publish-chart.yaml b/.gitea/workflows/publish-chart.yaml new file mode 100644 index 0000000..e0fc6a9 --- /dev/null +++ b/.gitea/workflows/publish-chart.yaml @@ -0,0 +1,43 @@ +name: Publish Helm Chart + +on: + push: + branches: + - main + paths: + - 'Chart.yaml' # Only trigger if version changes or main is updated + +jobs: + publish: + runs-on: ubuntu-latest # Or whatever label your runner uses + container: + image: alpine/helm:3.12.0 # Use an image with Helm pre-installed + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Install Dependencies + run: helm dependency update . + + - name: Package Chart + run: helm package . + + - name: Login to Registry + run: | + # Gitea automatically provides the token and actor variables + echo ${{ secrets.GITEA_TOKEN }} | helm registry login ${{ gitea.server_url }} \ + --username ${{ gitea.actor }} \ + --password-stdin + + - name: Push to Gitea Registry + run: | + # Clean the protocol (https://) from the URL for OCI + DOMAIN=${{ gitea.server_url }} + DOMAIN=${DOMAIN#*//} + + # Find the packaged .tgz file + CHART_FILE=$(ls *.tgz) + + # Push to the OCI registry + # URL Format: oci:////charts + helm push $CHART_FILE oci://$DOMAIN/${{ gitea.actor }}/charts \ No newline at end of file diff --git a/Chart.yaml b/Chart.yaml new file mode 100644 index 0000000..013651c --- /dev/null +++ b/Chart.yaml @@ -0,0 +1,11 @@ +apiVersion: v2 +name: solidtime +description: A Helm chart for Solidtime Time Tracker +type: application +version: 0.1.0 +appVersion: "1.0.0" +dependencies: + - name: postgresql + version: 12.x.x + repository: https://charts.bitnami.com/bitnami + condition: postgresql.enabled \ No newline at end of file diff --git a/templates/_helpers.tpl b/templates/_helpers.tpl new file mode 100644 index 0000000..69d4c50 --- /dev/null +++ b/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "solidtime.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 "solidtime.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 "solidtime.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "solidtime.labels" -}} +helm.sh/chart: {{ include "solidtime.chart" . }} +{{ include "solidtime.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "solidtime.selectorLabels" -}} +app.kubernetes.io/name: {{ include "solidtime.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "solidtime.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "solidtime.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/templates/configmap.yaml b/templates/configmap.yaml new file mode 100644 index 0000000..ff6c510 --- /dev/null +++ b/templates/configmap.yaml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ include "solidtime.fullname" . }}-env +data: + APP_URL: "https://{{ .Values.domain }}" + DB_CONNECTION: "pgsql" + DB_HOST: "{{ .Release.Name }}-postgresql" # Connects to the dependency + DB_PORT: "5432" + DB_DATABASE: "{{ .Values.postgresql.auth.database }}" + DB_USERNAME: "{{ .Values.postgresql.auth.username }}" \ No newline at end of file diff --git a/templates/deployment-app.yaml b/templates/deployment-app.yaml new file mode 100644 index 0000000..646c6a0 --- /dev/null +++ b/templates/deployment-app.yaml @@ -0,0 +1,33 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "solidtime.fullname" . }}-app +spec: + replicas: 1 + selector: + matchLabels: + app: solidtime-app + template: + metadata: + labels: + app: solidtime-app + spec: + containers: + - name: solidtime + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + ports: + - containerPort: 80 + envFrom: + - configMapRef: + name: {{ include "solidtime.fullname" . }}-env + env: + - name: DB_PASSWORD + valueFrom: + secretKeyRef: + name: {{ include "solidtime.fullname" . }}-secret + key: DB_PASSWORD + - name: APP_KEY + valueFrom: + secretKeyRef: + name: {{ include "solidtime.fullname" . }}-secret + key: APP_KEY \ No newline at end of file diff --git a/templates/deployment-worker.yaml b/templates/deployment-worker.yaml new file mode 100644 index 0000000..0bf06b6 --- /dev/null +++ b/templates/deployment-worker.yaml @@ -0,0 +1,33 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "solidtime.fullname" . }}-worker +spec: + replicas: 1 + selector: + matchLabels: + app: solidtime-worker + template: + metadata: + labels: + app: solidtime-worker + spec: + containers: + - name: worker + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + # Override the default command to run the queue worker + command: ["php", "/var/www/html/artisan", "queue:work"] + envFrom: + - configMapRef: + name: {{ include "solidtime.fullname" . }}-env + env: + - name: DB_PASSWORD + valueFrom: + secretKeyRef: + name: {{ include "solidtime.fullname" . }}-secret + key: DB_PASSWORD + - name: APP_KEY + valueFrom: + secretKeyRef: + name: {{ include "solidtime.fullname" . }}-secret + key: APP_KEY \ No newline at end of file diff --git a/templates/ingress.yaml b/templates/ingress.yaml new file mode 100644 index 0000000..e69de29 diff --git a/templates/secret.yaml b/templates/secret.yaml new file mode 100644 index 0000000..38c9594 --- /dev/null +++ b/templates/secret.yaml @@ -0,0 +1,8 @@ +apiVersion: v1 +kind: Secret +metadata: + name: {{ include "solidtime.fullname" . }}-secret +type: Opaque +stringData: + APP_KEY: {{ .Values.appKey | quote }} + DB_PASSWORD: {{ .Values.postgresql.auth.password | quote }} \ No newline at end of file diff --git a/templates/service.yaml b/templates/service.yaml new file mode 100644 index 0000000..6c2ea36 --- /dev/null +++ b/templates/service.yaml @@ -0,0 +1,16 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "solidtime.fullname" . }} + labels: + {{- include "solidtime.labels" . | nindent 4 }} +spec: + type: ClusterIP + ports: + - port: 80 + targetPort: 80 + protocol: TCP + name: http + selector: + # Matches the labels in deployment-app.yaml + app: solidtime-app \ No newline at end of file diff --git a/values.yaml b/values.yaml new file mode 100644 index 0000000..aad5aac --- /dev/null +++ b/values.yaml @@ -0,0 +1,33 @@ +domain: "time.northernlighthouseinteractive.com" + +image: + repository: solidtime/solidtime + pullPolicy: IfNotPresent + tag: "latest" # Pin this to a specific version in production! + +# Generates the Laravel App Key. Change this! +# Run `php artisan key:generate --show` locally to get one. +appKey: "base64:YOUR_GENERATED_KEY_HERE" + +ingress: + enabled: true + className: "nginx" + annotations: + cert-manager.io/cluster-issuer: "letsencrypt-prod" + hosts: + - host: time.northernlighthouseinteractive.com + paths: + - path: / + pathType: Prefix + +# Database Dependency Configuration +postgresql: + enabled: true + auth: + username: solidtime + password: securepassword + database: solidtime + primary: + persistence: + enabled: true + size: 10Gi \ No newline at end of file