Skip to content

Open-source gym & body-weight tracker, now in the App Store (iPhone + Apple Watch) and as an Android APK. Plan routines, log workouts, see which muscles are trained, import from Strong/Hevy/FitNotes. Self-host it or use it on the phone alone.

Helm: chart for Kubernetes

Arsanandha Aphisitworachorch4e555adef0f3
diff --git a/helm/.helmignore b/helm/.helmignore
new file mode 100644
index 000000000..0e8a0eb36
--- /dev/null
+++ b/helm/.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/helm/Chart.yaml b/helm/Chart.yaml
new file mode 100644
index 000000000..dd9b0ef5c
--- /dev/null
+++ b/helm/Chart.yaml
@@ -0,0 +1,24 @@
+apiVersion: v2
+name: opengym
+description: A self-hosted gym and body-weight tracker you actually own.
+
+# 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.1.0
+
+# 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.
+# It is recommended to use it with quotes.
+appVersion: "1.3.9"
diff --git a/helm/README.md b/helm/README.md
new file mode 100644
index 000000000..30825434c
--- /dev/null
+++ b/helm/README.md
@@ -0,0 +1,158 @@
+# openGym Helm chart
+
+Installs openGym on Kubernetes: the API and the web container in a single pod, two PVCs, a
+Service, and optionally an Ingress or a Gateway API HTTPRoute with a cert-manager certificate. It
+deploys the same thing as the plain manifests in [`kubernetes/`](../kubernetes), but lets you set
+everything from values.
+
+Read [docs/SELF_HOSTING.md](../docs/SELF_HOSTING.md) first. The passkey requirements (HTTPS, and
+`RP_ID`/`ORIGIN` matching the hostname people open) and the settings in
+[`.env.example`](../.env.example) apply here unchanged. Kubernetes-specific notes are in
+[docs/SELF_HOSTING_KUBERNETES.md](../docs/SELF_HOSTING_KUBERNETES.md).
+
+## Install
+
+```bash
+git clone https://github.com/DuarteSantos8/openGym
+cd openGym
+
+helm install opengym ./helm -n fitness --create-namespace \
+ --set api.env.RP_ID=gym.example.com \
+ --set api.env.ORIGIN=https://gym.example.com \
+ --set ingress.enabled=true \
+ --set ingress.hosts[0].host=gym.example.com \
+ --set ingress.hosts[0].paths[0].path=/ \
+ --set ingress.hosts[0].paths[0].pathType=Prefix
+```
+
+For anything more than a quick test, put your settings in a values file:
+
+```bash
+helm install opengym ./helm -n fitness --create-namespace -f my-values.yaml
+helm upgrade opengym ./helm -n fitness -f my-values.yaml
+helm test opengym -n fitness # calls /api/health through the web container
+```
+
+Pods restart on their own when the ConfigMap or Secret changes.
+
+## Exposing it
+
+Pick one of the two routing options. Both send traffic to the Service on port 80.
+
+### Ingress
+
+```yaml
+ingress:
+ enabled: true
+ className: nginx
+ annotations:
+ cert-manager.io/cluster-issuer: letsencrypt
+ # ingress-nginx allows 1m request bodies by default. Photo and video uploads need more:
+ nginx.ingress.kubernetes.io/proxy-body-size: 48m
+ hosts:
+ - host: gym.example.com
+ paths:
+ - path: /
+ pathType: Prefix
+ tls:
+ - secretName: opengym-tls
+ hosts:
+ - gym.example.com
+```
+
+### Gateway API (HTTPRoute)
+
+This is the setup the plain manifests use: Envoy Gateway, with a cert-manager Certificate.
+
+```yaml
+httpRoute:
+ enabled: true
+ parentRefs:
+ - name: eg
+ namespace: envoy-gateway-system
+ sectionName: https
+ hostnames:
+ - gym.example.com
+
+certificate:
+ enabled: true
+ secretName: opengym-tls
+ issuerRef:
+ kind: ClusterIssuer
+ name: letsencrypt
+ dnsNames:
+ - gym.example.com
+ referenceGrant:
+ enabled: true # lets the Gateway in another namespace read the certificate Secret
+ gatewayNamespace: envoy-gateway-system
+```
+
+### Neither (local test)
+
+```bash
+helm install opengym ./helm --set api.env.RP_ID=localhost --set api.env.ORIGIN=http://localhost:8080
+kubectl port-forward svc/opengym 8080:80
+```
+
+Browsers allow passkeys over plain `http://` only on `localhost`.
+
+## Configuration
+
+### App settings
+
+| Values key | Ends up in | Notes |
+|---|---|---|
+| `api.env.*` | ConfigMap `<release>-api` | Every setting from `.env.example`, under the same name. An empty value is left out, so the app default applies. `PORT` comes from `api.service.port`. |
+| `api.secretEnv.*` | Secret `<release>-api` | `ADMIN_UIDS`. You can add more keys; each becomes an env var. |
+| `web.env.*` | ConfigMap `<release>-web` | `BASE_PATH`, `MEDIA_UPLOAD_MAX`, `CF_CONNECTING_IP`. The chart sets `NGINX_PORT`, `PORT` and `BACKEND=127.0.0.1` itself. |
+
+`TRUST_PROXY` stays off on purpose. The web container overwrites `X-Forwarded-For` with the
+address it was reached from, which here is the ingress or gateway pod. Turning `TRUST_PROXY` on
+changes nothing for the sign-in throttle, but any pod that reaches port 3000 directly could then
+choose the address that gets recorded.
+
+### Storage
+
+| Key | Default | |
+|---|---|---|
+| `persistence.data.size` | `2Gi` | Accounts, passkeys, workouts, uploads, session secret. **Back this up.** |
+| `persistence.media.size` | `2Gi` | Exercise images and GIFs (~140 MB). The init container downloads them again if they are lost. |
+| `persistence.*.storageClass` | `""` | `""` uses the cluster default. |
+| `persistence.*.existingClaim` | `""` | Uses a PVC you already have instead of creating one. |
+
+The chart keeps both PVCs on `helm uninstall` (`helm.sh/resource-policy: keep`). To get rid of
+the data, delete them by hand.
+
+### Images
+
+`api.image.tag` and `web.image.tag` default to `1.3.9`. Change them together: an API and a web
+image from different releases aren't meant to run side by side.
+
+### Other values
+
+`imagePullSecrets`, `serviceAccount`, `podAnnotations`, `podLabels`, `podSecurityContext`,
+`securityContext`, `nodeSelector`, `tolerations`, `affinity`, `api/web.resources`,
+`api/web.livenessProbe`/`readinessProbe` and `mediaDownload.image`/`resources` work the way they
+do in any Helm chart. See [`values.yaml`](values.yaml) for the full list.
+
+## Always one replica
+
+The API stores its data in JSON files on a single `ReadWriteOnce` volume, so the chart always runs
+one replica with the `Recreate` strategy, and there is no autoscaler. A second API process would be
+a second writer to the same files.
+
+## Moving from `kubectl apply -k kubernetes/`
+
+Helm refuses to take over resources it didn't create. Remove the old Deployment, Service,
+HTTPRoute, Certificate and ReferenceGrant, but **keep the PVCs**: deleting them deletes the data.
+Point the chart at the existing claims instead:
+
+```bash
+kubectl -n fitness delete deployment/opengym service/opengym httproute/opengym \
+ certificate/opengym-tls referencegrant/allow-gateway
+helm install opengym ./helm -n fitness -f my-values.yaml \
+ --set persistence.data.existingClaim=opengym-data \
+ --set persistence.media.existingClaim=opengym-media
+```
+
+The site is unreachable between the delete and the moment the new pod is ready.
diff --git a/helm/templates/NOTES.txt b/helm/templates/NOTES.txt
new file mode 100644
index 000000000..5a67c3a0a
--- /dev/null
+++ b/helm/templates/NOTES.txt
@@ -0,0 +1,19 @@
+openGym {{ .Chart.AppVersion }} is installed.
+{{- if .Values.ingress.enabled }}
+{{- range $host := .Values.ingress.hosts }}
+ {{- range .paths }}
+ http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }}
+ {{- end }}
+{{- end }}
+{{- else if .Values.httpRoute.enabled }}
+{{- range .Values.httpRoute.hostnames }}
+ https://{{ . }}/
+{{- end }}
+{{- else }}
+ No Ingress or HTTPRoute. To try it locally (passkeys work on localhost only):
+ kubectl --namespace {{ .Release.Namespace }} port-forward svc/{{ include "helm.fullname" . }} 8080:{{ .Values.service.port }}
+ then set api.env.RP_ID=localhost and api.env.ORIGIN=http://localhost:8080
+{{- end }}
+
+Passkeys need HTTPS and RP_ID ({{ .Values.api.env.RP_ID }}) equal to the hostname people open.
+Back up the {{ .Values.persistence.data.existingClaim | default (printf "%s-data" (include "helm.fullname" .)) }} volume: it is the whole instance.
diff --git a/helm/templates/_helpers.tpl b/helm/templates/_helpers.tpl
new file mode 100644
index 000000000..a1745f5e5
--- /dev/null
+++ b/helm/templates/_helpers.tpl
@@ -0,0 +1,63 @@
+{{/*
+Expand the name of the chart.
+*/}}
+{{- define "helm.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 "helm.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 "helm.chart" -}}
+{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
+{{- end }}
+
+{{/*
+Common labels
+*/}}
+{{- define "helm.labels" -}}
+helm.sh/chart: {{ include "helm.chart" . }}
+{{ include "helm.selectorLabels" . }}
+{{- if .Chart.AppVersion }}
+app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
+{{- end }}
+app.kubernetes.io/managed-by: {{ .Release.Service }}
+{{- end }}
+
+{{/*
+Selector labels
+*/}}
+{{- define "helm.selectorLabels" -}}
+app: {{ include "helm.name" . }}
+app.kubernetes.io/name: {{ include "helm.name" . }}
+app.kubernetes.io/instance: {{ .Release.Name }}
+{{- end }}
+
+{{/*
+Create the name of the service account to use
+*/}}
+{{- define "helm.serviceAccountName" -}}
+{{- if .Values.serviceAccount.create }}
+{{- default (include "helm.fullname" .) .Values.serviceAccount.name }}
+{{- else }}
+{{- default "default" .Values.serviceAccount.name }}
+{{- end }}
+{{- end }}
diff --git a/helm/templates/certificate.yaml b/helm/templates/certificate.yaml
new file mode 100644
index 000000000..8a5571686
--- /dev/null
+++ b/helm/templates/certificate.yaml
@@ -0,0 +1,35 @@
+{{- with .Values.certificate }}
+{{- if .enabled }}
+apiVersion: cert-manager.io/v1
+kind: Certificate
+metadata:
+ name: {{ .secretName }}
+ labels:
+ {{- include "helm.labels" $ | nindent 4 }}
+spec:
+ dnsNames:
+ {{- toYaml .dnsNames | nindent 4 }}
+ issuerRef:
+ {{- toYaml .issuerRef | nindent 4 }}
+ secretName: {{ .secretName }}
+{{- if .referenceGrant.enabled }}
+---
+# A Gateway in another namespace needs this grant to read the certificate Secret.
+apiVersion: gateway.networking.k8s.io/v1beta1
+kind: ReferenceGrant
+metadata:
+ name: {{ include "helm.fullname" $ }}-tls
+ labels:
+ {{- include "helm.labels" $ | nindent 4 }}
+spec:
+ from:
+ - group: gateway.networking.k8s.io
+ kind: Gateway
+ namespace: {{ .referenceGrant.gatewayNamespace }}
+ to:
+ - group: ""
+ kind: Secret
+ name: {{ .secretName }}
+{{- end }}
+{{- end }}
+{{- end }}
diff --git a/helm/templates/configmap.yaml b/helm/templates/configmap.yaml
new file mode 100644
index 000000000..8ff8e0c2a
--- /dev/null
+++ b/helm/templates/configmap.yaml
@@ -0,0 +1,30 @@
+apiVersion: v1
+kind: ConfigMap
+metadata:
+ name: {{ include "helm.fullname" . }}-api
+ labels:
+ {{- include "helm.labels" . | nindent 4 }}
+data:
+ PORT: {{ .Values.api.service.port | quote }}
+ {{- range $k, $v := .Values.api.env }}
+ {{- if ne (toString $v) "" }}
+ {{ $k }}: {{ toString $v | quote }}
+ {{- end }}
+ {{- end }}
+---
+apiVersion: v1
+kind: ConfigMap
+metadata:
+ name: {{ include "helm.fullname" . }}-web
+ labels:
+ {{- include "helm.labels" . | nindent 4 }}
+data:
+ NGINX_PORT: {{ .Values.web.service.port | quote }}
+ PORT: {{ .Values.api.service.port | quote }}
+ # Both containers share the pod's network, so the API is on localhost.
+ BACKEND: "127.0.0.1"
+ {{- range $k, $v := .Values.web.env }}
+ {{- if ne (toString $v) "" }}
+ {{ $k }}: {{ toString $v | quote }}
+ {{- end }}
+ {{- end }}
diff --git a/helm/templates/deployment.yaml b/helm/templates/deployment.yaml
new file mode 100644
index 000000000..6087d436c
--- /dev/null
+++ b/helm/templates/deployment.yaml
@@ -0,0 +1,124 @@
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+ name: {{ include "helm.fullname" . }}
+ labels:
+ {{- include "helm.labels" . | nindent 4 }}
+spec:
+ # One writer: the API's data is JSON files on a ReadWriteOnce volume. Recreate, so the old pod
+ # lets go of the volume before the new one mounts it.
+ replicas: 1
+ strategy:
+ type: Recreate
+ selector:
+ matchLabels:
+ {{- include "helm.selectorLabels" . | nindent 6 }}
+ template:
+ metadata:
+ annotations:
+ checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
+ checksum/secret: {{ include (print $.Template.BasePath "/secret.yaml") . | sha256sum }}
+ {{- with .Values.podAnnotations }}
+ {{- toYaml . | nindent 8 }}
+ {{- end }}
+ labels:
+ {{- include "helm.labels" . | nindent 8 }}
+ {{- with .Values.podLabels }}
+ {{- toYaml . | nindent 8 }}
+ {{- end }}
+ spec:
+ {{- with .Values.imagePullSecrets }}
+ imagePullSecrets:
+ {{- toYaml . | nindent 8 }}
+ {{- end }}
+ serviceAccountName: {{ include "helm.serviceAccountName" . }}
+ securityContext:
+ {{- toYaml .Values.podSecurityContext | nindent 8 }}
+ initContainers:
+ # The exercise images and GIFs, one time (~140 MB) — the same download as the media
+ # service in docker-compose.yml. They are © Gym visual (https://gymvisual.com/), used
+ # under the exercises-dataset's terms and fetched from upstream, not redistributed by
+ # openGym; see NOTICE.md.
+ - name: media-download
+ image: {{ .Values.mediaDownload.image }}
+ command: [ "/bin/sh", "-c" ]
+ args:
+ - |
+ mkdir -p /out/img /out/gif
+ if [ -z "$(ls -A /out/img 2>/dev/null)" ]; then
+ git clone --depth 1 https://github.com/hasaneyldrm/exercises-dataset /tmp/ds
+ cp /tmp/ds/images/*.jpg /out/img/ && cp /tmp/ds/videos/*.gif /out/gif/
+ fi
+ volumeMounts:
+ - name: media
+ mountPath: /out
+ resources:
+ {{- toYaml .Values.mediaDownload.resources | nindent 12 }}
+ containers:
+ - name: api
+ securityContext:
+ {{- toYaml .Values.securityContext | nindent 12 }}
+ image: "{{ .Values.api.image.repository }}:{{ .Values.api.image.tag | default .Chart.AppVersion }}"
+ imagePullPolicy: {{ .Values.api.image.pullPolicy }}
+ envFrom:
+ - configMapRef:
+ name: {{ include "helm.fullname" . }}-api
+ - secretRef:
+ name: {{ include "helm.fullname" . }}-api
+ ports:
+ - name: api
+ containerPort: {{ .Values.api.service.port }}
+ protocol: TCP
+ livenessProbe:
+ {{- toYaml .Values.api.livenessProbe | nindent 12 }}
+ readinessProbe:
+ {{- toYaml .Values.api.readinessProbe | nindent 12 }}
+ resources:
+ {{- toYaml .Values.api.resources | nindent 12 }}
+ volumeMounts:
+ - name: data
+ mountPath: {{ .Values.api.env.DATA_DIR | default "/data" }}
+ - name: web
+ securityContext:
+ {{- toYaml .Values.securityContext | nindent 12 }}
+ image: "{{ .Values.web.image.repository }}:{{ .Values.web.image.tag | default .Chart.AppVersion }}"
+ imagePullPolicy: {{ .Values.web.image.pullPolicy }}
+ envFrom:
+ - configMapRef:
+ name: {{ include "helm.fullname" . }}-web
+ ports:
+ - name: web
+ containerPort: {{ .Values.web.service.port }}
+ protocol: TCP
+ livenessProbe:
+ {{- toYaml .Values.web.livenessProbe | nindent 12 }}
+ readinessProbe:
+ {{- toYaml .Values.web.readinessProbe | nindent 12 }}
+ resources:
+ {{- toYaml .Values.web.resources | nindent 12 }}
+ volumeMounts:
+ - name: media
+ mountPath: /usr/share/nginx/html/img
+ subPath: img
+ - name: media
+ mountPath: /usr/share/nginx/html/gif
+ subPath: gif
+ volumes:
+ - name: data
+ persistentVolumeClaim:
+ claimName: {{ .Values.persistence.data.existingClaim | default (printf "%s-data" (include "helm.fullname" .)) }}
+ - name: media
+ persistentVolumeClaim:
+ claimName: {{ .Values.persistence.media.existingClaim | default (printf "%s-media" (include "helm.fullname" .)) }}
+ {{- with .Values.nodeSelector }}
+ nodeSelector:
+ {{- toYaml . | nindent 8 }}
+ {{- end }}
+ {{- with .Values.affinity }}
+ affinity:
+ {{- toYaml . | nindent 8 }}
+ {{- end }}
+ {{- with .Values.tolerations }}
+ tolerations:
+ {{- toYaml . | nindent 8 }}
+ {{- end }}
diff --git a/helm/templates/httproute.yaml b/helm/templates/httproute.yaml
new file mode 100644
index 000000000..24e08c159
--- /dev/null
+++ b/helm/templates/httproute.yaml
@@ -0,0 +1,25 @@
+{{- if .Values.httpRoute.enabled }}
+apiVersion: gateway.networking.k8s.io/v1
+kind: HTTPRoute
+metadata:
+ name: {{ include "helm.fullname" . }}
+ labels:
+ {{- include "helm.labels" . | nindent 4 }}
+ {{- with .Values.httpRoute.annotations }}
+ annotations:
+ {{- toYaml . | nindent 4 }}
+ {{- end }}
+spec:
+ parentRefs:
+ {{- toYaml .Values.httpRoute.parentRefs | nindent 4 }}
+ hostnames:
+ {{- toYaml .Values.httpRoute.hostnames | nindent 4 }}
+ rules:
+ - matches:
+ - path:
+ type: PathPrefix
+ value: /
+ backendRefs:
+ - name: {{ include "helm.fullname" . }}
+ port: {{ .Values.service.port }}
+{{- end }}
diff --git a/helm/templates/ingress.yaml b/helm/templates/ingress.yaml
new file mode 100644
index 000000000..f935357f7
--- /dev/null
+++ b/helm/templates/ingress.yaml
@@ -0,0 +1,42 @@
+{{- if .Values.ingress.enabled -}}
+{{- $fullName := include "helm.fullname" . -}}
+apiVersion: networking.k8s.io/v1
+kind: Ingress
+metadata:
+ name: {{ $fullName }}
+ labels:
+ {{- include "helm.labels" . | nindent 4 }}
+ {{- with .Values.ingress.annotations }}
+ annotations:
+ {{- toYaml . | nindent 4 }}
+ {{- end }}
+spec:
+ {{- with .Values.ingress.className }}
+ ingressClassName: {{ . }}
+ {{- end }}
+ {{- 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: {{ .path }}
+ pathType: {{ .pathType }}
+ backend:
+ service:
+ name: {{ $fullName }}
+ port:
+ name: web
+ {{- end }}
+ {{- end }}
+{{- end }}
diff --git a/helm/templates/pvc.yaml b/helm/templates/pvc.yaml
new file mode 100644
index 000000000..c8e00ed85
--- /dev/null
+++ b/helm/templates/pvc.yaml
@@ -0,0 +1,23 @@
+{{- range $name := list "data" "media" }}
+{{- $p := index $.Values.persistence $name }}
+{{- if not $p.existingClaim }}
+---
+apiVersion: v1
+kind: PersistentVolumeClaim
+metadata:
+ name: {{ include "helm.fullname" $ }}-{{ $name }}
+ labels:
+ {{- include "helm.labels" $ | nindent 4 }}
+ annotations:
+ helm.sh/resource-policy: keep
+spec:
+ accessModes:
+ {{- toYaml $p.accessModes | nindent 4 }}
+ {{- with $p.storageClass }}
+ storageClassName: {{ . | quote }}
+ {{- end }}
+ resources:
+ requests:
+ storage: {{ $p.size }}
+{{- end }}
+{{- end }}
diff --git a/helm/templates/secret.yaml b/helm/templates/secret.yaml
new file mode 100644
index 000000000..fe9344ef2
--- /dev/null
+++ b/helm/templates/secret.yaml
@@ -0,0 +1,13 @@
+apiVersion: v1
+kind: Secret
+metadata:
+ name: {{ include "helm.fullname" . }}-api
+ labels:
+ {{- include "helm.labels" . | nindent 4 }}
+type: Opaque
+data:
+ {{- range $k, $v := .Values.api.secretEnv }}
+ {{- if ne (toString $v) "" }}
+ {{ $k }}: {{ toString $v | b64enc }}
+ {{- end }}
+ {{- end }}
diff --git a/helm/templates/service.yaml b/helm/templates/service.yaml
new file mode 100644
index 000000000..f1a295ae1
--- /dev/null
+++ b/helm/templates/service.yaml
@@ -0,0 +1,15 @@
+apiVersion: v1
+kind: Service
+metadata:
+ name: {{ include "helm.fullname" . }}
+ labels:
+ {{- include "helm.labels" . | nindent 4 }}
+spec:
+ type: {{ .Values.service.type }}
+ ports:
+ - port: {{ .Values.service.port }}
+ targetPort: web
+ protocol: TCP
+ name: web
+ selector:
+ {{- include "helm.selectorLabels" . | nindent 4 }}
diff --git a/helm/templates/serviceaccount.yaml b/helm/templates/serviceaccount.yaml
new file mode 100644
index 000000000..d47046559
--- /dev/null
+++ b/helm/templates/serviceaccount.yaml
@@ -0,0 +1,13 @@
+{{- if .Values.serviceAccount.create -}}
+apiVersion: v1
+kind: ServiceAccount
+metadata:
+ name: {{ include "helm.serviceAccountName" . }}
+ labels:
+ {{- include "helm.labels" . | nindent 4 }}
+ {{- with .Values.serviceAccount.annotations }}
+ annotations:
+ {{- toYaml . | nindent 4 }}
+ {{- end }}
+automountServiceAccountToken: {{ .Values.serviceAccount.automount }}
+{{- end }}
diff --git a/helm/templates/tests/test-connection.yaml b/helm/templates/tests/test-connection.yaml
new file mode 100644
index 000000000..f3a11950d
--- /dev/null
+++ b/helm/templates/tests/test-connection.yaml
@@ -0,0 +1,16 @@
+apiVersion: v1
+kind: Pod
+metadata:
+ name: "{{ include "helm.fullname" . }}-test-connection"
+ labels:
+ {{- include "helm.labels" . | nindent 4 }}
+ annotations:
+ "helm.sh/hook": test
+spec:
+ containers:
+ - name: wget
+ image: busybox
+ command: ['wget']
+ # Through web's /api proxy, so it checks both containers.
+ args: ['-qO-', '{{ include "helm.fullname" . }}:{{ .Values.service.port }}/api/health']
+ restartPolicy: Never
diff --git a/helm/values.yaml b/helm/values.yaml
new file mode 100644
index 000000000..ec14eb672
--- /dev/null
+++ b/helm/values.yaml
@@ -0,0 +1,189 @@
+# openGym Helm chart. Mirrors kubernetes/ (the plain manifests); docs/SELF_HOSTING_KUBERNETES.md
+# explains the choices. Always one replica: the API keeps its data in JSON files on one volume,
+# so a second pod would be a second writer.
+
+imagePullSecrets: []
+nameOverride: ""
+fullnameOverride: ""
+
+serviceAccount:
+ create: true
+ # openGym never talks to the Kubernetes API.
+ automount: false
+ annotations: {}
+ name: ""
+
+podAnnotations: {}
+podLabels: {}
+
+podSecurityContext: {}
+ # fsGroup: 2000
+
+securityContext: {}
+ # capabilities:
+ # drop:
+ # - ALL
+ # runAsNonRoot: true
+
+service:
+ type: ClusterIP
+ port: 80
+
+# Both PVCs are kept on `helm uninstall` (helm.sh/resource-policy: keep). Delete them by hand
+# if you really mean to.
+persistence:
+ # Accounts, passkeys, per-user state, session secret, uploads. BACK THIS UP.
+ data:
+ existingClaim: "" # use a PVC you already have instead of creating one
+ storageClass: "" # "" = cluster default
+ accessModes: [ReadWriteOnce]
+ size: 2Gi
+ # Exercise images and GIFs (~140 MB), downloaded once by the init container.
+ media:
+ existingClaim: ""
+ storageClass: ""
+ accessModes: [ReadWriteOnce]
+ size: 2Gi
+
+# Classic Ingress. Passkeys need HTTPS and a host equal to api.env.RP_ID.
+ingress:
+ enabled: false
+ className: ""
+ annotations: {}
+ # cert-manager.io/cluster-issuer: letsencrypt
+ # ingress-nginx caps request bodies at 1m; uploads need MEDIA_UPLOAD_MAX (48m):
+ # nginx.ingress.kubernetes.io/proxy-body-size: 48m
+ hosts:
+ - host: opengym.example.com
+ paths:
+ - path: /
+ pathType: Prefix
+ tls: []
+ # - secretName: opengym-tls
+ # hosts:
+ # - opengym.example.com
+
+# Gateway API HTTPRoute (what kubernetes/httproute.yaml does).
+httpRoute:
+ enabled: false
+ annotations: {}
+ parentRefs:
+ - name: eg
+ namespace: envoy-gateway-system
+ sectionName: https
+ hostnames:
+ - opengym.example.com
+
+# cert-manager Certificate for the HTTPRoute's listener. Ingress users usually want the
+# cert-manager.io/cluster-issuer annotation instead.
+certificate:
+ enabled: false
+ secretName: opengym-tls
+ issuerRef:
+ kind: ClusterIssuer
+ name: letsencrypt
+ dnsNames:
+ - opengym.example.com
+ # Lets a Gateway in another namespace read the certificate Secret. Drop if your listener
+ # carries its own (e.g. wildcard) certificate.
+ referenceGrant:
+ enabled: true
+ gatewayNamespace: envoy-gateway-system
+
+nodeSelector: {}
+
+tolerations: []
+
+affinity: {}
+
+# Init container that fetches the exercise media once into the media volume.
+mediaDownload:
+ image: alpine/git:2.52.0
+ resources:
+ requests:
+ memory: 128Mi
+ limits:
+ memory: 256Mi
+
+api:
+ image:
+ repository: ghcr.io/duartesantos8/opengym-api
+ pullPolicy: IfNotPresent
+ tag: 1.3.9 # keep in step with web.image.tag
+ service:
+ port: 3000
+ resources:
+ requests:
+ memory: 128Mi
+ limits:
+ memory: 512Mi
+ # Rendered into the api ConfigMap (see .env.example for what each does).
+ # An empty value is left out, so the app default applies. PORT comes from api.service.port.
+ env:
+ DATA_DIR: /data
+ RP_ID: opengym.example.com
+ ORIGIN: https://opengym.example.com
+ RP_NAME: openGym
+ INVITE_ONLY: "" # "1" = signup needs an invite code
+ ALLOW_GUEST: "" # "0" = no "Continue without account"
+ DEFAULT_LANG: "" # en, de, pt-BR, th, ...
+ PASSWORD_LOGIN: "" # "1" = password sign-in next to passkeys
+ # TRUST_PROXY stays off here on purpose, see kubernetes/deployment.yaml.
+ TRUST_PROXY: ""
+ SESSION_DAYS: "" # default 90
+ AUDIT_LOG: "" # "0" = off
+ AUDIT_MAX: "" # default 5000
+ AUDIT_DAYS: "" # default 90
+ AUDIT_IP: "" # off | net | full
+ MEDIA_UPLOADS: "" # "0" = off
+ MEDIA_QUOTA_MB: ""
+ MEDIA_IMAGE_MAX_MB: ""
+ MEDIA_GIF_MAX_MB: ""
+ MEDIA_VIDEO_MAX_MB: ""
+ MEDIA_VIDEO_MAX_SEC: ""
+ MEDIA_GC_GRACE_DAYS: ""
+ MEDIA_UPLOADS_PER_HOUR: ""
+ MEDIA_MIN_FREE_MB: ""
+ VAPID_SUBJECT: "" # e.g. mailto:[email protected]
+ COACH_DISABLED: "" # "1" = Coach kill switch
+ COACH_JOB_TIMEOUT_MS: ""
+ # Rendered into the Secret. Same rule: empty = left out.
+ secretEnv:
+ ADMIN_UIDS: "" # comma-separated user ids from db.json
+ livenessProbe:
+ httpGet:
+ path: /api/health
+ port: api
+ initialDelaySeconds: 30
+ readinessProbe:
+ httpGet:
+ path: /api/health
+ port: api
+
+web:
+ image:
+ repository: ghcr.io/duartesantos8/opengym-web
+ pullPolicy: IfNotPresent
+ tag: 1.3.9
+ service:
+ port: 80
+ # Rendered into the web ConfigMap. NGINX_PORT, PORT and BACKEND (127.0.0.1, same pod) are set
+ # by the chart.
+ env:
+ BASE_PATH: "" # "/gym" if your proxy passes a subpath prefix through
+ MEDIA_UPLOAD_MAX: "" # default 48m, keep above MEDIA_VIDEO_MAX_MB
+ CF_CONNECTING_IP: "" # "$http_cf_connecting_ip" only behind Cloudflare
+ resources:
+ requests:
+ memory: 32Mi
+ limits:
+ memory: 128Mi
+ livenessProbe:
+ httpGet:
+ path: /
+ port: web
+ initialDelaySeconds: 30
+ readinessProbe:
+ httpGet:
+ path: /
+ port: web