Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
March 20, 2021 07:39 pm GMT

Django-probes: wait until database is ready - Probes for Docker and Kubernetes

Concepts

Provides a Django management command to check whether the primary database is ready to accept connections.

Run this command in a Kubernetes or OpenShift Init Container to make your Django application wait until the database is available (e.g. to run database migrations).

Installation

The easiest way to install django-probes is with pip

pip install django-probes

Basic Usage

1) Add django-probes to your Django application:

INSTALLED_APPS = [    ...    'django_probes',]

2) Add an Init Container to your Kubernetes/OpenShift deployment configuration, which calls the wait_for_database management command:

- kind: Deployment  apiVersion: apps/v1  spec:    template:      spec:        initContainers:        - name: wait-for-database          image: my-django-app:latest          envFrom:          - secretRef:              name: django          command: ['python', 'manage.py', 'wait_for_database']

Links


Original Link: https://dev.to/javidjms/django-probes-wait-until-database-is-ready-probes-for-docker-and-kubernetes-6o7

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To