.gitlab-ci.yml 2.1 KB
Newer Older
Nane Kratzke's avatar
Nane Kratzke committed
1
2
3
4
5
6
7
8
9
10
11
stages:
    - build
    - deploy
    - teardown

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

container:
  stage: build
Nane Kratzke's avatar
Nane Kratzke committed
12
13
14
  image:
      name: gcr.io/kaniko-project/executor:debug
      entrypoint: [""]
Nane Kratzke's avatar
Nane Kratzke committed
15
16
  only:
      changes:
17
      - .gitlab-ci.yml
Nane Kratzke's avatar
Nane Kratzke committed
18
19
20
21
22
      - hiphop/*
      - hiphop/*/*
  script:
      - mkdir -p /kaniko/.docker
      - echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json
Nane Kratzke's avatar
Nane Kratzke committed
23
      - cd hiphop
Nane Kratzke's avatar
Nane Kratzke committed
24
25
26
27
28
29
30
31
32
      - /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 \
Nane Kratzke's avatar
Nane Kratzke committed
33
          --docker-username=nane.kratzke \ 
Nane Kratzke's avatar
Nane Kratzke committed
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
          --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 -