Helm chart for Posthog WITW
There are three charts in this repository:
caddy, which is used to deploy a stateful (just for certs) reverse-proxy for our servicespostgis, which is used to deploy a stateful postgresql instance with the postgis extensionwitw, which is used to deploy stateless services based on the "whereintheworld" image
To deploy the full application, these steps should be followed (in order, DB first):
Postgres
- First,
cdintopostgisand runhelm template . - Does it look "correct enough" to you, all the environment variables, etc? If so, continue
- Then, run
helm install postgis . - This will render and upload the resource YAMLs to Kubernetes
- After a minute, run
kubectl get podsand make sure you see thepostgis-0pod inRunning
Whereintheworld
- First,
cdintowitwand runhelm template . -f values/backend.yaml - (The
-f values/backend.yamltells it to use the "backend" values file and settings) - Does it look "correct enough" to you, all the environment variables, etc? If so, continue
- Then, run
helm install witw-backend . - This will render and upload the resource YAMLs to Kubernetes
- After a minute, run
kubectl get podsand make sure you see awitw-backendpod inRunning - Then, follow the same steps but with
-f values/frontend.yamlfor the frontend!
Migrations
- Run
kubectl get podsand find the name of awitw-backendpod - Run
kubectl exec -it $WITW_POD -- shto get a shell into the running pod above - Run
python manage.py migratein that shell to kick off the migrations - If it tells you "No migrations to apply", then you're all up to date!
Caddy
- First,
cdintocaddyand runhelm template . - Does it look "correct enough" to you? If so, continue
- Then, run
helm install caddy . - This will render and upload the resource YAMLs to Kubernetes
- After a minute, run
kubectl get podsand make sure you see thecaddy-0pod inRunning - You can also run
kubectl logs caddy-0to see how the TLS cert process went
After all of the above steps have been taken, try running:
curl -v https://hog.willett.io/_health
You should get a 200 response with server: gunicorn in the headers (and a 300 if you try with http). Additionally, if you try with a path looking like /api/foo, you should get a 400 error with "unauthorized".
For both of the charts mentioned above, the process for deploying changes is the same:
- Make any changes to the chart you like
- Run
helm diff upgrade $RELEASE_NAME .to see what Helm would do if you actually applied it - Make a PR with your changes, include the diff if you like, get it approved
- Run
helm upgrade $RELEASE_NAME .to actually execute your update, make sure it works - Merge your PR right after
Here are a few tools you might need when poking around the cluster:
- To get a (dangerous!) postgres shell:
kubectl exec -it postgis-0 -- psql -U whereintheworld - To run Django scripts:
kubectl get podsthenkubectl exec -it $WITW_POD -- python manage.py foo - To hit the API from your laptop:
kubectl port-forward svc/witw-backend 8000:8000(thencurl)