From 7780497a5588612cd6b18d64924e4c963f345085 Mon Sep 17 00:00:00 2001 From: AutomationGeek-dev <81010228+AutomationGeek-dev@users.noreply.github.com> Date: Mon, 22 Mar 2021 11:47:56 -0600 Subject: [PATCH 01/43] Use Single job starter workflow --- .semaphore/semaphore.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 .semaphore/semaphore.yml diff --git a/.semaphore/semaphore.yml b/.semaphore/semaphore.yml new file mode 100644 index 0000000..a9e572b --- /dev/null +++ b/.semaphore/semaphore.yml @@ -0,0 +1,13 @@ +version: v1.0 +name: Initial Pipeline +agent: + machine: + type: e1-standard-2 + os_image: ubuntu1804 +blocks: + - name: 'Block #1' + task: + jobs: + - name: 'Job #1' + commands: + - checkout From bc3a4888d0ade5cc9826e198b2909abc86541a20 Mon Sep 17 00:00:00 2001 From: AutomationGeek-dev Date: Mon, 22 Mar 2021 17:52:24 +0000 Subject: [PATCH 02/43] Update Semaphore configuration --- .semaphore/semaphore.yml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.semaphore/semaphore.yml b/.semaphore/semaphore.yml index a9e572b..624da11 100644 --- a/.semaphore/semaphore.yml +++ b/.semaphore/semaphore.yml @@ -5,9 +5,16 @@ agent: type: e1-standard-2 os_image: ubuntu1804 blocks: - - name: 'Block #1' + - name: Hello world task: jobs: - - name: 'Job #1' + - name: Build app commands: + - 'echo "${DOCKER_PASSWORD}" | docker login -u "${DOCKER_USERNAME}" --password-stdin' - checkout + - docker-compose build + - 'docker tag pyflasksemaphore:latest "$DOCKER_USERNAME"/helloworld:latest' + - 'docker tag pyflasksemaphore:latest "$DOCKER_USERNAME"/helloworld:$SEMAPHORE_WORKFLOW_ID' + - 'docker push "$DOCKER_USERNAME"/helloworld:latest' + - 'docker push "$DOCKER_USERNAME"/helloworld:$SEMAPHORE_WORKFLOW_ID' + - docker images From bcfe4fe2fdf5b9cae36fe5c68ebb6a79b65e5ac4 Mon Sep 17 00:00:00 2001 From: AutomationGeek-dev Date: Mon, 22 Mar 2021 17:52:52 +0000 Subject: [PATCH 03/43] Update Semaphore configuration --- .semaphore/semaphore.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.semaphore/semaphore.yml b/.semaphore/semaphore.yml index 624da11..00d8312 100644 --- a/.semaphore/semaphore.yml +++ b/.semaphore/semaphore.yml @@ -18,3 +18,5 @@ blocks: - 'docker push "$DOCKER_USERNAME"/helloworld:latest' - 'docker push "$DOCKER_USERNAME"/helloworld:$SEMAPHORE_WORKFLOW_ID' - docker images + secrets: + - name: Docker Secrets From c9cbb9b119a729e81dc78111229b28aa69c3faaa Mon Sep 17 00:00:00 2001 From: AutomationGeek-dev <81010228+AutomationGeek-dev@users.noreply.github.com> Date: Mon, 22 Mar 2021 11:55:21 -0600 Subject: [PATCH 04/43] Create docker-compose.yml --- docker-compose.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 docker-compose.yml diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..e637a23 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,12 @@ +version: '3.7' + +services: + users: + build: + context: . + dockerfile: Dockerfile + ports: + - 5001:5000 + environment: + #- FLASK_APP=app/__init__.py + - FLASK_ENV=development From d0ee9ecde309f1fa2e7ff3f2350a0e9534335972 Mon Sep 17 00:00:00 2001 From: AutomationGeek-dev <81010228+AutomationGeek-dev@users.noreply.github.com> Date: Mon, 22 Mar 2021 11:56:40 -0600 Subject: [PATCH 05/43] Update docker-compose.yml --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index e637a23..893b9df 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,7 +1,7 @@ version: '3.7' services: - users: + hello-world: build: context: . dockerfile: Dockerfile From 61c9dcddf47caaec81ffad0f886753477ebc3b9d Mon Sep 17 00:00:00 2001 From: AutomationGeek-dev Date: Mon, 22 Mar 2021 17:57:54 +0000 Subject: [PATCH 06/43] Update Semaphore configuration --- .semaphore/semaphore.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.semaphore/semaphore.yml b/.semaphore/semaphore.yml index 00d8312..3335f94 100644 --- a/.semaphore/semaphore.yml +++ b/.semaphore/semaphore.yml @@ -13,8 +13,8 @@ blocks: - 'echo "${DOCKER_PASSWORD}" | docker login -u "${DOCKER_USERNAME}" --password-stdin' - checkout - docker-compose build - - 'docker tag pyflasksemaphore:latest "$DOCKER_USERNAME"/helloworld:latest' - - 'docker tag pyflasksemaphore:latest "$DOCKER_USERNAME"/helloworld:$SEMAPHORE_WORKFLOW_ID' + - 'docker tag hello-world:latest "$DOCKER_USERNAME"/helloworld:latest' + - 'docker tag hello-world:latest "$DOCKER_USERNAME"/helloworld:$SEMAPHORE_WORKFLOW_ID' - 'docker push "$DOCKER_USERNAME"/helloworld:latest' - 'docker push "$DOCKER_USERNAME"/helloworld:$SEMAPHORE_WORKFLOW_ID' - docker images From e077e10138f84eb734f7123785b1a97c2198592a Mon Sep 17 00:00:00 2001 From: AutomationGeek-dev Date: Mon, 22 Mar 2021 18:00:58 +0000 Subject: [PATCH 07/43] Update Semaphore configuration --- .semaphore/semaphore.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.semaphore/semaphore.yml b/.semaphore/semaphore.yml index 3335f94..dc1890b 100644 --- a/.semaphore/semaphore.yml +++ b/.semaphore/semaphore.yml @@ -13,8 +13,8 @@ blocks: - 'echo "${DOCKER_PASSWORD}" | docker login -u "${DOCKER_USERNAME}" --password-stdin' - checkout - docker-compose build - - 'docker tag hello-world:latest "$DOCKER_USERNAME"/helloworld:latest' - - 'docker tag hello-world:latest "$DOCKER_USERNAME"/helloworld:$SEMAPHORE_WORKFLOW_ID' + - 'docker tag hello-world "$DOCKER_USERNAME"/helloworld:latest' + - 'docker tag hello-world "$DOCKER_USERNAME"/helloworld:$SEMAPHORE_WORKFLOW_ID' - 'docker push "$DOCKER_USERNAME"/helloworld:latest' - 'docker push "$DOCKER_USERNAME"/helloworld:$SEMAPHORE_WORKFLOW_ID' - docker images From 66c97f1896af2ff397181de19018d18f89103797 Mon Sep 17 00:00:00 2001 From: AutomationGeek-dev Date: Mon, 22 Mar 2021 18:10:03 +0000 Subject: [PATCH 08/43] Update Semaphore configuration --- .semaphore/semaphore.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.semaphore/semaphore.yml b/.semaphore/semaphore.yml index dc1890b..41a9666 100644 --- a/.semaphore/semaphore.yml +++ b/.semaphore/semaphore.yml @@ -15,7 +15,7 @@ blocks: - docker-compose build - 'docker tag hello-world "$DOCKER_USERNAME"/helloworld:latest' - 'docker tag hello-world "$DOCKER_USERNAME"/helloworld:$SEMAPHORE_WORKFLOW_ID' - - 'docker push "$DOCKER_USERNAME"/helloworld:latest' + - docker push "$DOCKER_USERNAME"/helloworld - 'docker push "$DOCKER_USERNAME"/helloworld:$SEMAPHORE_WORKFLOW_ID' - docker images secrets: From c208d26273ca83a927d066875926b40aa828ebcc Mon Sep 17 00:00:00 2001 From: AutomationGeek-dev Date: Mon, 22 Mar 2021 18:11:33 +0000 Subject: [PATCH 09/43] Update Semaphore configuration --- .semaphore/semaphore.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.semaphore/semaphore.yml b/.semaphore/semaphore.yml index 41a9666..f12f065 100644 --- a/.semaphore/semaphore.yml +++ b/.semaphore/semaphore.yml @@ -13,7 +13,7 @@ blocks: - 'echo "${DOCKER_PASSWORD}" | docker login -u "${DOCKER_USERNAME}" --password-stdin' - checkout - docker-compose build - - 'docker tag hello-world "$DOCKER_USERNAME"/helloworld:latest' + - docker tag hello-world "$DOCKER_USERNAME"/helloworld - 'docker tag hello-world "$DOCKER_USERNAME"/helloworld:$SEMAPHORE_WORKFLOW_ID' - docker push "$DOCKER_USERNAME"/helloworld - 'docker push "$DOCKER_USERNAME"/helloworld:$SEMAPHORE_WORKFLOW_ID' From 17cb1d682804d349d6def1a5df0cca0a994fe19a Mon Sep 17 00:00:00 2001 From: AutomationGeek-dev Date: Mon, 22 Mar 2021 18:18:25 +0000 Subject: [PATCH 10/43] Update Semaphore configuration --- .semaphore/semaphore.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.semaphore/semaphore.yml b/.semaphore/semaphore.yml index f12f065..730cea3 100644 --- a/.semaphore/semaphore.yml +++ b/.semaphore/semaphore.yml @@ -13,6 +13,8 @@ blocks: - 'echo "${DOCKER_PASSWORD}" | docker login -u "${DOCKER_USERNAME}" --password-stdin' - checkout - docker-compose build + - docker image + - docker ps - docker tag hello-world "$DOCKER_USERNAME"/helloworld - 'docker tag hello-world "$DOCKER_USERNAME"/helloworld:$SEMAPHORE_WORKFLOW_ID' - docker push "$DOCKER_USERNAME"/helloworld From 7f2c39621324f7b2bbd1d0f854dca56118110259 Mon Sep 17 00:00:00 2001 From: AutomationGeek-dev Date: Mon, 22 Mar 2021 18:20:08 +0000 Subject: [PATCH 11/43] Update Semaphore configuration --- .semaphore/semaphore.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.semaphore/semaphore.yml b/.semaphore/semaphore.yml index 730cea3..1167c77 100644 --- a/.semaphore/semaphore.yml +++ b/.semaphore/semaphore.yml @@ -13,8 +13,7 @@ blocks: - 'echo "${DOCKER_PASSWORD}" | docker login -u "${DOCKER_USERNAME}" --password-stdin' - checkout - docker-compose build - - docker image - - docker ps + - docker image ls - docker tag hello-world "$DOCKER_USERNAME"/helloworld - 'docker tag hello-world "$DOCKER_USERNAME"/helloworld:$SEMAPHORE_WORKFLOW_ID' - docker push "$DOCKER_USERNAME"/helloworld From ba7e8ca87b5b5a0d9b33f0b044b7dba01bc71332 Mon Sep 17 00:00:00 2001 From: AutomationGeek-dev <81010228+AutomationGeek-dev@users.noreply.github.com> Date: Mon, 22 Mar 2021 12:22:45 -0600 Subject: [PATCH 12/43] Update docker-compose.yml --- docker-compose.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/docker-compose.yml b/docker-compose.yml index 893b9df..ccc7f91 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,6 +5,7 @@ services: build: context: . dockerfile: Dockerfile + container_name: hello-world ports: - 5001:5000 environment: From 59cc77a094fb832ad00240d870ed43d5be820969 Mon Sep 17 00:00:00 2001 From: AutomationGeek-dev <81010228+AutomationGeek-dev@users.noreply.github.com> Date: Mon, 22 Mar 2021 12:24:13 -0600 Subject: [PATCH 13/43] Update docker-compose.yml --- docker-compose.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/docker-compose.yml b/docker-compose.yml index ccc7f91..e192ceb 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,6 +5,7 @@ services: build: context: . dockerfile: Dockerfile + image: hello-world container_name: hello-world ports: - 5001:5000 From 12e5270f5408ed943aadc94f67086d1fced521f6 Mon Sep 17 00:00:00 2001 From: AutomationGeek-dev <81010228+AutomationGeek-dev@users.noreply.github.com> Date: Mon, 22 Mar 2021 12:26:43 -0600 Subject: [PATCH 14/43] Update docker-compose.yml --- docker-compose.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index e192ceb..1abfae9 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,11 +2,10 @@ version: '3.7' services: hello-world: + image: hello-world build: context: . dockerfile: Dockerfile - image: hello-world - container_name: hello-world ports: - 5001:5000 environment: From 421c74fa1ceeb16a0f917afbdcce682dda9ec710 Mon Sep 17 00:00:00 2001 From: AutomationGeek-dev Date: Mon, 22 Mar 2021 18:27:47 +0000 Subject: [PATCH 15/43] Update Semaphore configuration --- .semaphore/semaphore.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.semaphore/semaphore.yml b/.semaphore/semaphore.yml index 1167c77..4a9ce1b 100644 --- a/.semaphore/semaphore.yml +++ b/.semaphore/semaphore.yml @@ -14,9 +14,9 @@ blocks: - checkout - docker-compose build - docker image ls - - docker tag hello-world "$DOCKER_USERNAME"/helloworld - - 'docker tag hello-world "$DOCKER_USERNAME"/helloworld:$SEMAPHORE_WORKFLOW_ID' - - docker push "$DOCKER_USERNAME"/helloworld + - 'docker tag hello-world:latest "$DOCKER_USERNAME"/helloworld:latest' + - 'docker tag hello-world:latest "$DOCKER_USERNAME"/helloworld:$SEMAPHORE_WORKFLOW_ID' + - 'docker push "$DOCKER_USERNAME"/helloworld:latest' - 'docker push "$DOCKER_USERNAME"/helloworld:$SEMAPHORE_WORKFLOW_ID' - docker images secrets: From 8562b763902e4169d8a7845d01f3b4731442fb30 Mon Sep 17 00:00:00 2001 From: AutomationGeek-dev Date: Mon, 22 Mar 2021 19:39:29 +0000 Subject: [PATCH 16/43] Update Semaphore configuration --- .semaphore/pipeline_2.yml | 32 ++++++++++++++++++++++++++++++++ .semaphore/semaphore.yml | 5 +++++ 2 files changed, 37 insertions(+) create mode 100644 .semaphore/pipeline_2.yml diff --git a/.semaphore/pipeline_2.yml b/.semaphore/pipeline_2.yml new file mode 100644 index 0000000..f83cfb9 --- /dev/null +++ b/.semaphore/pipeline_2.yml @@ -0,0 +1,32 @@ +version: v1.0 +name: Pipeline 2 +agent: + machine: + type: e1-standard-2 + os_image: ubuntu1804 +blocks: + - name: Docker-login-pull + task: + jobs: + - name: docker-login + commands: + - 'echo "${DOCKER_PASSWORD}" | docker login -u "${DOCKER_USERNAME}" --password-stdin' + - 'docker pull $DOCKER_USERNAME"/helloworld:$SEMAPHORE_WORKFLOW_ID' + secrets: + - name: Docker Secrets + - name: Deploy + task: + secrets: + - name: Docker Secrets + - name: Digital Ocean Secret + env_vars: + - name: cluster_name + value: test-kubernetes + prologue: + commands: + - doctl auth init --access-token $DO_ACCESS_TOKEN + - 'doctl kubernetes cluster kubeconfig save "${CLUSTER_NAME}"' + - checkout + jobs: + - name: 'Job #1' + commands: [] diff --git a/.semaphore/semaphore.yml b/.semaphore/semaphore.yml index 4a9ce1b..29499a1 100644 --- a/.semaphore/semaphore.yml +++ b/.semaphore/semaphore.yml @@ -21,3 +21,8 @@ blocks: - docker images secrets: - name: Docker Secrets +promotions: + - name: Promotion 1 + pipeline_file: pipeline_2.yml + auto_promote: + when: (branch = 'setup-semaphore' OR tag =~ '^hotfix*') AND result = 'passed' From ffab29cfb9f8b19faa3c99670ba86831114f1f9b Mon Sep 17 00:00:00 2001 From: AutomationGeek-dev Date: Mon, 22 Mar 2021 19:41:58 +0000 Subject: [PATCH 17/43] Update Semaphore configuration --- .semaphore/pipeline_2.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.semaphore/pipeline_2.yml b/.semaphore/pipeline_2.yml index f83cfb9..e5255b1 100644 --- a/.semaphore/pipeline_2.yml +++ b/.semaphore/pipeline_2.yml @@ -11,7 +11,7 @@ blocks: - name: docker-login commands: - 'echo "${DOCKER_PASSWORD}" | docker login -u "${DOCKER_USERNAME}" --password-stdin' - - 'docker pull $DOCKER_USERNAME"/helloworld:$SEMAPHORE_WORKFLOW_ID' + - 'docker pull $DOCKER_USERNAME/helloworld:$SEMAPHORE_WORKFLOW_ID' secrets: - name: Docker Secrets - name: Deploy From acc5cf2843ba10ff8be10fb86f9ade8b6d4dae74 Mon Sep 17 00:00:00 2001 From: AutomationGeek-dev Date: Mon, 22 Mar 2021 19:46:31 +0000 Subject: [PATCH 18/43] Update Semaphore configuration --- .semaphore/pipeline_2.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.semaphore/pipeline_2.yml b/.semaphore/pipeline_2.yml index e5255b1..c37bf26 100644 --- a/.semaphore/pipeline_2.yml +++ b/.semaphore/pipeline_2.yml @@ -25,8 +25,8 @@ blocks: prologue: commands: - doctl auth init --access-token $DO_ACCESS_TOKEN - - 'doctl kubernetes cluster kubeconfig save "${CLUSTER_NAME}"' + - 'doctl kubernetes cluster kubeconfig save ${CLUSTER_NAME}' - checkout jobs: - - name: 'Job #1' + - name: Canary Deployment commands: [] From 595a8b8a60f88fc5448e7ddb6b57f61aafe600cf Mon Sep 17 00:00:00 2001 From: AutomationGeek-dev Date: Mon, 22 Mar 2021 19:50:03 +0000 Subject: [PATCH 19/43] Update Semaphore configuration --- .semaphore/pipeline_2.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.semaphore/pipeline_2.yml b/.semaphore/pipeline_2.yml index c37bf26..2ccc714 100644 --- a/.semaphore/pipeline_2.yml +++ b/.semaphore/pipeline_2.yml @@ -25,7 +25,7 @@ blocks: prologue: commands: - doctl auth init --access-token $DO_ACCESS_TOKEN - - 'doctl kubernetes cluster kubeconfig save ${CLUSTER_NAME}' + - 'doctl kubernetes cluster kubeconfig save "${CLUSTER_NAME}"' - checkout jobs: - name: Canary Deployment From 129918db968b182e4a5109a3676cb45c7b210e45 Mon Sep 17 00:00:00 2001 From: AutomationGeek-dev <81010228+AutomationGeek-dev@users.noreply.github.com> Date: Mon, 22 Mar 2021 13:52:18 -0600 Subject: [PATCH 20/43] Create service.yml --- manifests/service.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 manifests/service.yml diff --git a/manifests/service.yml b/manifests/service.yml new file mode 100644 index 0000000..42a0d09 --- /dev/null +++ b/manifests/service.yml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: Service +metadata: + name: helloworld-app +spec: + selector: + app: helloworld + type: LoadBalancer + ports: + - port: 80 + targetPort: 5001 From b2981181bc38f9bc1fd0cc507486b4e3a8404cb0 Mon Sep 17 00:00:00 2001 From: AutomationGeek-dev Date: Mon, 22 Mar 2021 19:57:05 +0000 Subject: [PATCH 21/43] Update Semaphore configuration --- .semaphore/pipeline_2.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.semaphore/pipeline_2.yml b/.semaphore/pipeline_2.yml index 2ccc714..1c854f6 100644 --- a/.semaphore/pipeline_2.yml +++ b/.semaphore/pipeline_2.yml @@ -25,8 +25,9 @@ blocks: prologue: commands: - doctl auth init --access-token $DO_ACCESS_TOKEN - - 'doctl kubernetes cluster kubeconfig save "${CLUSTER_NAME}"' + - 'doctl kubernetes cluster kubeconfig save ${CLUSTER_NAME}' - checkout jobs: - name: Canary Deployment - commands: [] + commands: + - kubectl apply -f manifests/service.yml From c67a4129ca4205e8ad6aa3cd0df1639699329e2e Mon Sep 17 00:00:00 2001 From: AutomationGeek-dev Date: Mon, 22 Mar 2021 20:03:57 +0000 Subject: [PATCH 22/43] Update Semaphore configuration --- .semaphore/pipeline_2.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.semaphore/pipeline_2.yml b/.semaphore/pipeline_2.yml index 1c854f6..1fe9f8a 100644 --- a/.semaphore/pipeline_2.yml +++ b/.semaphore/pipeline_2.yml @@ -20,12 +20,14 @@ blocks: - name: Docker Secrets - name: Digital Ocean Secret env_vars: - - name: cluster_name + - name: CLUSTER_NAME value: test-kubernetes prologue: commands: + - 'wget https://github.com/digitalocean/doctl/releases/download/v1.20.0/doctl-1.20.0-linux-amd64.tar.gz' + - sudo cp doctl /usr/local/bin - doctl auth init --access-token $DO_ACCESS_TOKEN - - 'doctl kubernetes cluster kubeconfig save ${CLUSTER_NAME}' + - 'doctl kubernetes cluster kubeconfig save "${CLUSTER_NAME}"' - checkout jobs: - name: Canary Deployment From 61a87e6484d00938ee2f0c29b7ce0250773429a4 Mon Sep 17 00:00:00 2001 From: AutomationGeek-dev Date: Mon, 22 Mar 2021 20:08:47 +0000 Subject: [PATCH 23/43] Update Semaphore configuration --- .semaphore/pipeline_2.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.semaphore/pipeline_2.yml b/.semaphore/pipeline_2.yml index 1fe9f8a..af3fba8 100644 --- a/.semaphore/pipeline_2.yml +++ b/.semaphore/pipeline_2.yml @@ -24,8 +24,6 @@ blocks: value: test-kubernetes prologue: commands: - - 'wget https://github.com/digitalocean/doctl/releases/download/v1.20.0/doctl-1.20.0-linux-amd64.tar.gz' - - sudo cp doctl /usr/local/bin - doctl auth init --access-token $DO_ACCESS_TOKEN - 'doctl kubernetes cluster kubeconfig save "${CLUSTER_NAME}"' - checkout From a6f3400f83b6718a926948ab504bf74165c496c0 Mon Sep 17 00:00:00 2001 From: AutomationGeek-dev <81010228+AutomationGeek-dev@users.noreply.github.com> Date: Mon, 22 Mar 2021 14:33:04 -0600 Subject: [PATCH 24/43] Create deployment.yml --- manifests/deployment.yml | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 manifests/deployment.yml diff --git a/manifests/deployment.yml b/manifests/deployment.yml new file mode 100644 index 0000000..eff7d23 --- /dev/null +++ b/manifests/deployment.yml @@ -0,0 +1,32 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: $deployment +spec: + replicas: $replicas + selector: + matchLabels: + app: addressbook + strategy: + type: RollingUpdate + rollingUpdate: + maxSurge: 1 + maxUnavailable: 1 + template: + metadata: + labels: + app: addressbook + deployment: $deployment + spec: + imagePullSecrets: + - name: dockerhub + containers: + - name: addressbook + image: $img + readinessProbe: + httpGet: + path: /ready + port: 5001 + env: + - name: FLASK_ENV + value: "production" From 7c94d0129681c5350d92e824a1b5aab6045be0a8 Mon Sep 17 00:00:00 2001 From: AutomationGeek-dev <81010228+AutomationGeek-dev@users.noreply.github.com> Date: Mon, 22 Mar 2021 14:44:43 -0600 Subject: [PATCH 25/43] Create apply.sh --- apply.sh | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 apply.sh diff --git a/apply.sh b/apply.sh new file mode 100644 index 0000000..8b07b76 --- /dev/null +++ b/apply.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash +# apply a kubernetes manifest and wait for rollout +# +# usage: +# apply.sh manifest/DEPLOYMENT_FILE.yml DEPLOYMENT_NAME REPLICAS IMAGE +# +# example: +# apply.sh manifest/deployment.yml addressbook-stable 3 $DOCKER_USERNAME/semaphore-demo-cicd-kubernetes:latest +# + +set -e + +export manifest=$1 +export deployment=$2 +export replicas=$3 +export img=$4 + +apply_tmp=$(mktemp) +cat $manifest | envsubst | tee $apply_tmp +kubectl apply -f $apply_tmp +kubectl rollout status -f $apply_tmp --timeout=120s +rm -f $apply_tmp From 18ed143d2451a5e4a9b788615c845b361f09b3d9 Mon Sep 17 00:00:00 2001 From: AutomationGeek-dev <81010228+AutomationGeek-dev@users.noreply.github.com> Date: Mon, 22 Mar 2021 14:45:30 -0600 Subject: [PATCH 26/43] Update deployment.yml --- manifests/deployment.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/manifests/deployment.yml b/manifests/deployment.yml index eff7d23..7a76d73 100644 --- a/manifests/deployment.yml +++ b/manifests/deployment.yml @@ -6,7 +6,7 @@ spec: replicas: $replicas selector: matchLabels: - app: addressbook + app: helloworld strategy: type: RollingUpdate rollingUpdate: @@ -15,13 +15,13 @@ spec: template: metadata: labels: - app: addressbook + app: helloworld deployment: $deployment spec: imagePullSecrets: - name: dockerhub containers: - - name: addressbook + - name: helloworld image: $img readinessProbe: httpGet: From 40ad36467a482a6a72f4a2061d9f87f4c9bacf4a Mon Sep 17 00:00:00 2001 From: AutomationGeek-dev Date: Mon, 22 Mar 2021 20:50:27 +0000 Subject: [PATCH 27/43] Update Semaphore configuration --- .semaphore/pipeline_2.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.semaphore/pipeline_2.yml b/.semaphore/pipeline_2.yml index af3fba8..2502acf 100644 --- a/.semaphore/pipeline_2.yml +++ b/.semaphore/pipeline_2.yml @@ -31,3 +31,7 @@ blocks: - name: Canary Deployment commands: - kubectl apply -f manifests/service.yml + - ./apply.sh manifests/deployment.yml helloworld-canary 1 \ + - '$DOCKER_USERNAME/helloworld:$SEMAPHORE_WORKFLOW_ID' + - if kubectl get deployment helloworld-stable; then \ + - kubectl scale --replicas=2 deployment/helloworld-stable; fi From 59d391ea4ec7e29ab04085e32c88f9f6d6f77beb Mon Sep 17 00:00:00 2001 From: AutomationGeek-dev Date: Mon, 22 Mar 2021 20:59:54 +0000 Subject: [PATCH 28/43] Update Semaphore configuration --- .semaphore/pipeline_2.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.semaphore/pipeline_2.yml b/.semaphore/pipeline_2.yml index 2502acf..c77e747 100644 --- a/.semaphore/pipeline_2.yml +++ b/.semaphore/pipeline_2.yml @@ -30,6 +30,8 @@ blocks: jobs: - name: Canary Deployment commands: + - chmod 600 ./apply.sh + - chmod a+x ./apply.sh - kubectl apply -f manifests/service.yml - ./apply.sh manifests/deployment.yml helloworld-canary 1 \ - '$DOCKER_USERNAME/helloworld:$SEMAPHORE_WORKFLOW_ID' From 8c0191d596657c4a9fadb5dcddd43ae4fb2f8695 Mon Sep 17 00:00:00 2001 From: AutomationGeek-dev Date: Mon, 22 Mar 2021 21:07:08 +0000 Subject: [PATCH 29/43] Update Semaphore configuration --- .semaphore/pipeline_2.yml | 2 +- .semaphore/pipeline_3.yml | 13 +++++++++++++ .semaphore/pipeline_4.yml | 13 +++++++++++++ .semaphore/semaphore.yml | 6 +++++- 4 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 .semaphore/pipeline_3.yml create mode 100644 .semaphore/pipeline_4.yml diff --git a/.semaphore/pipeline_2.yml b/.semaphore/pipeline_2.yml index c77e747..9e6a5ab 100644 --- a/.semaphore/pipeline_2.yml +++ b/.semaphore/pipeline_2.yml @@ -36,4 +36,4 @@ blocks: - ./apply.sh manifests/deployment.yml helloworld-canary 1 \ - '$DOCKER_USERNAME/helloworld:$SEMAPHORE_WORKFLOW_ID' - if kubectl get deployment helloworld-stable; then \ - - kubectl scale --replicas=2 deployment/helloworld-stable; fi + - kubectl scale --replicas=1 deployment/helloworld-stable; fi diff --git a/.semaphore/pipeline_3.yml b/.semaphore/pipeline_3.yml new file mode 100644 index 0000000..7fcf8c0 --- /dev/null +++ b/.semaphore/pipeline_3.yml @@ -0,0 +1,13 @@ +version: v1.0 +name: Pipeline 3 +agent: + machine: + type: e1-standard-2 + os_image: ubuntu1804 +blocks: + - name: 'Block #1' + task: + jobs: + - name: 'Job #1' + commands: + - echo "job 1" diff --git a/.semaphore/pipeline_4.yml b/.semaphore/pipeline_4.yml new file mode 100644 index 0000000..bf9d449 --- /dev/null +++ b/.semaphore/pipeline_4.yml @@ -0,0 +1,13 @@ +version: v1.0 +name: Pipeline 4 +agent: + machine: + type: e1-standard-2 + os_image: ubuntu1804 +blocks: + - name: 'Block #1' + task: + jobs: + - name: 'Job #1' + commands: + - echo "job 1" diff --git a/.semaphore/semaphore.yml b/.semaphore/semaphore.yml index 29499a1..461b6a0 100644 --- a/.semaphore/semaphore.yml +++ b/.semaphore/semaphore.yml @@ -22,7 +22,11 @@ blocks: secrets: - name: Docker Secrets promotions: - - name: Promotion 1 + - name: Canary pipeline_file: pipeline_2.yml auto_promote: when: (branch = 'setup-semaphore' OR tag =~ '^hotfix*') AND result = 'passed' + - name: Stable + pipeline_file: pipeline_3.yml + - name: Rollback + pipeline_file: pipeline_4.yml From fbe2c1e5a0ee658fdb5c8e3a0fc5bd6dcb319131 Mon Sep 17 00:00:00 2001 From: AutomationGeek-dev <81010228+AutomationGeek-dev@users.noreply.github.com> Date: Mon, 22 Mar 2021 15:15:12 -0600 Subject: [PATCH 30/43] Update docker-compose.yml --- docker-compose.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/docker-compose.yml b/docker-compose.yml index 1abfae9..ce1a583 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,6 +3,7 @@ version: '3.7' services: hello-world: image: hello-world + container_name: hello-world-container build: context: . dockerfile: Dockerfile From fd686da7195cb2ff04f728f198ee77e3a34f8bba Mon Sep 17 00:00:00 2001 From: AutomationGeek-dev <81010228+AutomationGeek-dev@users.noreply.github.com> Date: Mon, 22 Mar 2021 15:15:49 -0600 Subject: [PATCH 31/43] Update deployment.yml --- manifests/deployment.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/deployment.yml b/manifests/deployment.yml index 7a76d73..cd567fc 100644 --- a/manifests/deployment.yml +++ b/manifests/deployment.yml @@ -21,7 +21,7 @@ spec: imagePullSecrets: - name: dockerhub containers: - - name: helloworld + - name: hello-world-containerhelloworld image: $img readinessProbe: httpGet: From 4872d4285e5c4e7e58d8d80cc2d519377de05bb5 Mon Sep 17 00:00:00 2001 From: AutomationGeek-dev <81010228+AutomationGeek-dev@users.noreply.github.com> Date: Mon, 22 Mar 2021 15:15:58 -0600 Subject: [PATCH 32/43] Update deployment.yml --- manifests/deployment.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/deployment.yml b/manifests/deployment.yml index cd567fc..5d3ad04 100644 --- a/manifests/deployment.yml +++ b/manifests/deployment.yml @@ -21,7 +21,7 @@ spec: imagePullSecrets: - name: dockerhub containers: - - name: hello-world-containerhelloworld + - name: hello-world-container image: $img readinessProbe: httpGet: From bd2d248ab38a1308f2e63dc36fb23228bae895e7 Mon Sep 17 00:00:00 2001 From: AutomationGeek-dev Date: Mon, 22 Mar 2021 21:30:42 +0000 Subject: [PATCH 33/43] Update Semaphore configuration --- .semaphore/pipeline_2.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.semaphore/pipeline_2.yml b/.semaphore/pipeline_2.yml index 9e6a5ab..6cc2836 100644 --- a/.semaphore/pipeline_2.yml +++ b/.semaphore/pipeline_2.yml @@ -34,6 +34,6 @@ blocks: - chmod a+x ./apply.sh - kubectl apply -f manifests/service.yml - ./apply.sh manifests/deployment.yml helloworld-canary 1 \ - - '$DOCKER_USERNAME/helloworld:$SEMAPHORE_WORKFLOW_ID' + - '--img=$DOCKER_USERNAME/helloworld:$SEMAPHORE_WORKFLOW_ID' - if kubectl get deployment helloworld-stable; then \ - kubectl scale --replicas=1 deployment/helloworld-stable; fi From fa3c6bfa0b418b7d939e0e63864216ab57fc5600 Mon Sep 17 00:00:00 2001 From: AutomationGeek-dev <81010228+AutomationGeek-dev@users.noreply.github.com> Date: Mon, 22 Mar 2021 15:38:54 -0600 Subject: [PATCH 34/43] Update deployment.yml --- manifests/deployment.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/deployment.yml b/manifests/deployment.yml index 5d3ad04..66128ea 100644 --- a/manifests/deployment.yml +++ b/manifests/deployment.yml @@ -22,7 +22,7 @@ spec: - name: dockerhub containers: - name: hello-world-container - image: $img + image: $DOCKER_USERNAME/helloworld:$SEMAPHORE_WORKFLOW_ID readinessProbe: httpGet: path: /ready From b62b3544db4bfe423d06603913c659381a92edf8 Mon Sep 17 00:00:00 2001 From: AutomationGeek-dev <81010228+AutomationGeek-dev@users.noreply.github.com> Date: Mon, 22 Mar 2021 15:48:34 -0600 Subject: [PATCH 35/43] Update deployment.yml --- manifests/deployment.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/deployment.yml b/manifests/deployment.yml index 66128ea..ffe22f8 100644 --- a/manifests/deployment.yml +++ b/manifests/deployment.yml @@ -26,7 +26,7 @@ spec: readinessProbe: httpGet: path: /ready - port: 5001 + port: 5000 env: - name: FLASK_ENV value: "production" From 3d8ae52a5febd3c71eafc983bb116a8261158483 Mon Sep 17 00:00:00 2001 From: AutomationGeek-dev <81010228+AutomationGeek-dev@users.noreply.github.com> Date: Mon, 22 Mar 2021 16:04:26 -0600 Subject: [PATCH 36/43] Update service.yml --- manifests/service.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/service.yml b/manifests/service.yml index 42a0d09..1770511 100644 --- a/manifests/service.yml +++ b/manifests/service.yml @@ -8,4 +8,4 @@ spec: type: LoadBalancer ports: - port: 80 - targetPort: 5001 + targetPort: 5000 From 3b6b43e6dfa5db30bfd4358ff0dc014ef5306c43 Mon Sep 17 00:00:00 2001 From: AutomationGeek-dev <81010228+AutomationGeek-dev@users.noreply.github.com> Date: Mon, 22 Mar 2021 16:10:48 -0600 Subject: [PATCH 37/43] Update deployment.yml --- manifests/deployment.yml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/manifests/deployment.yml b/manifests/deployment.yml index ffe22f8..d2d8497 100644 --- a/manifests/deployment.yml +++ b/manifests/deployment.yml @@ -23,10 +23,3 @@ spec: containers: - name: hello-world-container image: $DOCKER_USERNAME/helloworld:$SEMAPHORE_WORKFLOW_ID - readinessProbe: - httpGet: - path: /ready - port: 5000 - env: - - name: FLASK_ENV - value: "production" From 8018026c947c9775b37e2e7c9fcc007c2d215c7a Mon Sep 17 00:00:00 2001 From: AutomationGeek-dev Date: Mon, 22 Mar 2021 22:14:02 +0000 Subject: [PATCH 38/43] Update Semaphore configuration --- .semaphore/pipeline_2.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.semaphore/pipeline_2.yml b/.semaphore/pipeline_2.yml index 6cc2836..9e6a5ab 100644 --- a/.semaphore/pipeline_2.yml +++ b/.semaphore/pipeline_2.yml @@ -34,6 +34,6 @@ blocks: - chmod a+x ./apply.sh - kubectl apply -f manifests/service.yml - ./apply.sh manifests/deployment.yml helloworld-canary 1 \ - - '--img=$DOCKER_USERNAME/helloworld:$SEMAPHORE_WORKFLOW_ID' + - '$DOCKER_USERNAME/helloworld:$SEMAPHORE_WORKFLOW_ID' - if kubectl get deployment helloworld-stable; then \ - kubectl scale --replicas=1 deployment/helloworld-stable; fi From 49958f308cf88f56e00f3fdecaba4c14cd82965b Mon Sep 17 00:00:00 2001 From: AutomationGeek-dev Date: Mon, 22 Mar 2021 22:18:21 +0000 Subject: [PATCH 39/43] Update Semaphore configuration --- .semaphore/pipeline_2.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.semaphore/pipeline_2.yml b/.semaphore/pipeline_2.yml index 9e6a5ab..78c8275 100644 --- a/.semaphore/pipeline_2.yml +++ b/.semaphore/pipeline_2.yml @@ -34,6 +34,5 @@ blocks: - chmod a+x ./apply.sh - kubectl apply -f manifests/service.yml - ./apply.sh manifests/deployment.yml helloworld-canary 1 \ - - '$DOCKER_USERNAME/helloworld:$SEMAPHORE_WORKFLOW_ID' - if kubectl get deployment helloworld-stable; then \ - kubectl scale --replicas=1 deployment/helloworld-stable; fi From f340210fd987daddc78d51cd8c634d7346d8d730 Mon Sep 17 00:00:00 2001 From: AutomationGeek-dev Date: Mon, 22 Mar 2021 22:20:56 +0000 Subject: [PATCH 40/43] Update Semaphore configuration --- .semaphore/pipeline_2.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.semaphore/pipeline_2.yml b/.semaphore/pipeline_2.yml index 78c8275..af52814 100644 --- a/.semaphore/pipeline_2.yml +++ b/.semaphore/pipeline_2.yml @@ -33,6 +33,6 @@ blocks: - chmod 600 ./apply.sh - chmod a+x ./apply.sh - kubectl apply -f manifests/service.yml - - ./apply.sh manifests/deployment.yml helloworld-canary 1 \ + - './apply.sh manifests/deployment.yml helloworld-canary 1 ' - if kubectl get deployment helloworld-stable; then \ - kubectl scale --replicas=1 deployment/helloworld-stable; fi From b5af1fe5f1ef982d291a07ade7bc2611331d0139 Mon Sep 17 00:00:00 2001 From: AutomationGeek-dev Date: Mon, 22 Mar 2021 22:25:02 +0000 Subject: [PATCH 41/43] Update Semaphore configuration --- .semaphore/pipeline_2.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.semaphore/pipeline_2.yml b/.semaphore/pipeline_2.yml index af52814..8f611de 100644 --- a/.semaphore/pipeline_2.yml +++ b/.semaphore/pipeline_2.yml @@ -34,5 +34,5 @@ blocks: - chmod a+x ./apply.sh - kubectl apply -f manifests/service.yml - './apply.sh manifests/deployment.yml helloworld-canary 1 ' - - if kubectl get deployment helloworld-stable; then \ - - kubectl scale --replicas=1 deployment/helloworld-stable; fi + - 'if kubectl get deployment helloworld-stable; then \ ' + - ' kubectl scale --replicas=1 deployment/helloworld-stable; fi' From 1b671e419c07e3e99b65bfc8ff995da61db9d30d Mon Sep 17 00:00:00 2001 From: AutomationGeek-dev Date: Mon, 22 Mar 2021 22:25:50 +0000 Subject: [PATCH 42/43] Update Semaphore configuration --- .semaphore/pipeline_2.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.semaphore/pipeline_2.yml b/.semaphore/pipeline_2.yml index 8f611de..2d21b51 100644 --- a/.semaphore/pipeline_2.yml +++ b/.semaphore/pipeline_2.yml @@ -34,5 +34,4 @@ blocks: - chmod a+x ./apply.sh - kubectl apply -f manifests/service.yml - './apply.sh manifests/deployment.yml helloworld-canary 1 ' - - 'if kubectl get deployment helloworld-stable; then \ ' - - ' kubectl scale --replicas=1 deployment/helloworld-stable; fi' + - if kubectl get deployment helloworld-stable; then kubectl scale --replicas=1 deployment/helloworld-stable; fi From 2b303655efb1586812cac5e0da963c610b871977 Mon Sep 17 00:00:00 2001 From: AutomationGeek-dev <81010228+AutomationGeek-dev@users.noreply.github.com> Date: Tue, 23 Mar 2021 07:26:22 -0600 Subject: [PATCH 43/43] Update service.yml --- manifests/service.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/manifests/service.yml b/manifests/service.yml index 1770511..496c05e 100644 --- a/manifests/service.yml +++ b/manifests/service.yml @@ -5,7 +5,6 @@ metadata: spec: selector: app: helloworld - type: LoadBalancer ports: - port: 80 targetPort: 5000