new standard deploy templates
This commit is contained in:
@@ -36,15 +36,14 @@ deploy:
|
|||||||
- $CI_COMMIT_TAG
|
- $CI_COMMIT_TAG
|
||||||
stage: deploy
|
stage: deploy
|
||||||
image:
|
image:
|
||||||
name: debian:latest
|
name: debian:10
|
||||||
entrypoint: [""]
|
entrypoint: [""]
|
||||||
script:
|
script:
|
||||||
- echo $CI_REGISTRY_IMAGE
|
|
||||||
- apt -qq update >> /dev/null && apt -qq install -y curl gettext >> /dev/null
|
- 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
|
- 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
|
- chmod +x ./kubectl
|
||||||
- envsubst < k8s/deploy.yaml > out.yaml
|
- mkdir /deploy
|
||||||
- mv out.yaml k8s/deploy.yaml
|
- for f in $(find k8s -regex '.*\\.ya*ml); do envsubst < $f > "/deploy/$(basename $f)"; done'
|
||||||
- ./kubectl apply -f k8s
|
- ./kubectl apply -f /deploy
|
||||||
- ./kubectl rollout status deploy $DEPLOY
|
- ./kubectl rollout status deploy $DEPLOY
|
||||||
- ./kubectl exec $(./kubectl get pods --selector=app=$DEPLOY --output=jsonpath='{.items[*].metadata.name}') -- python manage.py migrate
|
- ./kubectl exec $(./kubectl get pods --selector=app=$DEPLOY --output=jsonpath='{.items[*].metadata.name}') -- python manage.py migrate
|
||||||
@@ -20,13 +20,12 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
|||||||
# See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/
|
# See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/
|
||||||
|
|
||||||
# SECURITY WARNING: keep the secret key used in production secret!
|
# SECURITY WARNING: keep the secret key used in production secret!
|
||||||
SECRET_KEY = 'b8fi9=f-qj=@-#1iru34-f@a6pzfysgrf(1n_&d=ur%!1w$q*w'
|
SECRET_KEY = os.getenv("SECRET_KEY")
|
||||||
|
|
||||||
# SECURITY WARNING: don't run with debug turned on in production!
|
# SECURITY WARNING: don't run with debug turned on in production!
|
||||||
DEBUG = True if os.getenv("DEBUG") == "True" else False
|
DEBUG = True if os.getenv("DEBUG") == "True" else False
|
||||||
|
|
||||||
ALLOWED_HOSTS = ["localhost", "test.ducoterra.net"]
|
ALLOWED_HOSTS = os.getenv("ALLOWED_HOSTS").split(",")
|
||||||
|
|
||||||
|
|
||||||
# Application definition
|
# Application definition
|
||||||
|
|
||||||
|
|||||||
6
k8s/configmap.yaml
Normal file
6
k8s/configmap.yaml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
kind: ConfigMap
|
||||||
|
metadata:
|
||||||
|
name: $DEPLOY
|
||||||
|
data:
|
||||||
|
ALLOWED_HOSTS: localhost,test.ducoterra.net
|
||||||
@@ -1,22 +1,25 @@
|
|||||||
apiVersion: apps/v1
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
metadata:
|
metadata:
|
||||||
name: test
|
name: $DEPLOY
|
||||||
spec:
|
spec:
|
||||||
selector:
|
selector:
|
||||||
matchLabels:
|
matchLabels:
|
||||||
app: test
|
app: $DEPLOY
|
||||||
template:
|
template:
|
||||||
metadata:
|
metadata:
|
||||||
labels:
|
labels:
|
||||||
app: test
|
app: $DEPLOY
|
||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: test
|
- name: $DEPLOY
|
||||||
image: $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG
|
image: $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG
|
||||||
|
envFrom:
|
||||||
|
- configMapRef:
|
||||||
|
name: gitlab
|
||||||
volumeMounts:
|
volumeMounts:
|
||||||
- mountPath: /app/db
|
- mountPath: /app/db
|
||||||
name: test
|
name: $DEPLOY
|
||||||
resources:
|
resources:
|
||||||
limits:
|
limits:
|
||||||
memory: "256Mi"
|
memory: "256Mi"
|
||||||
@@ -27,6 +30,6 @@ spec:
|
|||||||
ports:
|
ports:
|
||||||
- containerPort: 8000
|
- containerPort: 8000
|
||||||
volumes:
|
volumes:
|
||||||
- name: test
|
- name: $DEPLOY
|
||||||
persistentVolumeClaim:
|
persistentVolumeClaim:
|
||||||
claimName: test
|
claimName: $DEPLOY
|
||||||
@@ -3,7 +3,7 @@ kind: Ingress
|
|||||||
metadata:
|
metadata:
|
||||||
annotations:
|
annotations:
|
||||||
ingress.kubernetes.io/ssl-redirect: "true"
|
ingress.kubernetes.io/ssl-redirect: "true"
|
||||||
name: test
|
name: $DEPLOY
|
||||||
spec:
|
spec:
|
||||||
tls:
|
tls:
|
||||||
- hosts:
|
- hosts:
|
||||||
@@ -14,7 +14,7 @@ spec:
|
|||||||
http:
|
http:
|
||||||
paths:
|
paths:
|
||||||
- backend:
|
- backend:
|
||||||
serviceName: test
|
serviceName: $DEPLOY
|
||||||
servicePort: 8000
|
servicePort: 8000
|
||||||
|
|
||||||
---
|
---
|
||||||
@@ -22,7 +22,7 @@ spec:
|
|||||||
apiVersion: traefik.containo.us/v1alpha1
|
apiVersion: traefik.containo.us/v1alpha1
|
||||||
kind: IngressRoute
|
kind: IngressRoute
|
||||||
metadata:
|
metadata:
|
||||||
name: test-external-tls
|
name: $DEPLOY-external-tls
|
||||||
spec:
|
spec:
|
||||||
entryPoints:
|
entryPoints:
|
||||||
- websecure
|
- websecure
|
||||||
@@ -32,7 +32,7 @@ spec:
|
|||||||
- match: Host(`test.ducoterra.net`)
|
- match: Host(`test.ducoterra.net`)
|
||||||
kind: Rule
|
kind: Rule
|
||||||
services:
|
services:
|
||||||
- name: test
|
- name: $DEPLOY
|
||||||
port: 8000
|
port: 8000
|
||||||
|
|
||||||
---
|
---
|
||||||
@@ -40,7 +40,7 @@ spec:
|
|||||||
apiVersion: traefik.containo.us/v1alpha1
|
apiVersion: traefik.containo.us/v1alpha1
|
||||||
kind: IngressRoute
|
kind: IngressRoute
|
||||||
metadata:
|
metadata:
|
||||||
name: test-external-web
|
name: $DEPLOY-external-web
|
||||||
spec:
|
spec:
|
||||||
entryPoints:
|
entryPoints:
|
||||||
- web
|
- web
|
||||||
@@ -48,7 +48,7 @@ spec:
|
|||||||
- match: Host(`test.ducoterra.net`)
|
- match: Host(`test.ducoterra.net`)
|
||||||
kind: Rule
|
kind: Rule
|
||||||
services:
|
services:
|
||||||
- name: test
|
- name: $DEPLOY
|
||||||
port: 8000
|
port: 8000
|
||||||
middlewares:
|
middlewares:
|
||||||
- name: httpsredirect
|
- name: httpsredirect
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: PersistentVolumeClaim
|
kind: PersistentVolumeClaim
|
||||||
metadata:
|
metadata:
|
||||||
name: test
|
name: $DEPLOY
|
||||||
spec:
|
spec:
|
||||||
storageClassName: nfs-encrypted
|
storageClassName: nfs-encrypted
|
||||||
accessModes:
|
accessModes:
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: Service
|
kind: Service
|
||||||
metadata:
|
metadata:
|
||||||
name: test
|
name: $DEPLOY
|
||||||
spec:
|
spec:
|
||||||
selector:
|
selector:
|
||||||
app: test
|
app: $DEPLOY
|
||||||
ports:
|
ports:
|
||||||
- port: 8000
|
- port: 8000
|
||||||
targetPort: 8000
|
targetPort: 8000
|
||||||
Reference in New Issue
Block a user