Skip to main content

Kubernetes

hunt is one pod with one volume. Only one copy can run at a time, since SQLite is a file on that volume, so updates replace the pod rather than rolling.

Requirements​

  • A Kubernetes cluster, with a storage class for the volume
  • kubectl

1. Write the manifests​

Save this as hunt.yaml: the volume, the deployment and its service.

apiVersion: v1
kind: PersistentVolumeClaim
metadata: { name: hunt-data }
spec:
accessModes: [ReadWriteOnce]
resources: { requests: { storage: 1Gi } }
---
apiVersion: apps/v1
kind: Deployment
metadata: { name: hunt }
spec:
replicas: 1
strategy: { type: Recreate }
selector: { matchLabels: { app: hunt } }
template:
metadata: { labels: { app: hunt } }
spec:
securityContext: { fsGroup: 65532 }
containers:
- name: hunt
image: ghcr.io/arabesquelabs/hunt:latest
ports: [{ containerPort: 4848 }]
volumeMounts: [{ name: data, mountPath: /data }]
readinessProbe: { httpGet: { path: /healthz, port: 4848 } }
livenessProbe: { httpGet: { path: /healthz, port: 4848 } }
volumes:
- name: data
persistentVolumeClaim: { claimName: hunt-data }
---
apiVersion: v1
kind: Service
metadata: { name: hunt }
spec:
selector: { app: hunt }
ports: [{ port: 4848, targetPort: 4848 }]
  • One replica, recreated: never two pods on one SQLite file.
  • fsGroup: 65532: the image runs as that user, so this gives it the volume.
  • The probes: /healthz answers "ok" once hunt and its database do, and needs no sign-in.

2. Deploy it​

kubectl create namespace hunt
kubectl -n hunt apply -f hunt.yaml
kubectl -n hunt rollout status deployment/hunt

3. Open it​

Through a port-forward, from your own computer:

kubectl -n hunt port-forward svc/hunt 4848

Then visit http://localhost:4848. The CLI works through it too (HUNT_URL=http://127.0.0.1:4848).

To reach it from elsewhere, point an Ingress, a load balancer or a Cloudflare Tunnel at the hunt service's port 4848, with a sign-in in front of it: see "What's public, and what needs signing in".

4. Use PostgreSQL or MySQL (optional)​

Give the container the database's address as HUNT_DB, from a secret:

env:
- name: HUNT_DB
valueFrom: { secretKeyRef: { name: hunt-db, key: url } }

Updating​

kubectl -n hunt rollout restart deployment/hunt # pulls latest again
kubectl -n hunt set image deployment/hunt hunt=ghcr.io/arabesquelabs/hunt:v0.15.0 # or a version