Commit 1ef8020a authored by Ninot Romain's avatar Ninot Romain
Browse files

CD conf

parent badc6e3c
services:
- docker:stable-dind
stages:
- build
- deploy
variables:
CONTAINER_IMAGE: ${DOCKER_USER}/myapps-${CI_COMMIT_SHORT_SHA}
build:
image: docker:latest
tags:
- docker
stage: build
before_script:
- docker login ${HARBOR_SERVER} --username ${DOCKER_USER} --password ${DOCKER_PASSWORD}
script:
- docker build -t myapps .
- docker tag myapps zasyvcng.gra5.container-registry.ovh.net/library/${CI_COMMIT_SHORT_SHA}
- docker push zasyvcng.gra5.container-registry.ovh.net/library/${CI_COMMIT_SHORT_SHA}
deploy:
stage: deploy
image: dtzar/helm-kubectl
tags:
- docker
script:
- kubectl config set-cluster ${CLUSTER} --server="${SERVER}"
- kubectl config set clusters.${CLUSTER}.certificate-authority-data ${CERTIFICATE_AUTHORITY_DATA}
- kubectl config set-credentials ${USER} --token="${USER_TOKEN}"
- kubectl config set-context ${CONTEXT} --cluster=${CLUSTER} --user=${USER}
- kubectl config use-context ${CONTEXT}
- sed -i "s/latest/${CI_COMMIT_SHORT_SHA}/g" kube/deployment.yaml
- sed -i "s/template/${CI_PROJECT_NAME}/g" kube/deployment.yaml
- sed -i "s/template/${CI_PROJECT_NAME}/g" kube/service.yaml
- sed -i "s/template/${CI_PROJECT_NAME}/g" kube/ingress.yaml
- kubectl apply -f kube
- kubectl get services
FROM python:3
ENV PYTHONUNBUFFERED 1
RUN mkdir /code
WORKDIR /code
COPY requirements.txt /code/
RUN pip3 install -r requirements.txt
COPY . /code/
\ No newline at end of file
apiVersion: apps/v1
kind: Deployment
metadata:
name: template
spec:
replicas: 1
selector:
matchLabels:
app: template
template:
metadata:
labels:
app: template
spec:
containers:
- name: django
image: zasyvcng.gra5.container-registry.ovh.net/library/latest
ports:
- containerPort: 8000
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: template
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
spec:
rules:
- host: template.kube.cs-campus.fr
http:
paths:
- path: /
backend:
serviceName: template
servicePort: 8000
apiVersion: v1
kind: Service
metadata:
name: template
spec:
selector:
app: template
ports:
- port: 8000
targetPort: 8000
type: NodePort
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment