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.
JavaScript apple-watchbodyweightdockerfitnessfitness-trackergymhealthiosmcpnodejspasskeysprogressive-web-applicationspwareactself-hostedself-hostingvitewebauthnweightliftingworkout-tracker
Follow-up to #304: the Kubernetes manifests create their namespace, pin the images to a release and the media download to a git version, and the guide says why TRUST_PROXY stays off behind a gateway
Duarte Santoscbad8fd8a020
diff --git a/docs/SELF_HOSTING_KUBERNETES.md b/docs/SELF_HOSTING_KUBERNETES.mdindex 3efc12c85..5616471a3 100644--- a/docs/SELF_HOSTING_KUBERNETES.md+++ b/docs/SELF_HOSTING_KUBERNETES.md@@ -26,7 +26,8 @@ kubectl apply -k kubernetes/Notes:-- The manifests use the `fitness` namespace (`kubernetes/kustomization.yaml`) and a Gateway+- The manifests create and use the `fitness` namespace (`kubernetes/namespace.yaml`, set on every+ resource by `kubernetes/kustomization.yaml`; rename it in both), and a Gatewaycalled `eg` in `envoy-gateway-system` with an `https` listener; change both to match yourcluster. The Gateway has to terminate TLS; this was tested with[Envoy Gateway](https://gateway.envoyproxy.io) and [cert-manager](https://cert-manager.io).@@ -34,5 +35,19 @@ Notes:Coach with an API key works on that same API image; the Claude and Codex sign-in providersneed the `coach` build target, which is not published — build it yourself (see[AI_COACH.md](AI_COACH.md)).+- The images are pinned to a release (`1.3.9`), the API and the web image always to the same+ one. To update, read the release notes, set the new version on both and apply again; pinning+ to `latest` instead means a restarted pod can come back on a version you never chose.- Settings are environment variables on the `api` container, named as in `.env.example`. Keepsecrets such as the push keys in a Kubernetes Secret and load them with `envFrom`.+- **Client addresses.** The web container overwrites `X-Forwarded-For` with the address it was+ reached from (see `web/nginx.conf.template`), and behind a Gateway that is the gateway's pod,+ not the visitor. So the sign-in throttle, which counts attempts per address, acts on the whole+ instance at once, and the activity log records the gateway's address. `TRUST_PROXY` is left+ off because it would not change that: the API would read the same gateway address from the+ header — and any pod that reaches port 3000 directly could put its own address there. Getting+ real visitor addresses needs the gateway to preserve them (for example+ `externalTrafficPolicy: Local` on its LoadBalancer Service) and to set a header of its own that+ overwrites whatever a client sent; pass that through with `CF_CONNECTING_IP` on the `web`+ container (as `.env.example` describes for Cloudflare), turn on `TRUST_PROXY=1` on the `api`+ container, and add a NetworkPolicy so only the web container's pod reaches port 3000.diff --git a/kubernetes/deployment.yaml b/kubernetes/deployment.yamlindex e1d350229..fde1b6032 100644--- a/kubernetes/deployment.yaml+++ b/kubernetes/deployment.yaml@@ -22,7 +22,7 @@ spec:# under the exercises-dataset's terms and fetched from upstream, not redistributed by# openGym; see NOTICE.md.- name: media-download- image: alpine/git+ image: alpine/git:2.52.0command: ["/bin/sh", "-c"]args:- |@@ -41,8 +41,12 @@ spec:memory: 256Micontainers:- name: api- image: ghcr.io/duartesantos8/opengym-api:latest- imagePullPolicy: Always+ # Pin both images to one release and move them together: a tag names what you run and+ # what you roll back to, where :latest changes under a pod whenever it is rescheduled.+ # The API and the web image of one version belong together. The published tags are+ # the version (1.3.9) and its minor line (1.3); see the release notes before a bump.+ image: ghcr.io/duartesantos8/opengym-api:1.3.9+ imagePullPolicy: IfNotPresentenv:- name: PORTvalue: "3000"@@ -54,6 +58,11 @@ spec:value: https://opengym.example.com# Everything else in .env.example (INVITE_ONLY, ADMIN_UIDS, ALLOW_GUEST,# DEFAULT_LANG, PASSWORD_LOGIN, the push keys, ...) goes here the same way.+ # TRUST_PROXY is left off on purpose: the web container overwrites X-Forwarded-For+ # with the address it was reached from, which here is the gateway's pod, so turning+ # it on changes nothing for the sign-in throttle — while any pod in the cluster that+ # talks to port 3000 directly could then choose its own address. See+ # docs/SELF_HOSTING_KUBERNETES.md.ports:- containerPort: 3000name: http@@ -76,8 +85,8 @@ spec:limits:memory: 512Mi- name: web- image: ghcr.io/duartesantos8/opengym-web:latest- imagePullPolicy: Always+ image: ghcr.io/duartesantos8/opengym-web:1.3.9 # same version as the api container+ imagePullPolicy: IfNotPresentenv:- name: NGINX_PORTvalue: "80"diff --git a/kubernetes/kustomization.yaml b/kubernetes/kustomization.yamlindex 9a22bdfd5..55b930cf1 100644--- a/kubernetes/kustomization.yaml+++ b/kubernetes/kustomization.yaml@@ -3,6 +3,7 @@ apiVersion: kustomize.config.k8s.io/v1beta1kind: Kustomizationnamespace: fitnessresources:+ - namespace.yaml- pvc.yaml- deployment.yaml- service.yamldiff --git a/kubernetes/namespace.yaml b/kubernetes/namespace.yamlnew file mode 100644index 000000000..08f208028--- /dev/null+++ b/kubernetes/namespace.yaml@@ -0,0 +1,6 @@+# The namespace everything below lives in (kustomization.yaml sets it on each resource), created+# here so `kubectl apply -k kubernetes/` works on a fresh cluster. Renaming it means changing both.+apiVersion: v1+kind: Namespace+metadata:+ name: fitness