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 Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
Close
Hashes for django_k8s_health_check-1.0.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 92508817fcd14d3b6c3a4b26d47a13bcfd2970a6cd56c64adff0d3771f7c2c06 |
|
MD5 | ab772bbf7a3e49ebd6e7880f9b4ff387 |
|
BLAKE2b-256 | 686b878267f9b1d8e9205742bcdd7e74be0a19cccd939739d99bb0851ea79d60 |