DjangoApplication construct simplifies deployment of Django applications to Kubernetes. It automatically configures the deployment, service, ingress, and environment variables needed to run a Django application.
Constructor
Properties
Deployment configuration including image, replicas, environment variables, and resource limits.
The value for the
DJANGO_SETTINGS_MODULE environment variable. This specifies which settings file Django should use (e.g., "myapp.settings.production").Port to expose the application on. This is used for the Kubernetes service and ingress configuration.
Array of domain configurations. Each entry specifies:
host: The domain name (e.g.,"api.example.com")paths: Array of URL paths to expose (e.g.,["/api", "/admin"])isSubdomain: Whether this is a subdomain for certificate purposes
Optional ingress configuration to override default settings, such as custom annotations for path-based routing.
Whether to create a Kubernetes service account and attach it to deployment pods. The service account name will be the release name.
Behavior
TheDjangoApplication construct automatically:
- Sets environment variables: Injects
DJANGO_SETTINGS_MODULEandDOMAINS(comma-separated list of hosts) - Creates ingress rules: Configures ingress based on the provided domains and paths
- Manages certificates: Uses the
isSubdomainflag to determine certificate generation strategy - Configures service: Creates a Kubernetes service exposing the specified port
Usage Example
Basic Django Application
Django with Multiple Domains
Django ASGI (WebSockets)
Example from the Kittyhawk README:Django Without Public Access (Celery Worker)
Related
- Deployments - Configuration options for the underlying deployment
- Ingress - Ingress construct for custom routing
- Certificates - Certificate management for TLS