From c28f09b2f1d2cb8362da3b88007cb0e4e3ea7b13 Mon Sep 17 00:00:00 2001 From: Thomas MENARD <thomas.menard@pasteur.fr> Date: Tue, 4 Jun 2019 00:31:11 +0200 Subject: [PATCH] Update README --- README.md | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 17fc539..d6b2439 100644 --- a/README.md +++ b/README.md @@ -321,6 +321,43 @@ Once succesfully completed, you can see the docker image in the `Registry`sectio servicePort: 80 path: / ``` + + * Kubernetes Job + + We will use a `Job` in order to manage django migrations. + > Note: Kubernetes jobs are run only once opposed to `Deployments` that run continiously. + + ```yaml + apiVersion: batch/v1 + kind: Job + metadata: + name: polls-migrations + spec: + template: + spec: + containers: + - name: django + image: ${CI_REGISTRY}/${CI_PROJECT_NAME}/polls:${CI_COMMIT_SHORT_SHA} + command: ['python', 'manage.py', 'migrate'] + env: + - name: DATABASE_NAME + valueFrom: + secretKeyRef: + name: postgresql-credentials + key: database + - name: DATABASE_USER + valueFrom: + secretKeyRef: + name: postgresql-credentials + key: username + - name: DATABASE_PASSWORD + valueFrom: + secretKeyRef: + name: postgresql-credentials + key: password + restartPolicy: Never + backoffLimit: 5 + ``` 6. Setup Continuous Delivery in Gitlab CI ```yaml @@ -333,7 +370,6 @@ deploy: name: mynamespace url: https://mynamespace.pasteur.cloud script: - - yum install gettext -y - kubectl delete secret registry-gitlab -n ${NAMESPACE} --ignore-not-found=true - kubectl create secret docker-registry -n ${NAMESPACE} registry-gitlab --docker-server=registry-gitlab.pasteur.fr --docker-username=${DEPLOY_USER} --docker-password=${DEPLOY_TOKEN} --docker-email=kubernetes@pasteur.fr - envsubst < polls.yaml | kubectl apply -f - -- GitLab