diff --git a/.circleci/config.yml b/.circleci/config.yml index e7249a9c..3a8ff1b7 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -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: | @@ -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 @@ -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.*/ \ No newline at end of file diff --git a/Makefile b/Makefile index edcf3ff6..c5f5df25 100644 --- a/Makefile +++ b/Makefile @@ -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 @@ -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) diff --git a/deploy/platformmonitoringapi/values-template.yaml b/deploy/platformmonitoringapi/values-template.yaml index 44c3ae67..8011cc20 100644 --- a/deploy/platformmonitoringapi/values-template.yaml +++ b/deploy/platformmonitoringapi/values-template.yaml @@ -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"