.gitlab-ci.yml 3.18 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
kibana:
  stage: prepare
  script:
  - helm repo add elastic https://helm.elastic.co
Nane Kratzke's avatar
Nane Kratzke committed
17
  - helm install kibana elastic/kibana --set elasticsearchHosts=$ES_HOST || true
Nane Kratzke's avatar
Nane Kratzke committed
18

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

Nane Kratzke's avatar
Nane Kratzke committed
45
space:
Nane Kratzke's avatar
Nane Kratzke committed
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
  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
61
space-svc:
Nane Kratzke's avatar
Nane Kratzke committed
62
  stage: deploy
Nane Kratzke's avatar
Nane Kratzke committed
63
  when: manual
Nane Kratzke's avatar
Nane Kratzke committed
64
  script:
Nane Kratzke's avatar
Nane Kratzke committed
65
66
    - NS=$(kubectl config view -o jsonpath="{..namespace}")
    - kubectl label ns $NS istio-injection=disabled --overwrite  
Nane Kratzke's avatar
Nane Kratzke committed
67
68
69
    - kubectl delete -f deploy/space-deploy+svc.yaml || true
    - kubectl apply -f deploy/space-deploy+svc.yaml

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

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