-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(feat): Add Gitlab CI/CD pipeline for chaos-exporter (#39)
* (feat): Add gitlab CI/CD pipeline for chaos-exporter Signed-off-by: Udit Gaurav <[email protected]>
- Loading branch information
1 parent
7b781af
commit f6d84f2
Showing
4 changed files
with
141 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
--- | ||
stages: | ||
- setup | ||
- build | ||
- test | ||
- push | ||
- cleanup | ||
|
||
ClusterSetup: | ||
stage: setup | ||
tags: | ||
- setup | ||
script: | ||
- chmod 755 ./build/gitlab/stages/1-cluster-setup/gcp | ||
- ./build/gitlab/stages/1-cluster-setup/gcp | ||
|
||
artifacts: | ||
when: always | ||
paths: | ||
- .kube/ | ||
|
||
Build: | ||
|
||
stage: build | ||
tags: | ||
- build | ||
script: | ||
|
||
- export COMMIT=${CI_COMMIT_SHORT_SHA} | ||
- export GOPATH=$HOME/go | ||
- export GOROOT=/usr/local/go | ||
- export PATH=$HOME/go/bin:$PATH | ||
- mkdir -p $HOME/go/src/github.com/${REPONAME}/${IMAGENAME} | ||
- rsync -az --delete ${CI_PROJECT_DIR}/ ${GOPATH}/src/github.com/${REPONAME}/${IMAGENAME}/ #CI_PROJECT_DIR is full path where project is cloned | ||
- go env | ||
- cd ~/go/src/github.com/${REPONAME}/${IMAGENAME} | ||
- make godeps | ||
# bdd testing dependencies - ginkgo and gomega | ||
- make bdddeps | ||
# Build | ||
- make build | ||
|
||
Test: | ||
|
||
stage: test | ||
tags: | ||
- test | ||
script: | ||
- cd ~/go/src/github.com/${REPONAME}/${IMAGENAME} | ||
- make test | ||
|
||
Push: | ||
|
||
stage: push | ||
tags: | ||
- push | ||
script: | ||
- make dockerops | ||
|
||
ClusterCleanup: | ||
|
||
when: always | ||
stage: cleanup | ||
tags: | ||
- cleanup | ||
script: | ||
- chmod 755 ./build/gitlab/stages/2-cluster-cleanup/cluster-cleanup | ||
- ./build/gitlab/stages/2-cluster-cleanup/cluster-cleanup | ||
|
||
artifacts: | ||
when: always | ||
paths: | ||
- .kube/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
path=$(pwd) | ||
echo $SDK_TOKEN > key.json | ||
gcloud auth activate-service-account --key-file=key.json | ||
gcloud config set project ${PROJECT_NAME} | ||
export GOOGLE_APPLICATION_CREDENTIALS="$path/key.json" | ||
|
||
truncate -s 0 ~/logs/vpc | ||
truncate -s 0 ~/logs/clusters | ||
|
||
git clone https://github.com/mayadata-io/litmus.git | ||
cd litmus/k8s/gcp/k8s-installer/ | ||
|
||
# Create VPC | ||
echo "CREATING VPC" | ||
ansible-playbook create-vpc.yml --extra-vars "project=${PROJECT_NAME}" | ||
|
||
# Create k8s cluster | ||
echo "CREATING CLUSTER" | ||
ansible-playbook create-k8s-cluster.yml -vv --extra-vars "project=${PROJECT_NAME} nodes=1 k8s_version=1.11.1" | ||
|
||
mkdir $path/.kube | ||
cat ~/.kube/config > $path/.kube/config | ||
cat ~/.kube/config > $path/.kube/admin.conf | ||
cat ~/logs/clusters > $path/.kube/clusters | ||
cat ~/logs/vpc > $path/.kube/vpc | ||
|
||
# Export VPC network name | ||
VPC=`cat $path/.kube/vpc` | ||
echo $VPC | ||
echo "Checking Cluster availability" | ||
ansible-playbook check-cluster-availability.yml --extra-vars "nodes=1" | ||
kubectl get nodes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
path=$(pwd) | ||
echo $SDK_TOKEN > key.json | ||
gcloud auth activate-service-account --key-file=key.json | ||
gcloud config set project ${PROJECT_NAME} | ||
export GOOGLE_APPLICATION_CREDENTIALS="$path/key.json" | ||
|
||
cp $path/.kube/clusters ~/logs | ||
cp $path/.kube/vpc ~/logs | ||
git clone https://github.com/mayadata-io/litmus.git | ||
cd litmus/k8s/gcp/k8s-installer/ | ||
echo "************************** Cluster cleanup started **************************" | ||
|
||
# Fetching cluster name | ||
cluster_name=$(cat ~/logs/clusters) | ||
|
||
# Delete k8s cluster | ||
ansible-playbook delete-k8s-cluster.yml | ||
|
||
# Export VPC network name | ||
VPC=`cat $path/.kube/vpc` | ||
echo $VPC | ||
|
||
# Delete VPC | ||
ansible-playbook delete-vpc.yml --extra-vars "project=${PROJECT-NAME}" | ||
|
||
echo $cluster_name | ||
rm -rf litmus |