.gitlab-ci.yml 2.22 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=image-registry \ 
Nane Kratzke's avatar
Nane Kratzke committed
34
35
36
37
38
39
40
          --docker-password=$REGISTRY_READ_TOKEN \ 
          "

hiphop:
  stage: deploy
  image: $KUBECTL
  script:
Nane Kratzke's avatar
Nane Kratzke committed
41
    - kubectl apply -f deploy/tracing.yaml
Nane Kratzke's avatar
Nane Kratzke committed
42
    - NS=$(kubectl config view -o jsonpath="{..namespace}")
Nane Kratzke's avatar
Nane Kratzke committed
43
    - kubectl label ns $NS istio-injection=disabled --overwrite
Nane Kratzke's avatar
Nane Kratzke committed
44
45
46
47
    - TIER=1 mo deploy/hiphop-deploy+svc.yaml | kubectl delete -f - || true
    - TIER=2 mo deploy/hiphop-deploy+svc.yaml | kubectl delete -f - || true
    - TIER=3 mo deploy/hiphop-deploy+svc.yaml | kubectl delete -f - || true
    - TIER=4 mo deploy/hiphop-deploy+svc.yaml | kubectl delete -f - || true
Nane Kratzke's avatar
rebuild    
Nane Kratzke committed
48
49
50
51
    - TIER=1 mo deploy/hiphop-deploy+svc.yaml | kubectl apply -f -
    - TIER=2 mo deploy/hiphop-deploy+svc.yaml | kubectl apply -f -
    - TIER=3 mo deploy/hiphop-deploy+svc.yaml | kubectl apply -f -
    - TIER=4 mo deploy/hiphop-deploy+svc.yaml | kubectl apply -f -
Nane Kratzke's avatar
Nane Kratzke committed
52
53
54
55
56
57

shutdown:
  stage: teardown
  image: $KUBECTL
  when: manual
  script:
Nane Kratzke's avatar
Nane Kratzke committed
58
    - NS=$(kubectl config view -o jsonpath="{..namespace}")
Nane Kratzke's avatar
rebuild    
Nane Kratzke committed
59
60
61
62
    - TIER=1 mo deploy/hiphop-deploy+svc.yaml | kubectl delete -f -
    - TIER=2 mo deploy/hiphop-deploy+svc.yaml | kubectl delete -f -
    - TIER=3 mo deploy/hiphop-deploy+svc.yaml | kubectl delete -f -
    - TIER=4 mo deploy/hiphop-deploy+svc.yaml | kubectl delete -f -
Nane Kratzke's avatar
update    
Nane Kratzke committed
63
    - kubectl delete -f deploy/tracing.yaml
Nane Kratzke's avatar
Nane Kratzke committed
64
    - kubectl label ns $NS istio-injection=disabled --overwrite
Nane Kratzke's avatar
Nane Kratzke committed
65