.gitlab-ci.yml 2 KB
Newer Older
Nane Kratzke's avatar
Nane Kratzke committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
stages:
    - build
    - deploy
    - teardown

variables:
  KUBECTL: "transit/kubectl-plus:v1.19.4"
  CLUSTER: "rig.th-luebeck.dev"

container:
  stage: build
  only:
      changes:
      - hiphop/*
      - hiphop/*/*
  script:
      - mkdir -p /kaniko/.docker
      - echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json
      - cd src
      - /kaniko/executor --context . --destination $CI_REGISTRY_IMAGE/hiphop:latest

secrets:
  stage: build
  image: $KUBECTL
  script:
    - kubectl delete secret gitlab-registry-credentials || true
    - "kubectl create secret docker-registry gitlab-registry-credentials \
          --docker-server=$CI_REGISTRY \
          --docker-username=image-registry \ 
          --docker-password=$REGISTRY_READ_TOKEN \ 
          "

hiphop:
  stage: deploy
  image: $KUBECTL
  script:
    - NS=$(kubectl config view --minify --output 'jsonpath={..namespace}')
    - VHOST=hiphop.$NS.$CLUSTER TIER=1 mo deploy/hiphop-deploy+svc.yaml | kubectl apply -f -
    - VHOST=hiphop.$NS.$CLUSTER TIER=2 mo deploy/hiphop-deploy+svc.yaml | kubectl apply -f -
    - VHOST=hiphop.$NS.$CLUSTER TIER=3 mo deploy/hiphop-deploy+svc.yaml | kubectl apply -f -
    - VHOST=hiphop.$NS.$CLUSTER TIER=4 mo deploy/hiphop-deploy+svc.yaml | kubectl apply -f -
    - VHOST=hiphop.$NS.$CLUSTER mo deploy/hiphop-ingress.yaml | kubectl apply -f -

shutdown:
  stage: teardown
  image: $KUBECTL
  when: manual
  script:
    - NS=$(kubectl config view --minify --output 'jsonpath={..namespace}')
    - VHOST=hiphop.$NS.$CLUSTER TIER=1 mo deploy/hiphop-deploy+svc.yaml | kubectl delete -f -
    - VHOST=hiphop.$NS.$CLUSTER TIER=2 mo deploy/hiphop-deploy+svc.yaml | kubectl delete -f -
    - VHOST=hiphop.$NS.$CLUSTER TIER=3 mo deploy/hiphop-deploy+svc.yaml | kubectl delete -f -
    - VHOST=hiphop.$NS.$CLUSTER TIER=4 mo deploy/hiphop-deploy+svc.yaml | kubectl delete -f -
    - VHOST=hiphop.$NS.$CLUSTER mo deploy/hiphop-ingress.yaml | kubectl delete -f -