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 avai…


This content originally appeared on DEV Community and was authored by Javid Mougamadou

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


This content originally appeared on DEV Community and was authored by Javid Mougamadou


Print Share Comment Cite Upload Translate Updates
APA

Javid Mougamadou | Sciencx (2021-03-20T19:39:41+00:00) Django-probes: wait until database is ready – Probes for Docker and Kubernetes. Retrieved from https://www.scien.cx/2021/03/20/django-probes-wait-until-database-is-ready-probes-for-docker-and-kubernetes/

MLA
" » Django-probes: wait until database is ready – Probes for Docker and Kubernetes." Javid Mougamadou | Sciencx - Saturday March 20, 2021, https://www.scien.cx/2021/03/20/django-probes-wait-until-database-is-ready-probes-for-docker-and-kubernetes/
HARVARD
Javid Mougamadou | Sciencx Saturday March 20, 2021 » Django-probes: wait until database is ready – Probes for Docker and Kubernetes., viewed ,<https://www.scien.cx/2021/03/20/django-probes-wait-until-database-is-ready-probes-for-docker-and-kubernetes/>
VANCOUVER
Javid Mougamadou | Sciencx - » Django-probes: wait until database is ready – Probes for Docker and Kubernetes. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/03/20/django-probes-wait-until-database-is-ready-probes-for-docker-and-kubernetes/
CHICAGO
" » Django-probes: wait until database is ready – Probes for Docker and Kubernetes." Javid Mougamadou | Sciencx - Accessed . https://www.scien.cx/2021/03/20/django-probes-wait-until-database-is-ready-probes-for-docker-and-kubernetes/
IEEE
" » Django-probes: wait until database is ready – Probes for Docker and Kubernetes." Javid Mougamadou | Sciencx [Online]. Available: https://www.scien.cx/2021/03/20/django-probes-wait-until-database-is-ready-probes-for-docker-and-kubernetes/. [Accessed: ]
rf:citation
» Django-probes: wait until database is ready – Probes for Docker and Kubernetes | Javid Mougamadou | Sciencx | https://www.scien.cx/2021/03/20/django-probes-wait-until-database-is-ready-probes-for-docker-and-kubernetes/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.