Skip to content

Commit

Permalink
add flows for staging and artifactory
Browse files Browse the repository at this point in the history
  • Loading branch information
alin999 committed Jul 4, 2019
1 parent 5546c59 commit 88b6f49
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 12 deletions.
63 changes: 57 additions & 6 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,10 @@ jobs:
make clean_k8s
when: always


gke_deploy:
<<: *defaults
steps:
- checkout
- run:
name: Build image
command: |
make build
- run:
name: GKE Auth
command: |
Expand All @@ -121,7 +116,25 @@ jobs:
- run:
name: GKE Deploy
command: |
make gke_deploy
make gke_k8s_deploy
artifactory_deploy:
<<: *defaults

steps:
- checkout

- run:
name: Artifactory Docker Push
command: |
make artifactory_docker_push
- run:
name: Artifactory Helm Push
command: |
make artifactory_helm_push
workflows:
version: 2
Expand All @@ -147,3 +160,41 @@ workflows:
branches:
only:
- master

staging:
jobs:
- test:
context: org-staging
filters:
branches:
only:
- /release.*/
- gke_deploy:
context: org-staging
requires:
- test
filters:
branches:
only:
- /release.*/

artifactory:
jobs:
- test:
context: org-global
filters:
branches:
ignore: /.*/
tags:
only:
- /artifactory.*/
- artifactory_deploy:
context: org-global
requires:
- test
filters:
branches:
ignore: /.*/
tags:
only:
- /artifactory.*/
24 changes: 19 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
IMAGE_NAME ?= platformmonitoringapi
IMAGE_TAG ?= latest
ARTIFACTORY_TAG ?=$(shell echo "$(CIRCLE_TAG)" | awk -F/ '{print $$2}')
IMAGE ?= $(GKE_DOCKER_REGISTRY)/$(GKE_PROJECT_ID)/$(IMAGE_NAME)

ifdef CIRCLECI
Expand Down Expand Up @@ -61,9 +62,22 @@ gke_docker_push: build
_helm:
curl https://raw.githubusercontent.com/kubernetes/helm/master/scripts/get | bash -s -- -v v2.11.0

gke_deploy: _helm
gke_k8s_deploy: _helm
gcloud --quiet container clusters get-credentials $(GKE_CLUSTER_NAME) $(CLUSTER_ZONE_REGION)
helm \
--set "global.env=$(HELM_ENV)" \
--set "IMAGE.$(HELM_ENV)=$(IMAGE):$(CIRCLE_SHA1)" \
upgrade --install platformmonitoringapi deploy/platformmonitoringapi/ --wait --timeout 600
helm -f deploy/platformmonitoringapi/values-$(HELM_ENV).yaml --set "IMAGE=$(IMAGE):$(CIRCLE_SHA1)" upgrade --install platformmonitoringapi deploy/platformmonitoringapi/ --wait --timeout 600

artifactory_docker_push: build
docker tag $(IMAGE_NAME):$(IMAGE_TAG) $(ARTIFACTORY_DOCKER_REPO)/$(IMAGE_NAME):$(ARTIFACTORY_TAG)
docker login $(ARTIFACTORY_DOCKER_REPO) --username=$(ARTIFACTORY_USERNAME) --password=$(ARTIFACTORY_PASSWORD)
docker push $(ARTIFACTORY_DOCKER_REPO)/$(IMAGE_NAME):$(ARTIFACTORY_TAG)

artifactory_helm_push: _helm
mkdir -p temp_deploy/platformmonitoringapi
cp -Rf deploy/platformmonitoringapi/. temp_deploy/platformmonitoringapi
cp temp_deploy/platformmonitoringapi/values-template.yaml temp_deploy/platformmonitoringapi/values.yaml
sed -i "s/IMAGE_TAG/$(ARTIFACTORY_TAG)/g" temp_deploy/platformmonitoringapi/values.yaml
find temp_deploy/platformmonitoringapi -type f -name 'values-*' -delete
helm init --client-only
helm package --app-version=$(ARTIFACTORY_TAG) --version=$(ARTIFACTORY_TAG) temp_deploy/platformmonitoringapi/
helm plugin install https://github.com/belitre/helm-push-artifactory-plugin
helm push-artifactory $(IMAGE_NAME)-$(ARTIFACTORY_TAG).tgz $(ARTIFACTORY_HELM_REPO) --username $(ARTIFACTORY_USERNAME) --password $(ARTIFACTORY_PASSWORD)
2 changes: 1 addition & 1 deletion deploy/platformmonitoringapi/values-template.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
IMAGE: ''
IMAGE: neuro-docker-local-public.jfrog.io/platformmonitoringapi:IMAGE_TAG
NP_MONITORING_REQUESTS_CPU: "0.1"
NP_MONITORING_LIMITS_CPU: "0.3"
NP_MONITORING_REQUESTS_MEMORY: "50Mi"
Expand Down

0 comments on commit 88b6f49

Please sign in to comment.