Skip to main content

Django Kubernetes

Tests Documentation Status

Middleware and Views for Kubernetes liveness and readiness probes and Django management commands for Kubernetes jobs such as waiting for the database to be ready or ensuring an admin user exists or is created from environment variables.

Let's face it; running a Django app on a Kubernetes cluster is a bit difficult - Django was built by folks who were running it on virtual machines or even bare metal hardware! They expected a shell environment available to them to be able to run management commands and influence how Django started up when in production.

When Django is orchestrated, we somehow have to manage these commands in our clusters; either by manually running the commands or creating init containers or Jobs that our deployments depend on. Moreover, once the pods are up and running, we need to ensure that the Kubernetes control layer can manipulate them as needed.

That's where this package comes in, it provides the following helpers to make your Django deployments on Kubernetes easier:

Readiness Probes

  • DatabaseProbe: Checks that a connection can be established to the database
  • MemcachedProbe: Checks that the cache nodes are available and ready

Views

  • LivenessView: responds Ok to /livez and /healthz path requests
  • ReadinessView: respond Ok if readiness probes are fine, else 503

Middleware

  • ProbeMiddleware: performs /livez, /healthz, and /readyz checks with readiness probes before any middleware or views might interact with those services and raise a 500 error or some other error.

Management Commands

  • ./manage.py probe: a CLI version of the probes with --live, --health, and --ready checks that can be used by Kubernetes probe exec commands.
  • ./manage.py wait4db: sleeps until the database is ready and available
  • ./manage.py ensureadmin: reads environment variables for an admin user and creates that super user if the record does not already exist in the database.
  • ./manage.py lockedmigrate: uses a postgres advisory lock to ensure migration safety across multiple processes; useful for a multi-replica deployment with a migrate init container.

See the documentation for more on how to get started and use this app in your Django project.

Metadata

Release files for django-kubernetes 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-kubernetes 1.1.0
File Size Uploaded
django_kubernetes-1.1.0.tar.gz 24.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-kubernetes 1.1.0
File Interpreter ABI Platform
django_kubernetes-1.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 38.5 kB

Release files / django_kubernetes-1.1.0.tar.gz

Download URL django_kubernetes-1.1.0.tar.gz
Size 24.8 kB
Tags Source
SHA-256 checksum
How to use checksums
6ca3e3b85c8cd7c11057156398d74398c585a7d782ad585a65463e749d2d86ed
BLAKE2b-256 checksum
How to use checksums
636c3a5bf9a360e14612dfa581d055cc27e78e35954b0edf17cb02c22f3ca154
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 18, 2025.

Transparency log

Release files / django_kubernetes-1.1.0-py3-none-any.whl

Download URL django_kubernetes-1.1.0-py3-none-any.whl
Size 13.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
068cca992a6b3f8030774618ce23ee22cf68b565a35faa46bb6ccd97f034c029
BLAKE2b-256 checksum
How to use checksums
fdd014e763857e44fc8d846f786527c777d6b85d649e5d990e29cf2b468a91d9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 18, 2025.

Transparency log

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page