-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
68 lines (62 loc) · 2.77 KB
/
.gitlab-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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
56
57
58
59
60
61
62
63
64
65
66
67
68
image : python:3.8.6-alpine3.11
variables:
DOCKER_DRIVER: overlay2
APP_NAME: tetrate-app
default:
before_script:
- |
apk --update add curl=7.67.0-r1 jq=1.6-r0 bash=5.0.11-r1
pip --no-cache-dir install --upgrade pip awscli==1.18.154 && aws --version && rm -rf /var/cache/apk/*
export KUBECTL_VERSION=v1.19.0
curl -L -o /usr/bin/kubectl https://storage.googleapis.com/kubernetes-release/release/${KUBECTL_VERSION}/bin/linux/amd64/kubectl
chmod +x /usr/bin/kubectl
kubectl version --client
curl --silent --location "https://github.com/weaveworks/eksctl/releases/latest/download/eksctl_$(uname -s)_amd64.tar.gz" | tar xz -C /tmp
mv /tmp/eksctl /usr/local/bin
eksctl version
curl -L -o /usr/bin/tctl https://tetrate.bintray.com/getcli/latest/linux/amd64/tctl
chmod +x /usr/bin/tctl
tctl --version
tctl config users set gitlab-admin --username admin --password $TSB_PASS --tenant $TSB_TENANT
tctl config clusters set blog-gitlab-cluster --bridge-address $TSB_URL:8443
tctl config profiles set blog-gitlab-env --cluster blog-gitlab-cluster --user gitlab-admin
tctl config profiles set-current blog-gitlab-env
stages:
- init
- publish
- deploy
unit-init:
stage: init
script:
- sleep 3
- echo "unit-tests executed"
- tctl get tenants
push_to_ecr:
stage: publish
image: docker:latest
services:
- docker:dind
before_script:
- |
docker --version
apk add --no-cache curl jq python3 py-pip && pip install awscli==1.18.154
script:
- $(aws ecr get-login --no-include-email --region $AWS_DEFAULT_REGION)
- export ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text)
- echo "ACCOUNT_ID= $ACCOUNT_ID"
- export REPOSITORY_URL=$ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/tetrate-app:${CI_PIPELINE_ID} && echo $REPOSITORY_URL
- cd src/
- docker build -t $REPOSITORY_URL .
- docker push $REPOSITORY_URL
- docker tag $REPOSITORY_URL $ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/tetrate-app:latest
- docker push $ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/tetrate-app:latest
bluegreen%20newversion:
stage: deploy
script:
- $(aws ecr get-login --no-include-email --region $AWS_DEFAULT_REGION)
- export ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text)
- echo "ACCOUNT_ID= $ACCOUNT_ID"
- export INIT_WEIGHT=80 && export NEW_WEIGHT=20
- eksctl utils write-kubeconfig --kubeconfig kubeconfig-$CLUSTER_NAME.yaml --cluster $CLUSTER_NAME --region $AWS_DEFAULT_REGION
- export KUBECONFIG=${PWD}/kubeconfig-$CLUSTER_NAME.yaml
- chmod 775 tsb-config.sh && ./tsb-config.sh deploy