.gitlab-ci.yml 1.93 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
stages:
Nane Kratzke's avatar
pubsub    
Nane Kratzke committed
4
5
6
7
8
9
10
11
12
13
14
15
16
17
- prepare
- build
- deploy
- terminate

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=$CI_REGISTRY_TOKEN \ 
        "
Nane Kratzke's avatar
Nane Kratzke committed
18
19
20
21
22
23

volumes:
    stage: prepare
    script:
    - kubectl apply -f volumes/redis-pvc.yaml

Nane Kratzke's avatar
pubsub    
Nane Kratzke committed
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
55
consumer:
  stage: build
  image:
    name: gcr.io/kaniko-project/executor:debug
    entrypoint: [""]
  only:
    changes:
    - .gitlab-ci.yml
    - consumer/*
    - consumer/*/*
  script:
  - mkdir -p /kaniko/.docker
  - echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json
  - cd consumer
  - /kaniko/executor --context . --destination $CI_REGISTRY_IMAGE/consumer:latest

producer:
  stage: build
  image:
    name: gcr.io/kaniko-project/executor:debug
    entrypoint: [""]
  only:
    changes:
    - .gitlab-ci.yml
    - producer/*
    - producer/*/*
  script:
  - mkdir -p /kaniko/.docker
  - echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json
  - cd producer
  - /kaniko/executor --context . --destination $CI_REGISTRY_IMAGE/producer:latest

Nane Kratzke's avatar
Nane Kratzke committed
56
57
58
redis:
   stage: deploy
   script:
Nane Kratzke's avatar
Nane Kratzke committed
59
   - kubectl delete -f deploy/redis-dep.yaml || true
Nane Kratzke's avatar
Nane Kratzke committed
60
61
   - kubectl apply -f deploy/redis-dep.yaml
   - kubectl apply -f deploy/redis-svc.yaml
Nane Kratzke's avatar
pubsub    
Nane Kratzke committed
62
63
64
65
66
67
68
69
70
71
72
73

pubsub-consumer:
    stage: deploy
    script:
    - mo deploy/pubsub-consumer-dep.yaml | kubectl delete -f - || true
    - mo deploy/pubsub-consumer-dep.yaml | kubectl apply -f -

pubsub-producer:
    stage: deploy
    script:
    - mo deploy/pubsub-producer-dep.yaml | kubectl delete -f - || true
    - mo deploy/pubsub-producer-dep.yaml | kubectl apply -f -