manual approval to prod
This commit is contained in:
@@ -1,7 +1,8 @@
|
|||||||
variables:
|
variables:
|
||||||
CI_PROJECT_DIR: "."
|
CI_PROJECT_DIR: "."
|
||||||
CI_REGISTRY_IMAGE: hub.ducoterra.net/ducoterra/mysite
|
CI_REGISTRY_IMAGE: hub.ducoterra.net/ducoterra/mysite
|
||||||
DEPLOY: test
|
DEPLOY_TEST: test
|
||||||
|
DEPLOY_PROD: prod
|
||||||
|
|
||||||
stages:
|
stages:
|
||||||
- build
|
- build
|
||||||
@@ -20,21 +21,21 @@ build:
|
|||||||
- /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG
|
- /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG
|
||||||
|
|
||||||
test:
|
test:
|
||||||
|
stage: test
|
||||||
only:
|
only:
|
||||||
variables:
|
variables:
|
||||||
- $CI_COMMIT_TAG
|
- $CI_COMMIT_TAG
|
||||||
stage: test
|
|
||||||
image:
|
image:
|
||||||
name: $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG
|
name: $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG
|
||||||
entrypoint: [""]
|
entrypoint: [""]
|
||||||
script:
|
script:
|
||||||
- python manage.py test
|
- python manage.py test
|
||||||
|
|
||||||
deploy:
|
deploy_to_test:
|
||||||
|
stage: deploy
|
||||||
only:
|
only:
|
||||||
variables:
|
variables:
|
||||||
- $CI_COMMIT_TAG
|
- $CI_COMMIT_TAG
|
||||||
stage: deploy
|
|
||||||
image:
|
image:
|
||||||
name: debian:10
|
name: debian:10
|
||||||
entrypoint: [""]
|
entrypoint: [""]
|
||||||
@@ -44,6 +45,28 @@ deploy:
|
|||||||
- chmod +x ./kubectl
|
- chmod +x ./kubectl
|
||||||
- mkdir /deploy
|
- mkdir /deploy
|
||||||
- for f in $(find k8s -regex '.*\.ya*ml'); do envsubst < $f > "/deploy/$(basename $f)"; done
|
- for f in $(find k8s -regex '.*\.ya*ml'); do envsubst < $f > "/deploy/$(basename $f)"; done
|
||||||
|
- for f in $(find k8s/test -regex '.*\.ya*ml'); do envsubst < $f > "/deploy/$(basename $f)"; done
|
||||||
|
- ./kubectl apply -f /deploy
|
||||||
|
- ./kubectl rollout status deploy $DEPLOY
|
||||||
|
- POD=$(./kubectl get pods --selector=app=$DEPLOY --output=jsonpath='{.items[*].metadata.name}')
|
||||||
|
- ./kubectl exec $POD -- python manage.py migrate
|
||||||
|
|
||||||
|
deploy_to_prod:
|
||||||
|
stage: deploy
|
||||||
|
only:
|
||||||
|
variables:
|
||||||
|
- $CI_COMMIT_TAG
|
||||||
|
when: manual
|
||||||
|
image:
|
||||||
|
name: debian:10
|
||||||
|
entrypoint: [""]
|
||||||
|
script:
|
||||||
|
- apt -qq update >> /dev/null && apt -qq install -y curl gettext >> /dev/null
|
||||||
|
- curl -LO https://storage.googleapis.com/kubernetes-release/release/`curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt`/bin/linux/amd64/kubectl
|
||||||
|
- chmod +x ./kubectl
|
||||||
|
- mkdir /deploy
|
||||||
|
- for f in $(find k8s -regex '.*\.ya*ml'); do envsubst < $f > "/deploy/$(basename $f)"; done
|
||||||
|
- for f in $(find k8s/prod -regex '.*\.ya*ml'); do envsubst < $f > "/deploy/$(basename $f)"; done
|
||||||
- ./kubectl apply -f /deploy
|
- ./kubectl apply -f /deploy
|
||||||
- ./kubectl rollout status deploy $DEPLOY
|
- ./kubectl rollout status deploy $DEPLOY
|
||||||
- POD=$(./kubectl get pods --selector=app=$DEPLOY --output=jsonpath='{.items[*].metadata.name}')
|
- POD=$(./kubectl get pods --selector=app=$DEPLOY --output=jsonpath='{.items[*].metadata.name}')
|
||||||
|
|||||||
@@ -3,4 +3,4 @@ kind: ConfigMap
|
|||||||
metadata:
|
metadata:
|
||||||
name: $DEPLOY
|
name: $DEPLOY
|
||||||
data:
|
data:
|
||||||
ALLOWED_HOSTS: localhost,test.ducoterra.net
|
ALLOWED_HOSTS: localhost,$DEPLOY.ducoterra.net
|
||||||
@@ -7,10 +7,10 @@ metadata:
|
|||||||
spec:
|
spec:
|
||||||
tls:
|
tls:
|
||||||
- hosts:
|
- hosts:
|
||||||
- test.ducoterra.net
|
- $DEPLOY.ducoterra.net
|
||||||
secretName: letsencrypt
|
secretName: letsencrypt
|
||||||
rules:
|
rules:
|
||||||
- host: test.ducoterra.net
|
- host: $DEPLOY.ducoterra.net
|
||||||
http:
|
http:
|
||||||
paths:
|
paths:
|
||||||
- backend:
|
- backend:
|
||||||
@@ -29,7 +29,7 @@ spec:
|
|||||||
tls:
|
tls:
|
||||||
secretName: letsencrypt
|
secretName: letsencrypt
|
||||||
routes:
|
routes:
|
||||||
- match: Host(`test.ducoterra.net`)
|
- match: Host(`$DEPLOY.ducoterra.net`)
|
||||||
kind: Rule
|
kind: Rule
|
||||||
services:
|
services:
|
||||||
- name: $DEPLOY
|
- name: $DEPLOY
|
||||||
@@ -45,7 +45,7 @@ spec:
|
|||||||
entryPoints:
|
entryPoints:
|
||||||
- web
|
- web
|
||||||
routes:
|
routes:
|
||||||
- match: Host(`test.ducoterra.net`)
|
- match: Host(`$DEPLOY.ducoterra.net`)
|
||||||
kind: Rule
|
kind: Rule
|
||||||
services:
|
services:
|
||||||
- name: $DEPLOY
|
- name: $DEPLOY
|
||||||
18
k8s/test/ingress.yaml
Normal file
18
k8s/test/ingress.yaml
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
apiVersion: networking.k8s.io/v1beta1
|
||||||
|
kind: Ingress
|
||||||
|
metadata:
|
||||||
|
annotations:
|
||||||
|
ingress.kubernetes.io/ssl-redirect: "true"
|
||||||
|
name: $DEPLOY
|
||||||
|
spec:
|
||||||
|
tls:
|
||||||
|
- hosts:
|
||||||
|
- $DEPLOY.ducoterra.net
|
||||||
|
secretName: letsencrypt
|
||||||
|
rules:
|
||||||
|
- host: $DEPLOY.ducoterra.net
|
||||||
|
http:
|
||||||
|
paths:
|
||||||
|
- backend:
|
||||||
|
serviceName: $DEPLOY
|
||||||
|
servicePort: 8000
|
||||||
Reference in New Issue
Block a user