.gitlab-ci.yml 3.13 KB
Newer Older
Nane Kratzke's avatar
Nane Kratzke committed
1
2
image: "transit/kubectl-plus:v1.19.4"

Nane Kratzke's avatar
Nane Kratzke committed
3
4
5
6
variables:
  TRACING_SERVER: "http://apm-apm-server.default:8200"
  ES_HOST: "http://elasticsearch-master.default:9200"

Nane Kratzke's avatar
Nane Kratzke committed
7
stages:
Nane Kratzke's avatar
Nane Kratzke committed
8
    - prepare
Nane Kratzke's avatar
Nane Kratzke committed
9
10
11
12
    - build
    - deploy
    - teardown

Nane Kratzke's avatar
Nane Kratzke committed
13
14
15
16
17
18
kibana:
  stage: prepare
  script:
  - helm repo add elastic https://helm.elastic.co
  - helm install kibana elastic/kibana --set elasticsearchHosts=$ES_HOST

Nane Kratzke's avatar
Nane Kratzke committed
19
hiphop-container:
Nane Kratzke's avatar
Nane Kratzke committed
20
  stage: build
Nane Kratzke's avatar
Nane Kratzke committed
21
22
23
  image:
      name: gcr.io/kaniko-project/executor:debug
      entrypoint: [""]
Nane Kratzke's avatar
Nane Kratzke committed
24
25
  only:
      changes:
26
      - .gitlab-ci.yml
Nane Kratzke's avatar
Nane Kratzke committed
27
28
29
30
31
      - 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
32
      - cd hiphop
Nane Kratzke's avatar
Nane Kratzke committed
33
34
      - /kaniko/executor --context . --destination $CI_REGISTRY_IMAGE/hiphop:latest

Nane Kratzke's avatar
Nane Kratzke committed
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
space-container:
  stage: build
  image:
      name: gcr.io/kaniko-project/executor:debug
      entrypoint: [""]
  only:
      changes:
      - .gitlab-ci.yml
      - space/*
      - space/*/*
  script:
      - mkdir -p /kaniko/.docker
      - echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json
      - cd space
      - /kaniko/executor --context . --destination $CI_REGISTRY_IMAGE/space:latest

Nane Kratzke's avatar
Nane Kratzke committed
51
52
53
54
55
56
secrets:
  stage: build
  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
57
          --docker-username=image-registry \ 
Nane Kratzke's avatar
Nane Kratzke committed
58
59
60
          --docker-password=$REGISTRY_READ_TOKEN \ 
          "

Nane Kratzke's avatar
Nane Kratzke committed
61
62
space:
  stage: deploy
Nane Kratzke's avatar
Nane Kratzke committed
63
  when: manual
Nane Kratzke's avatar
Nane Kratzke committed
64
65
66
67
68
  script:
    - kubectl label ns $NS istio-injection=disabled --overwrite
    - kubectl delete -f deploy/space-deploy+svc.yaml || true
    - kubectl apply -f deploy/space-deploy+svc.yaml

Nane Kratzke's avatar
Nane Kratzke committed
69
70
hiphop:
  stage: deploy
Nane Kratzke's avatar
Nane Kratzke committed
71
  when: manual
Nane Kratzke's avatar
Nane Kratzke committed
72
  script:
Nane Kratzke's avatar
Nane Kratzke committed
73
    - NS=$(kubectl config view -o jsonpath="{..namespace}")
Nane Kratzke's avatar
Nane Kratzke committed
74
    - kubectl label ns $NS istio-injection=disabled --overwrite
Nane Kratzke's avatar
Nane Kratzke committed
75
76
77
78
    - 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
79
80
81
82
    - 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
83
84
85
86
87

shutdown:
  stage: teardown
  when: manual
  script:
Nane Kratzke's avatar
Nane Kratzke committed
88
    - NS=$(kubectl config view -o jsonpath="{..namespace}")
Nane Kratzke's avatar
rebuild    
Nane Kratzke committed
89
90
91
92
    - 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
Nane Kratzke committed
93
    - kubectl delete -f deploy/space-deploy+svc.yaml
Nane Kratzke's avatar
update    
Nane Kratzke committed
94
    - kubectl delete -f deploy/tracing.yaml
Nane Kratzke's avatar
Nane Kratzke committed
95
    - kubectl label ns $NS istio-injection=disabled --overwrite
Nane Kratzke's avatar
Nane Kratzke committed
96