-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add scheduling logic Signed-off-by: Sanjay Nathani <[email protected]>
- Loading branch information
1 parent
9b22142
commit 738bac0
Showing
2,375 changed files
with
885,131 additions
and
2 deletions.
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,140 @@ | ||
# Golang CircleCI 2.0 configuration file | ||
# | ||
# Check https://circleci.com/docs/2.0/language-go/ for more details | ||
version: 2.1 | ||
|
||
jobs: | ||
|
||
build: | ||
machine: | ||
image: circleci/classic:201808-01 | ||
working_directory: ~/go/src/github.com/litmuschaos/chaos-scheduler | ||
environment: | ||
K8S_VERSION: v1.12.0 | ||
KUBECONFIG: /home/circleci/.kube/config | ||
MINIKUBE_VERSION: v1.3.1 | ||
HOME: /home/circleci | ||
CHANGE_MINIKUBE_NONE_USER: true | ||
REPONAME: litmuschaos | ||
IMGNAME: chaos-scheduler | ||
IMGTAG: ci | ||
steps: | ||
- checkout | ||
- run: | ||
name: Setup kubectl | ||
command: | | ||
curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/${K8S_VERSION}/bin/linux/amd64/kubectl && chmod +x kubectl && sudo mv kubectl /usr/local/bin/ | ||
- run: | ||
name: Setup minikube | ||
command: | | ||
curl -Lo minikube https://storage.googleapis.com/minikube/releases/${MINIKUBE_VERSION}/minikube-linux-amd64 && chmod +x minikube | ||
sudo install minikube /usr/local/bin | ||
- run: | ||
name: Start minikube | ||
command: | | ||
sudo -E minikube start --vm-driver=none --cpus 2 --memory 4096 --kubernetes-version=${K8S_VERSION} | ||
- run: mkdir -p workspace | ||
- run: | ||
name: Setup ENV | ||
command: | | ||
echo 'export GOPATH="$HOME/go"' >> workspace/env-vars | ||
echo 'export PATH="$GOPATH/bin:$PATH"' >> workspace/env-vars | ||
echo 'export REPONAME="litmuschaos"' >> workspace/env-vars | ||
echo 'export IMGNAME="chaos-scheduler"' >> workspace/env-vars | ||
echo 'export IMGTAG="ci"' >> workspace/env-vars | ||
cat workspace/env-vars >> $BASH_ENV | ||
source $BASH_ENV | ||
- run: make deps | ||
- run: make gotasks | ||
- run: | | ||
docker build . -f build/Dockerfile -t ${REPONAME}/${IMGNAME}:${IMGTAG} | ||
- run: make test | ||
- run: | | ||
docker save -o workspace/image.tar ${REPONAME}/${IMGNAME}:${IMGTAG} | ||
- run: bash <(curl -s https://codecov.io/bash) -vz | ||
- persist_to_workspace: | ||
root: workspace | ||
paths: | ||
- image.tar | ||
- env-vars | ||
|
||
push: | ||
machine: | ||
image: circleci/classic:201808-01 | ||
environment: | ||
IMGTAG: ci | ||
working_directory: ~/go/src/github.com/litmuschaos/chaos-scheduler | ||
steps: | ||
- attach_workspace: | ||
at: /tmp/workspace | ||
- run: | | ||
cat /tmp/workspace/env-vars >> $BASH_ENV | ||
- checkout | ||
- run: | | ||
docker load -i /tmp/workspace/image.tar | ||
~/go/src/github.com/litmuschaos/chaos-scheduler/buildscripts/push --type=ci | ||
trivy-check: | ||
machine: true | ||
environment: | ||
TRIVYARCH: "64bit" | ||
steps: | ||
- run: | | ||
export VERSION=$(curl --silent "https://api.github.com/repos/aquasecurity/trivy/releases/latest" | grep '"tag_name":' | sed -E 's/.*"v([^"]+)".*/\1/') | ||
echo ${VERSION} | ||
sudo apt-get update | ||
sudo apt-get install -y rpm | ||
wget https://github.com/aquasecurity/trivy/releases/download/v${VERSION}/trivy_${VERSION}_Linux-${TRIVYARCH}.tar.gz | ||
tar zxvf trivy_${VERSION}_Linux-${TRIVYARCH}.tar.gz | ||
- run: | | ||
./trivy --exit-code 0 --severity HIGH --no-progress litmuschaos/chaos-scheduler:ci | ||
./trivy --exit-code 0 --severity CRITICAL --no-progress litmuschaos/chaos-scheduler:ci | ||
release: | ||
machine: | ||
image: circleci/classic:201808-01 | ||
environment: | ||
IMGTAG: ci | ||
working_directory: ~/go/src/github.com/litmuschaos/chaos-scheduler | ||
steps: | ||
- attach_workspace: | ||
at: /tmp/workspace | ||
- run: | | ||
cat /tmp/workspace/env-vars >> $BASH_ENV | ||
- checkout | ||
- run: | | ||
docker load -i /tmp/workspace/image.tar | ||
~/go/src/github.com/litmuschaos/chaos-scheduler/buildscripts/push --type=release | ||
workflows: | ||
version: 2 | ||
operator_build_deploy: | ||
jobs: | ||
- build: | ||
filters: | ||
## build jobs needs to be run for branch commits as well as tagged releases | ||
tags: | ||
only: /.*/ | ||
- trivy-check: | ||
requires: | ||
- build | ||
filters: | ||
tags: | ||
only: /.*/ | ||
- push: | ||
requires: | ||
- build | ||
filters: | ||
## push jobs needs to be run for branch commits as well as tagged releases | ||
## docker images push won't be performed for PRs due to ENV not being applied | ||
tags: | ||
only: /.*/ | ||
- release: | ||
requires: | ||
- build | ||
filters: | ||
## release jobs needs to be run for tagged releases alone & not for any branch commits | ||
branches: | ||
ignore: /.*/ | ||
tags: | ||
only: /.*/ |
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,4 @@ | ||
build/_output | ||
*.swp | ||
*.orig | ||
.idea/ |
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,94 @@ | ||
# Makefile for building Chaos Exporter | ||
# Reference Guide - https://www.gnu.org/software/make/manual/make.html | ||
|
||
IS_DOCKER_INSTALLED = $(shell which docker >> /dev/null 2>&1; echo $$?) | ||
|
||
# list only our namespaced directories | ||
PACKAGES = $(shell go list ./...) | ||
|
||
# docker info | ||
DOCKER_REPO ?= litmuschaos | ||
DOCKER_IMAGE ?= chaos-scheduler | ||
DOCKER_TAG ?= latest | ||
|
||
.PHONY: all | ||
all: deps format lint build test dockerops | ||
|
||
.PHONY: help | ||
help: | ||
@echo "" | ||
@echo "Usage:-" | ||
@echo "\tmake deps -- sets up dependencies for image build" | ||
@echo "\tmake gotasks -- builds the chaos scheduler binary" | ||
@echo "\tmake dockerops -- builds & pushes the chaos scheduler image" | ||
@echo "" | ||
|
||
.PHONY: deps | ||
deps: _build_check_docker godeps | ||
|
||
.PHONY: godeps | ||
godeps: | ||
@echo "" | ||
@echo "INFO:\tverifying dependencies for chaos scheduler build ..." | ||
@go get -v golang.org/x/lint/golint | ||
@go get -v golang.org/x/tools/cmd/goimports | ||
|
||
.PHONY: _build_check_docker | ||
_build_check_docker: | ||
@if [ $(IS_DOCKER_INSTALLED) -eq 1 ]; \ | ||
then echo "" \ | ||
&& echo "ERROR:\tdocker is not installed. Please install it before build." \ | ||
&& echo "" \ | ||
&& exit 1; \ | ||
fi; | ||
|
||
.PHONY: gotasks | ||
gotasks: format lint build | ||
|
||
.PHONY: format | ||
format: | ||
@echo "------------------" | ||
@echo "--> Running go fmt" | ||
@echo "------------------" | ||
@go fmt $(PACKAGES) | ||
|
||
.PHONY: lint | ||
lint: | ||
@echo "------------------" | ||
@echo "--> Running golint" | ||
@echo "------------------" | ||
@golint $(PACKAGES) | ||
@echo "------------------" | ||
@echo "--> Running go vet" | ||
@echo "------------------" | ||
@go vet $(PACKAGES) | ||
|
||
.PHONY: build | ||
build: | ||
@echo "------------------" | ||
@echo "--> Build Chaos Scheduler" | ||
@echo "------------------" | ||
@go build -o ${GOPATH}/src/github.com/litmuschaos/chaos-scheduler/build/_output/bin/chaos-scheduler -gcflags all=-trimpath=${GOPATH} -asmflags all=-trimpath=${GOPATH} github.com/litmuschaos/chaos-scheduler/cmd/manager | ||
|
||
.PHONY: codegen | ||
codegen: | ||
@echo "------------------" | ||
@echo "--> Updating Codegen" | ||
@echo "------------------" | ||
${GOPATH}/src/k8s.io/code-generator/generate-groups.sh all \ | ||
github.com/litmuschaos/chaos-scheduler/pkg/client github.com/litmuschaos/chaos-scheduler/pkg/apis \ | ||
litmuschaos:v1alpha1 | ||
|
||
.PHONY: test | ||
test: | ||
@echo "------------------" | ||
@echo "--> Run Go Test" | ||
@echo "------------------" | ||
@go test ./... -v | ||
|
||
.PHONY: dockerops | ||
dockerops: | ||
@echo "------------------" | ||
@echo "--> Build & Push chaos-scheduler docker image" | ||
@echo "------------------" | ||
sudo docker build . -f build/Dockerfile -t $(DOCKER_REPO)/$(DOCKER_IMAGE):$(DOCKER_TAG) |
Oops, something went wrong.