Fork of https://gitlab.com/burke-software/django-helm-chart/ to fix a bug in the upstream
Find a file
2022-07-19 20:55:29 -04:00
charts Update chart dependencies 2022-07-19 20:55:29 -04:00
templates Add nodeSelector, tolerations, affinity to beat 2022-07-20 00:52:19 +00:00
.gitlab-ci.yml Switch to GitLab hosted helm chart repo 2022-06-16 16:23:48 -04:00
.helmignore Initial commit 2020-01-14 22:04:41 -05:00
Chart.lock Update chart dependencies 2022-07-19 20:55:29 -04:00
Chart.yaml Update chart dependencies 2022-07-19 20:55:29 -04:00
LICENSE Refactor 2021-05-28 21:33:04 +00:00
README.md Update README 2022-06-16 16:27:38 -04:00
values.yaml Add nodeSelector, tolerations, affinity to beat 2022-07-20 00:52:19 +00:00

Django Helm Chart

A generic Django (plus Celery) Helm chart.

Preparing your Django app

This chart supports a web plus optional celery and beat deployments. Be prepared to extend it as necessary.

Django settings will be managed by environment variables. django-environ works well for this and can parse the DATABASE_URL connection string. This chart expects SECRET_KEY and DATABASE_URL variables.

Kubernetes works best when it is able to determine application health. Your Django app should have a /_health/ view such as

def health(request):
    return HttpResponse("ok", content_type="text/plain")

urlpatterns = [
    path("_health/", health),
...

Set the value web.livenessProbe.path and web.readinessProbe.path to change the URL.

Run commands

This helm chart will set a "role" environment variable to web, worker, or beat. Your Docker image could read this variable and run the correct command.

Alternatively, set the service.args. For example:

web:
  args:
    - run_it

Remember that Kubernetes "args" are Docker's CMD (or command). Pretty confusing!

Usage

  1. Add our Helm chart repo helm repo add django https://gitlab.com/api/v4/projects/26807467/packages/helm/stable
  2. Review our values.yaml. At a minimum you'll need to set env.secret.SECRET_KEY and env.secret.DATABASE_URL.
  3. Install the chart helm install your-app django/django -f your-values.yml

Tips

  • Do you really need kubernetes?
  • Use helm diff. One typo will wipe your app without warning otherwise.
  • While supported, I don't suggest running stateful services like PostgreSQL in kubernetes. There is no clean way to run major upgrades.
  • It's fine to use this chart as a reference for your own chart instead of directly using it.
  • I don't publish changelogs at this time. You may wish to fork this repo.

Managing environment variables and secrets

I suggest either

  • Keep them in a values.yml file in a private repo
  • Make use of --reuse-values and --set
  • Keep them in a non helm chart managed service

Deploying in CI

I use alpine/helm with Gitlab CI. Example.

Support development

Maintaining this chart takes time. Considering supporting it by

Commercial support is available - email info@burkesoftware.com

Contributing

Contributions are welcome. Report bugs on GitLab issues. Please only open feature requests that you'd like to implement yourself or pay for.