Django Health Check
Project description
Django Health Check
If you use or like the project, click Star
and Watch
to generate metrics and i evaluate project continuity.
Install:
pip install django-k8s-health-check
Usage Health only:
- In your urls:
from django_k8s_health_check.views import HealthView ... urlpatterns = [ path('', views.HealthView.as_view()), ]
Usage in kubernetes:
If use health check in kubernetes, you need to add kubernetes ip/host to allowed_hosts, but is a bad practice, especially if there are multiple ip/hosts... For this, i created a middleware to pass the ip/hosts, using multiples validators
-
Add the middleware to django middleware`s:
MIDDLEWARE = [ 'django_k8s_health_check.middleware.HealthCheckMiddleware', ... ]
-
Try this request:
import requests requests.get('your-url', headers={'X-Health': 'health-check'})
-
Put this in your yml
livenessProbe: httpGet: path: /your-path httpHeaders: - name: X-Health value: health-check timeoutSeconds: 5
-
Check de configuration bellow, and change for security reasons...
Configuration:
HEALTH_CHECK = {
# View
'SERVICE_NAME': None,
'CHECK_DATABASE': True,
'CHECK_CACHE': True,
# Middleware
'HEADER_FIELD': 'X-Health',
'HEADER_VALUE': 'health-check',
'ALLOWED_PATHS': None, # all others urls, use original ALLOWED_HOSTS. Ex: ['api/v1/health', '/health'], None allow all
'ALLOWED_HOSTS': None, # check request host is in a list, Ex: ['127.0.0.1', 'www.domain.com'], None allow all
}
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
Built Distribution
Close
Hashes for django-k8s-health-check-1.0.6.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | f5bdd5c3c9ae5ad0fda70363c56a202a92bddb9ff66c1b6a92eb79d6630fee3a |
|
MD5 | 73f1e6852aa05c1081e2df18d1b1f5dd |
|
BLAKE2b-256 | 77daab4d34b4e06d485f500af6cfb9edc5880fe89e5e41d3b6a99d58ce8c304c |
Close
Hashes for django_k8s_health_check-1.0.6-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c1018a4b25c1e5c96dda3aea73894dfab3d8396e8b8ae2419ab847d236145e08 |
|
MD5 | 7936a46531834680e2ed46ede535da06 |
|
BLAKE2b-256 | 33970bda75a49917d30a0042b8bdc2c960565aa5f9a62f0b5a5eb1e668b270cf |