django-k8s
Integration between Django and Kubernetes.
Caching
Service discovery for Memcached. Admittedly this will work with any service discovery that uses multiple A records for memcached servers. This allows the memcached client to properly distribute keys amongst memcached servers. AWS ElasticCache as well as Kubernetes and others are compatible with this scheme.
If an error is received when trying to access a memcached server, DNS resolution is performed again (refreshing server list). This allows memcached servers to be added or removed without restarting the application.
More information on this approach is provided below.
https://cloud.google.com/solutions/deploying-memcached-on-kubernetes-engine
Given Memcached deployed to Kubernetes with the following command:
helm install stable/memcached --name mycache --set replicaCount=3
You could configure your application like this:
CACHES = {
'default': {
'BACKEND': 'django_k8s.cache.backends.Memcached',
'HOST': environ.get('DJANGO_CACHE_HOST', None),
},
}
Migrations
One convenient way to handle Django migrations in Kubernetes is using a Job. However Django applications expect the database to be available and migrated on startup. Therefore some coordination is necessary. The application containers should wait for the migration job to complete before starting up.
This package provides a management command that polls the database to check for two conditions:
That the database server is reachable.
That all migrations have been applied.
It can optionally wait for both of these conditions to be true. An exit code of 0 indicates success. This management command could be part of your entrypoint, ensuring no Django application is started until these conditions are met.
This technique is compatible with systems other than Kubernetes, the author has used it with Docker Compose as well.
$ python manage.py checkmigrations
Migrations complete.
Metadata
Release files for django-k8s 0.2.9
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| django-k8s-0.2.9.tar.gz | 7.0 kB | Without provenance | Details for django-k8s-0.2.9.tar.gz |
Release files / django-k8s-0.2.9.tar.gz
| Download URL | django-k8s-0.2.9.tar.gz |
|---|---|
| Size | 7.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
faa39fd91ff4b9c6d9841694754caba672f51c32ccad9acb9d94d475215d8308
|
|
BLAKE2b-256 checksum How to use checksums |
1783ba7091e0a0476a27ff09d0571eb7056411d42d6300a9d610aec8f5b1b0b7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.6.7
|
Security for django-k8s 0.2.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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.