Skip to main content

Middleware for Kubernetes probes and Django management commands for Kubernetes jobs.

Project description

Django Kubernetes

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.

More documentation coming soon!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_kubernetes-1.0.1.tar.gz (15.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_kubernetes-1.0.1-py3-none-any.whl (12.8 kB view details)

Uploaded Python 3

File details

Details for the file django_kubernetes-1.0.1.tar.gz.

File metadata

  • Download URL: django_kubernetes-1.0.1.tar.gz
  • Upload date:
  • Size: 15.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for django_kubernetes-1.0.1.tar.gz
Algorithm Hash digest
SHA256 02cd655c5d18ba36e815f76ab094a0a26b05c239c70d399dfe150093baf28534
MD5 d509139fa14888b6ed44e76554d381ce
BLAKE2b-256 d3a6079d1f1dacbfc805fc8bcafc44faec6bffbe64957a69f528faf65ca4d45e

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_kubernetes-1.0.1.tar.gz:

Publisher: release.yaml on rotationalio/django-kubernetes

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file django_kubernetes-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for django_kubernetes-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2c9482426f3435841977638b7230f22f2173c56ec08696df3f57e26a307235b8
MD5 e9c297e57bb92078b645647347d2c59e
BLAKE2b-256 248e7aed9ef70dfe07157db0b6e06f398d79a69ce944b40f7188b6fa7782a20f

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_kubernetes-1.0.1-py3-none-any.whl:

Publisher: release.yaml on rotationalio/django-kubernetes

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page