From 701b2af387554fbf5d291ab178b17d1071cd2d1f Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Tue, 22 Jan 2019 00:27:41 -0800 Subject: [PATCH 01/38] Initial implementation --- .dockerignore | 6 +++ .editorconfig | 8 ++++ .gitignore | 3 ++ Dockerfile | 27 +++++++++++ Makefile | 12 +++++ codefresh/build.yaml | 32 +++++++++++++ codefresh/deploy.yaml | 72 ++++++++++++++++++++++++++++ codefresh/release.yaml | 0 dashboard.html | 42 +++++++++++++++++ deploy/helmfile.yaml | 3 ++ deploy/releases/blue.yaml | 99 +++++++++++++++++++++++++++++++++++++++ index.html | 16 +++++++ main.go | 49 +++++++++++++++++++ 13 files changed, 369 insertions(+) create mode 100644 .dockerignore create mode 100644 .editorconfig create mode 100644 .gitignore create mode 100644 Dockerfile create mode 100644 Makefile create mode 100644 codefresh/build.yaml create mode 100644 codefresh/deploy.yaml create mode 100644 codefresh/release.yaml create mode 100644 dashboard.html create mode 100644 deploy/helmfile.yaml create mode 100644 deploy/releases/blue.yaml create mode 100644 index.html create mode 100644 main.go diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..f2d4151 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,6 @@ +.git +.idea +*.iml +.editorconfig +build-harness +.build-harness diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..7928ca4 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,8 @@ +# Override for Makefile +[{Makefile, makefile, GNUmakefile}] +indent_style = tab +indent_size = 4 + +[Makefile.*] +indent_style = tab +indent_size = 4 \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..354b2ed --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +release/* +.build-harness +build-harness/ \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..2b6afdf --- /dev/null +++ b/Dockerfile @@ -0,0 +1,27 @@ +FROM golang:alpine3.8 AS builder + +# Copy source into builder +ADD . /src + +# Build the app +RUN cd /src && \ + go build -o example-app + +# Build the final image +FROM alpine:3.8 as final + +# Expose port of the app +EXPOSE 8080 + +# Set the runtime working directory +WORKDIR /app + +# Copy the helmfile deployment configuration +COPY deploy/ /deploy/ +COPY *.html /app/ + +# Install the app +COPY --from=builder /src/example-app /app/ + +# Define the entrypoint +ENTRYPOINT ["./example-app"] \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..7e753ed --- /dev/null +++ b/Makefile @@ -0,0 +1,12 @@ +DOCKER_IMAGE_NAME ?= example-app +SHELL = /bin/bash + +PATH:=$(PATH):$(GOPATH)/bin + +-include $(shell curl -sSL -o .build-harness "https://git.io/build-harness"; echo .build-harness) + +build: go/build + @exit 0 + +run: + docker run -it -p 8080:8080 --rm $(DOCKER_IMAGE_NAME) diff --git a/codefresh/build.yaml b/codefresh/build.yaml new file mode 100644 index 0000000..f2bb7d5 --- /dev/null +++ b/codefresh/build.yaml @@ -0,0 +1,32 @@ +version: '1.0' + +stages: + - Prepare + - Build + - Push + +steps: + main_clone: + title: "Clone repository" + type: git-clone + stage: Prepare + description: "Initialize" + repo: ${{CF_REPO_OWNER}}/${{CF_REPO_NAME}} + git: CF-default + revision: ${{CF_REVISION}} + + build_image: + title: Build image + stage: Build + type: build + description: Build image + image_name: ${{CF_REPO_NAME}} + dockerfile: Dockerfile + + push_image_commit: + title: Push image with commit tag + stage: Push + type: push + candidate: ${{build_image}} + tags: + - "${{CF_REVISION}}" \ No newline at end of file diff --git a/codefresh/deploy.yaml b/codefresh/deploy.yaml new file mode 100644 index 0000000..3f69033 --- /dev/null +++ b/codefresh/deploy.yaml @@ -0,0 +1,72 @@ +version: '1.0' + +stages: + - Prepare + - Deploy + +steps: + main_clone: + title: "Create Context" + stage: Prepare + image: alpine + commands: + - cf_export NAMESPACE=atlantis + - cf_export ATLANTIS_IMAGE_NAME=${{CF_DOCKER_REPO_URL}}/${{CF_REPO_NAME}} + - cf_export ATLANTIS_IMAGE_TAG=${{CF_RELEASE_TAG}} + + set_github_deployment_status_to_pending: + title: Set GitHub deployment status to "pending" + stage: Deploy + image: cloudposse/github-status-updater + environment: + - GITHUB_ACTION=update_state + - GITHUB_TOKEN=${{GITHUB_TOKEN}} + - GITHUB_OWNER=${{CF_REPO_OWNER}} + - GITHUB_REPO=${{CF_REPO_NAME}} + - GITHUB_REF=${{CF_REVISION}} + - GITHUB_CONTEXT=${{STAGE}}-environment + - GITHUB_STATE=pending + - GITHUB_DESCRIPTION=Deploying changes to ${{NAMESPACE}} namespace + - GITHUB_TARGET_URL=${{ATLANTIS_ATLANTIS_URL}} + when: + condition: + all: + githubNotificationsEnabled: "'${{GITHUB_NOTIFICATIONS_ENABLED}}' == 'true'" + + deploy_helmfile: + title: "Deploy with helmfile" + stage: "Deploy" + image: "${{CF_DOCKER_REPO_URL}}/${{CF_REPO_NAME}}:${{CF_REVISION}}" + working_directory: /conf/ + commands: + # Announce the release version + - "echo 'Preparing to deploy version ${{CF_RELEASE_TAG}}'" + # Fetch the build-harness + - "curl -sSL -o Makefile https://git.io/build-harness" + # Initialize the build-harness + - "make init" + # Install or upgrade tiller + - "make helm/toolbox/upsert" + # Add kiam annotation + - "kubectl annotate namespace atlantis 'iam.amazonaws.com/permitted=${{ATLANTIS_IAM_ROLE}}' --overwrite" + # Deploy chart to cluster using helmfile + - "helmfile --namespace ${{NAMESPACE}} --selector name=${{NAMESPACE}} sync" + + set_github_deployment_status_to_success: + title: Set GitHub deployment status to "success" + stage: "Deploy" + image: cloudposse/github-status-updater + environment: + - GITHUB_ACTION=update_state + - GITHUB_TOKEN=${{GITHUB_TOKEN}} + - GITHUB_OWNER=${{CF_REPO_OWNER}} + - GITHUB_REPO=${{CF_REPO_NAME}} + - GITHUB_REF=${{CF_REVISION}} + - GITHUB_CONTEXT=${{STAGE}}-environment + - GITHUB_STATE=success + - GITHUB_DESCRIPTION=Deployed to ${{NAMESPACE}} namespace + - GITHUB_TARGET_URL=${{ATLANTIS_ATLANTIS_URL}} + when: + condition: + all: + githubNotificationsEnabled: "'${{GITHUB_NOTIFICATIONS_ENABLED}}' == 'true'" \ No newline at end of file diff --git a/codefresh/release.yaml b/codefresh/release.yaml new file mode 100644 index 0000000..e69de29 diff --git a/dashboard.html b/dashboard.html new file mode 100644 index 0000000..8378337 --- /dev/null +++ b/dashboard.html @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/deploy/helmfile.yaml b/deploy/helmfile.yaml new file mode 100644 index 0000000..f9d995c --- /dev/null +++ b/deploy/helmfile.yaml @@ -0,0 +1,3 @@ +# Ordered list of releases. +helmfiles: + - "releases/blue.yaml" \ No newline at end of file diff --git a/deploy/releases/blue.yaml b/deploy/releases/blue.yaml new file mode 100644 index 0000000..535308f --- /dev/null +++ b/deploy/releases/blue.yaml @@ -0,0 +1,99 @@ +repositories: +# Cloud Posse incubator repo of helm charts +- name: "cloudposse-incubator" + url: "https://charts.cloudposse.com/incubator/" + +releases: + +####################################################################################### +## Atlantis ## +####################################################################################### + +# +# References: +# - https://github.com/cloudposse/atlantis/tree/master/helm/atlantis +# - https://github.com/cloudposse/charts/blob/master/incubator/monochart +# +- name: "blue-example" + namespace: "example" + labels: + color: "blue" + chart: "cloudposse-incubator/monochart" + version: "0.7.0" + wait: true + force: true + recreatePods: false + values: + - fullnameOverride: atlantis + image: + repository: '{{ env "IMAGE_NAME" | default "cloudposse/example-app" }}' + tag: '{{ env "IMAGE_TAG" | default "0.1.0" }}' + pullPolicy: Always + pullSecrets: + - 'atlantis-pull-secret-dockercfg' + + configMaps: + default: + enabled: true + env: + # Color to deploy + COLOR: "cyan" + + service: + enabled: true + type: ClusterIP + ports: + default: + internal: 8080 + external: 80 + + ingress: + default: + enabled: true + labels: + dns: "route53" + annotations: + kubernetes.io/ingress.class: nginx + kubernetes.io/tls-acme: "true" + external-dns.alpha.kubernetes.io/target: '{{ requiredEnv "NGINX_INGRESS_HOSTNAME" }}' + external-dns.alpha.kubernetes.io/ttl: "60" + hosts: + ### Required: ATLANTIS_HOSTNAME; + '{{ env "ATLANTIS_HOSTNAME" }}': / + tls: + ### Optional: ATLANTIS_TLS_SECRET_NAME; + - secretName: '{{ env "ATLANTIS_TLS_SECRET_NAME" | default "atlantis-server-tls" }}' + hosts: + ### Required: ATLANTIS_HOSTNAME; + - '{{ env "ATLANTIS_HOSTNAME" }}' + + probes: + livenessProbe: + httpGet: + path: /healthz + port: default + scheme: HTTP + periodSeconds: 60 + initialDelaySeconds: 5 + timeoutSeconds: 5 + successThreshold: 1 + failureThreshold: 5 + scheme: HTTP + readinessProbe: + httpGet: + path: /healthz + port: default + scheme: HTTP + periodSeconds: 60 + initialDelaySeconds: 10 + timeoutSeconds: 5 + successThreshold: 1 + failureThreshold: 5 + + resources: + requests: + memory: 1Gi + cpu: 100m + limits: + memory: 1Gi + cpu: 100m \ No newline at end of file diff --git a/index.html b/index.html new file mode 100644 index 0000000..efc3853 --- /dev/null +++ b/index.html @@ -0,0 +1,16 @@ + + + + + + %v + \ No newline at end of file diff --git a/main.go b/main.go new file mode 100644 index 0000000..4d9171c --- /dev/null +++ b/main.go @@ -0,0 +1,49 @@ +package main + +import ( + "fmt" + "io/ioutil" + "net/http" + "os" +) + +func main() { + c := os.Getenv("COLOR") + if len(c) == 0 { + c = "cyan" + } + count := 0 + + // Healthcheck endpoint + http.HandleFunc("/healthz", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprintf(w, "OK") + fmt.Printf("GET %s\n", r.URL.Path) + }) + + // Take one for the team + http.HandleFunc("/die", func(w http.ResponseWriter, r *http.Request) { + fmt.Printf("Goodbye\n") + die() + }) + + // Dashboard + dashboard, _ := ioutil.ReadFile("dashboard.html") + http.HandleFunc("/dashboard", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprintf(w, string(dashboard)) + fmt.Printf("GET %s\n", r.URL.Path) + }) + + // Default + index, _ := ioutil.ReadFile("index.html") + http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + count += 1 + fmt.Fprintf(w, string(index), c, count) + fmt.Printf("GET %s\n", r.URL.Path) + }) + + http.ListenAndServe(":8080", nil) +} + +func die() { + os.Exit(3) +} From 7f09af917166e1b2585cdf94a777f745b36e8bd7 Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Tue, 22 Jan 2019 00:57:29 -0800 Subject: [PATCH 02/38] Update pipelines --- codefresh/deploy.yaml | 6 ++---- codefresh/release.yaml | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 4 deletions(-) diff --git a/codefresh/deploy.yaml b/codefresh/deploy.yaml index 3f69033..0f65fc4 100644 --- a/codefresh/deploy.yaml +++ b/codefresh/deploy.yaml @@ -37,7 +37,7 @@ steps: title: "Deploy with helmfile" stage: "Deploy" image: "${{CF_DOCKER_REPO_URL}}/${{CF_REPO_NAME}}:${{CF_REVISION}}" - working_directory: /conf/ + working_directory: /deploy/ commands: # Announce the release version - "echo 'Preparing to deploy version ${{CF_RELEASE_TAG}}'" @@ -47,10 +47,8 @@ steps: - "make init" # Install or upgrade tiller - "make helm/toolbox/upsert" - # Add kiam annotation - - "kubectl annotate namespace atlantis 'iam.amazonaws.com/permitted=${{ATLANTIS_IAM_ROLE}}' --overwrite" # Deploy chart to cluster using helmfile - - "helmfile --namespace ${{NAMESPACE}} --selector name=${{NAMESPACE}} sync" + - "helmfile --namespace ${{NAMESPACE}} --selector color=${{NAMESPACE}} sync" set_github_deployment_status_to_success: title: Set GitHub deployment status to "success" diff --git a/codefresh/release.yaml b/codefresh/release.yaml index e69de29..07af5a5 100644 --- a/codefresh/release.yaml +++ b/codefresh/release.yaml @@ -0,0 +1,42 @@ +version: '1.0' + +stages: + - Prepare + - Promote + - Deploy + +steps: + main_clone: + title: "Create Context" + stage: "Prepare" + image: alpine + commands: + # Extract the postfix of a semver (e.g. 0.0.0-stage => stage) + - cf_export STAGE=$(echo ${{CF_RELEASE_TAG}} | sed -E 's/^[^-]+-?//') + + pull_image_sha: + title: Pull image with commit sha + stage: "Promote" + image: "${{CF_DOCKER_REPO_URL}}/${{CF_REPO_NAME}}:${{CF_REVISION}}" + commands: + - "true" + + push_image_tag: + title: Push image with release tag + stage: "Promote" + type: push + image_name: ${{CF_REPO_NAME}} + candidate: "${{CF_DOCKER_REPO_URL}}/${{CF_REPO_NAME}}:${{CF_REVISION}}" + tags: + - "${{CF_RELEASE_TAG}}" + + deploy: + title: Deploy Release + stage: "Deploy" + image: 'codefresh/cli:latest' + commands: + - codefresh run ${{CF_REPO_OWNER}}/${{CF_REPO_NAME}}/deploy-${{STAGE}} -d -b=${{CF_BRANCH}} -v CF_RELEASE_TAG=${{CF_RELEASE_TAG}} -v CF_PRERELEASE_FLAG=${{CF_PRERELEASE_FLAG}} -v STAGE=${{STAGE}} + when: + condition: + all: + stageDefined: "'${{STAGE}}' != ''" \ No newline at end of file From dc17039425f5b6e6dbac0548cd444ce2b5ef574d Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Tue, 22 Jan 2019 01:11:42 -0800 Subject: [PATCH 03/38] Fix deps --- Dockerfile | 2 ++ codefresh/deploy.yaml | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2b6afdf..42f10ad 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,6 +10,8 @@ RUN cd /src && \ # Build the final image FROM alpine:3.8 as final +RUN apk add --update curl make + # Expose port of the app EXPOSE 8080 diff --git a/codefresh/deploy.yaml b/codefresh/deploy.yaml index 0f65fc4..727a613 100644 --- a/codefresh/deploy.yaml +++ b/codefresh/deploy.yaml @@ -10,9 +10,9 @@ steps: stage: Prepare image: alpine commands: - - cf_export NAMESPACE=atlantis - - cf_export ATLANTIS_IMAGE_NAME=${{CF_DOCKER_REPO_URL}}/${{CF_REPO_NAME}} - - cf_export ATLANTIS_IMAGE_TAG=${{CF_RELEASE_TAG}} + - cf_export NAMESPACE=${{STAGE}} + - cf_export IMAGE_NAME=${{CF_DOCKER_REPO_URL}}/${{CF_REPO_NAME}} + - cf_export IMAGE_TAG=${{CF_RELEASE_TAG}} set_github_deployment_status_to_pending: title: Set GitHub deployment status to "pending" From 89f5f322de6264b8c41f23c78a29a9a805799efc Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Tue, 22 Jan 2019 01:15:46 -0800 Subject: [PATCH 04/38] add bash dep --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 42f10ad..bd99b89 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,7 +10,7 @@ RUN cd /src && \ # Build the final image FROM alpine:3.8 as final -RUN apk add --update curl make +RUN apk add --update curl make bash # Expose port of the app EXPOSE 8080 From 8cd0373da55a17f27dfce0afae3c9321db553ddc Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Tue, 22 Jan 2019 01:28:43 -0800 Subject: [PATCH 05/38] remove deps --- Dockerfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index bd99b89..07da9e5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,7 +10,9 @@ RUN cd /src && \ # Build the final image FROM alpine:3.8 as final -RUN apk add --update curl make bash +# Install the cloudposse alpine repository +ADD https://apk.cloudposse.com/ops@cloudposse.com.rsa.pub /etc/apk/keys/ +RUN echo "@cloudposse https://apk.cloudposse.com/3.8/vendor" >> /etc/apk/repositories # Expose port of the app EXPOSE 8080 From 85c11ee30e274475c3ae7492474a082233e809a2 Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Tue, 22 Jan 2019 21:41:42 -0800 Subject: [PATCH 06/38] click to crash --- codefresh/deploy.yaml | 2 +- deploy/releases/blue.yaml | 5 ++--- main.go | 10 ++++++---- public/boom.html | 18 ++++++++++++++++++ dashboard.html => public/dashboard.html | 0 index.html => public/index.html | 8 ++++++-- 6 files changed, 33 insertions(+), 10 deletions(-) create mode 100644 public/boom.html rename dashboard.html => public/dashboard.html (100%) rename index.html => public/index.html (67%) diff --git a/codefresh/deploy.yaml b/codefresh/deploy.yaml index 727a613..eb2137d 100644 --- a/codefresh/deploy.yaml +++ b/codefresh/deploy.yaml @@ -48,7 +48,7 @@ steps: # Install or upgrade tiller - "make helm/toolbox/upsert" # Deploy chart to cluster using helmfile - - "helmfile --namespace ${{NAMESPACE}} --selector color=${{NAMESPACE}} sync" + - "helmfile --namespace ${{NAMESPACE}} --selector color=blue sync" set_github_deployment_status_to_success: title: Set GitHub deployment status to "success" diff --git a/deploy/releases/blue.yaml b/deploy/releases/blue.yaml index 535308f..eadb468 100644 --- a/deploy/releases/blue.yaml +++ b/deploy/releases/blue.yaml @@ -15,7 +15,6 @@ releases: # - https://github.com/cloudposse/charts/blob/master/incubator/monochart # - name: "blue-example" - namespace: "example" labels: color: "blue" chart: "cloudposse-incubator/monochart" @@ -92,8 +91,8 @@ releases: resources: requests: - memory: 1Gi + memory: 10Mi cpu: 100m limits: - memory: 1Gi + memory: 10Mi cpu: 100m \ No newline at end of file diff --git a/main.go b/main.go index 4d9171c..edca8b4 100644 --- a/main.go +++ b/main.go @@ -21,20 +21,22 @@ func main() { }) // Take one for the team - http.HandleFunc("/die", func(w http.ResponseWriter, r *http.Request) { + boom, _ := ioutil.ReadFile("public/boom.html") + http.HandleFunc("/boom", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprintf(w, string(boom)) fmt.Printf("Goodbye\n") - die() + //die() }) // Dashboard - dashboard, _ := ioutil.ReadFile("dashboard.html") + dashboard, _ := ioutil.ReadFile("public/dashboard.html") http.HandleFunc("/dashboard", func(w http.ResponseWriter, r *http.Request) { fmt.Fprintf(w, string(dashboard)) fmt.Printf("GET %s\n", r.URL.Path) }) // Default - index, _ := ioutil.ReadFile("index.html") + index, _ := ioutil.ReadFile("public/index.html") http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { count += 1 fmt.Fprintf(w, string(index), c, count) diff --git a/public/boom.html b/public/boom.html new file mode 100644 index 0000000..36fb1c8 --- /dev/null +++ b/public/boom.html @@ -0,0 +1,18 @@ + + + + + + BOOM!!! + diff --git a/dashboard.html b/public/dashboard.html similarity index 100% rename from dashboard.html rename to public/dashboard.html diff --git a/index.html b/public/index.html similarity index 67% rename from index.html rename to public/index.html index efc3853..a83c50c 100644 --- a/index.html +++ b/public/index.html @@ -1,8 +1,9 @@ - + %v - \ No newline at end of file + From 46bfca726e2a9b6834da9fcff601b8883f0ef745 Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Tue, 22 Jan 2019 21:47:31 -0800 Subject: [PATCH 07/38] copy public/ --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 07da9e5..5cb5b4b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -22,10 +22,10 @@ WORKDIR /app # Copy the helmfile deployment configuration COPY deploy/ /deploy/ -COPY *.html /app/ +COPY public/ /app/public/ # Install the app COPY --from=builder /src/example-app /app/ # Define the entrypoint -ENTRYPOINT ["./example-app"] \ No newline at end of file +ENTRYPOINT ["./example-app"] From 35f28289c99a62d872cdf35870c8143460641d2a Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Tue, 22 Jan 2019 22:13:44 -0800 Subject: [PATCH 08/38] rebrand to example --- deploy/releases/blue.yaml | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/deploy/releases/blue.yaml b/deploy/releases/blue.yaml index eadb468..555dac0 100644 --- a/deploy/releases/blue.yaml +++ b/deploy/releases/blue.yaml @@ -4,17 +4,11 @@ repositories: url: "https://charts.cloudposse.com/incubator/" releases: - -####################################################################################### -## Atlantis ## -####################################################################################### - # # References: -# - https://github.com/cloudposse/atlantis/tree/master/helm/atlantis # - https://github.com/cloudposse/charts/blob/master/incubator/monochart # -- name: "blue-example" +- name: "example-blue" labels: color: "blue" chart: "cloudposse-incubator/monochart" @@ -23,13 +17,13 @@ releases: force: true recreatePods: false values: - - fullnameOverride: atlantis + - fullnameOverride: "example-blue" image: repository: '{{ env "IMAGE_NAME" | default "cloudposse/example-app" }}' tag: '{{ env "IMAGE_TAG" | default "0.1.0" }}' pullPolicy: Always pullSecrets: - - 'atlantis-pull-secret-dockercfg' + - "pull-secret" configMaps: default: @@ -57,14 +51,14 @@ releases: external-dns.alpha.kubernetes.io/target: '{{ requiredEnv "NGINX_INGRESS_HOSTNAME" }}' external-dns.alpha.kubernetes.io/ttl: "60" hosts: - ### Required: ATLANTIS_HOSTNAME; - '{{ env "ATLANTIS_HOSTNAME" }}': / + ### Required: APP_HOSTNAME; + '{{ env "APP_HOSTNAME" }}': / tls: ### Optional: ATLANTIS_TLS_SECRET_NAME; - - secretName: '{{ env "ATLANTIS_TLS_SECRET_NAME" | default "atlantis-server-tls" }}' + - secretName: '{{ env "APP_TLS_SECRET_NAME" | default "example-blue-server-tls" }}' hosts: - ### Required: ATLANTIS_HOSTNAME; - - '{{ env "ATLANTIS_HOSTNAME" }}' + ### Required: APP_HOSTNAME; + - '{{ env "APP_HOSTNAME" }}' probes: livenessProbe: From c1737cceda1bf733251c9e55d346df750f178186 Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Tue, 22 Jan 2019 22:39:30 -0800 Subject: [PATCH 09/38] enable deployment --- deploy/releases/blue.yaml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/deploy/releases/blue.yaml b/deploy/releases/blue.yaml index 555dac0..f02aa83 100644 --- a/deploy/releases/blue.yaml +++ b/deploy/releases/blue.yaml @@ -24,7 +24,17 @@ releases: pullPolicy: Always pullSecrets: - "pull-secret" + replicaCount: 2 + # Deployment configuration + deployment: + enabled: true + strategy: + type: "RollingUpdate" + rollingUpdate: + maxUnavailable: 0 + revisionHistoryLimit: 10 + # Configuration Settings configMaps: default: enabled: true @@ -32,6 +42,7 @@ releases: # Color to deploy COLOR: "cyan" + # Service endpoint service: enabled: true type: ClusterIP From c49221cec50129cd53ef811c90099e1da74ea440 Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Tue, 22 Jan 2019 22:53:34 -0800 Subject: [PATCH 10/38] Enable boom --- main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.go b/main.go index edca8b4..cec3600 100644 --- a/main.go +++ b/main.go @@ -25,7 +25,7 @@ func main() { http.HandleFunc("/boom", func(w http.ResponseWriter, r *http.Request) { fmt.Fprintf(w, string(boom)) fmt.Printf("Goodbye\n") - //die() + die() }) // Dashboard From c94455752043fc972b321c4e9be440a0587f3f43 Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Tue, 22 Jan 2019 23:07:25 -0800 Subject: [PATCH 11/38] prefix color --- deploy/releases/blue.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/deploy/releases/blue.yaml b/deploy/releases/blue.yaml index f02aa83..e53302c 100644 --- a/deploy/releases/blue.yaml +++ b/deploy/releases/blue.yaml @@ -63,13 +63,13 @@ releases: external-dns.alpha.kubernetes.io/ttl: "60" hosts: ### Required: APP_HOSTNAME; - '{{ env "APP_HOSTNAME" }}': / + 'blue.{{ env "APP_HOSTNAME" }}': / tls: ### Optional: ATLANTIS_TLS_SECRET_NAME; - secretName: '{{ env "APP_TLS_SECRET_NAME" | default "example-blue-server-tls" }}' hosts: ### Required: APP_HOSTNAME; - - '{{ env "APP_HOSTNAME" }}' + - 'blue.{{ env "APP_HOSTNAME" }}' probes: livenessProbe: From 66994924986d113f1f279af2f620953307cb5705 Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Tue, 22 Jan 2019 23:44:48 -0800 Subject: [PATCH 12/38] Generalize --- deploy/helmfile.yaml | 2 +- deploy/releases/{blue.yaml => app.yaml} | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) rename deploy/releases/{blue.yaml => app.yaml} (88%) diff --git a/deploy/helmfile.yaml b/deploy/helmfile.yaml index f9d995c..bd756f0 100644 --- a/deploy/helmfile.yaml +++ b/deploy/helmfile.yaml @@ -1,3 +1,3 @@ # Ordered list of releases. helmfiles: - - "releases/blue.yaml" \ No newline at end of file + - "releases/app.yaml" \ No newline at end of file diff --git a/deploy/releases/blue.yaml b/deploy/releases/app.yaml similarity index 88% rename from deploy/releases/blue.yaml rename to deploy/releases/app.yaml index e53302c..10eaf68 100644 --- a/deploy/releases/blue.yaml +++ b/deploy/releases/app.yaml @@ -8,16 +8,16 @@ releases: # References: # - https://github.com/cloudposse/charts/blob/master/incubator/monochart # -- name: "example-blue" +- name: 'example-{{ requiredEnv "COLOR" }}' labels: - color: "blue" + color: "{{ requiredEnv "COLOR" }}" chart: "cloudposse-incubator/monochart" version: "0.7.0" wait: true force: true recreatePods: false values: - - fullnameOverride: "example-blue" + - fullnameOverride: "example-{{ requiredEnv "COLOR" }}" image: repository: '{{ env "IMAGE_NAME" | default "cloudposse/example-app" }}' tag: '{{ env "IMAGE_TAG" | default "0.1.0" }}' @@ -63,13 +63,13 @@ releases: external-dns.alpha.kubernetes.io/ttl: "60" hosts: ### Required: APP_HOSTNAME; - 'blue.{{ env "APP_HOSTNAME" }}': / + '{{ requiredEnv "COLOR" }}.{{ env "APP_HOSTNAME" }}': / tls: ### Optional: ATLANTIS_TLS_SECRET_NAME; - - secretName: '{{ env "APP_TLS_SECRET_NAME" | default "example-blue-server-tls" }}' + - secretName: '{{ env "APP_TLS_SECRET_NAME" | default "example-{{ requiredEnv "COLOR" }}-server-tls" }}' hosts: ### Required: APP_HOSTNAME; - - 'blue.{{ env "APP_HOSTNAME" }}' + - '{{ requiredEnv "COLOR" }}.{{ env "APP_HOSTNAME" }}' probes: livenessProbe: From 56c67fec689255bbf8321f95feae00475fb3eab5 Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Wed, 23 Jan 2019 00:03:18 -0800 Subject: [PATCH 13/38] fix syntax --- deploy/releases/app.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deploy/releases/app.yaml b/deploy/releases/app.yaml index 10eaf68..cfab996 100644 --- a/deploy/releases/app.yaml +++ b/deploy/releases/app.yaml @@ -66,7 +66,7 @@ releases: '{{ requiredEnv "COLOR" }}.{{ env "APP_HOSTNAME" }}': / tls: ### Optional: ATLANTIS_TLS_SECRET_NAME; - - secretName: '{{ env "APP_TLS_SECRET_NAME" | default "example-{{ requiredEnv "COLOR" }}-server-tls" }}' + - secretName: '{{ env "APP_TLS_SECRET_NAME" | default (requiredEnv "COLOR" | printf "example-%s-server-tls") }}' hosts: ### Required: APP_HOSTNAME; - '{{ requiredEnv "COLOR" }}.{{ env "APP_HOSTNAME" }}' From 41e444f566829e941e3e7f55c37be4dd2fa2c4a9 Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Wed, 23 Jan 2019 01:02:09 -0800 Subject: [PATCH 14/38] Add ctl tool --- deploy/ctl | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100755 deploy/ctl diff --git a/deploy/ctl b/deploy/ctl new file mode 100755 index 0000000..8472f81 --- /dev/null +++ b/deploy/ctl @@ -0,0 +1,57 @@ +#!/usr/bin/env variant +# vim:set ft=yaml +tasks: + deps: + description: "Install alpine dependencies" + script: | + apk add --update curl make bash git kubectl@cloudposse helm@cloudposse helmfile@cloudposse + + color: + description: "Lookup the current color" + + parameters: + - name: config + default: ".color" + description: "Config file that keeps track of the current color" + + script: | + config=${CF_VOLUME_PATH:-.}/{{ get "config" }} + if [ -f ${config} ]; then + cat ${config} + else + echo "blue" | tee ${config} + fi + blue-green: + description: "Trigger a blue-green deployment" + + parameters: + - name: namespace + default: "default" + description: "Kubernetes namespace" + + - name: config + default: ".color" + description: "Config file that keeps track of the current color" + + - name: color + type: string + description: "Selected color to deploy" + + - name: blue + type: string + default: green + description: "Flip blue color to this color" + + - name: green + type: string + default: blue + description: "Flip green color to this color" + + script: | + config=${CF_VOLUME_PATH:-.}/{{ get "config" }} + cur_color={{ get "color" }} + new_color={{ get "color" | get }} + echo "Updating {{ get "namespace" }}: $cur_color => $new_color" + echo "$new_color" > ${config} + export COLOR=$new_color + helmfile --namespace {{ get "namespace" }} sync \ No newline at end of file From c557486b696b2647e1cc27a1cdf659ed36945538 Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Wed, 23 Jan 2019 01:32:58 -0800 Subject: [PATCH 15/38] Update deployment script --- Dockerfile | 1 + deploy/ctl | 47 +++++++++++++++++++++++++++-------------------- 2 files changed, 28 insertions(+), 20 deletions(-) diff --git a/Dockerfile b/Dockerfile index 5cb5b4b..5186c88 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,6 +13,7 @@ FROM alpine:3.8 as final # Install the cloudposse alpine repository ADD https://apk.cloudposse.com/ops@cloudposse.com.rsa.pub /etc/apk/keys/ RUN echo "@cloudposse https://apk.cloudposse.com/3.8/vendor" >> /etc/apk/repositories +RUN apk add --update variant@cloudposse # Expose port of the app EXPOSE 8080 diff --git a/deploy/ctl b/deploy/ctl index 8472f81..1aced1f 100755 --- a/deploy/ctl +++ b/deploy/ctl @@ -1,19 +1,26 @@ #!/usr/bin/env variant # vim:set ft=yaml + +parameters: +- name: config + default: .color + description: "Config file that keeps track of the current color" + +options: +- name: debug + default: boolean + default: false + description: "Enable debug mode" + tasks: + deps: description: "Install alpine dependencies" script: | - apk add --update curl make bash git kubectl@cloudposse helm@cloudposse helmfile@cloudposse + ! which apk >/dev/null || apk add --update curl make bash git kubectl@cloudposse helm@cloudposse helmfile@cloudposse color: description: "Lookup the current color" - - parameters: - - name: config - default: ".color" - description: "Config file that keeps track of the current color" - script: | config=${CF_VOLUME_PATH:-.}/{{ get "config" }} if [ -f ${config} ]; then @@ -21,6 +28,7 @@ tasks: else echo "blue" | tee ${config} fi + blue-green: description: "Trigger a blue-green deployment" @@ -28,10 +36,6 @@ tasks: - name: namespace default: "default" description: "Kubernetes namespace" - - - name: config - default: ".color" - description: "Config file that keeps track of the current color" - name: color type: string @@ -46,12 +50,15 @@ tasks: type: string default: blue description: "Flip green color to this color" - - script: | - config=${CF_VOLUME_PATH:-.}/{{ get "config" }} - cur_color={{ get "color" }} - new_color={{ get "color" | get }} - echo "Updating {{ get "namespace" }}: $cur_color => $new_color" - echo "$new_color" > ${config} - export COLOR=$new_color - helmfile --namespace {{ get "namespace" }} sync \ No newline at end of file + + steps: + - task: deps + - script: | + config=${CF_VOLUME_PATH:-.}/{{ get "config" }} + cur_color={{ get "color" }} + new_color={{ get "color" | get }} + echo "Config file is ${config}" + echo "Updating {{ get "namespace" }}: $cur_color => $new_color" + echo "$new_color" > ${config} + export COLOR=$new_color + helmfile --namespace {{ get "namespace" }} sync \ No newline at end of file From e8d4e07b7435eebf974dba8c2810586b22611b92 Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Wed, 23 Jan 2019 01:48:29 -0800 Subject: [PATCH 16/38] Remove debug mode --- deploy/ctl | 7 ------- 1 file changed, 7 deletions(-) diff --git a/deploy/ctl b/deploy/ctl index 1aced1f..51590b7 100755 --- a/deploy/ctl +++ b/deploy/ctl @@ -6,14 +6,7 @@ parameters: default: .color description: "Config file that keeps track of the current color" -options: -- name: debug - default: boolean - default: false - description: "Enable debug mode" - tasks: - deps: description: "Install alpine dependencies" script: | From e90d29dcf0c7b05cde76a475f84bdb4ac75501ee Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Wed, 23 Jan 2019 02:14:44 -0800 Subject: [PATCH 17/38] Update readme --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 199308b..6bea3b9 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,5 @@ # example-app -Example application for CI/CD demonstrations + +Example application for Codefresh CI/CD demonstrations. + +Contact From 95e94fa08410ae735ded0e34ea521d2afe5696bf Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Wed, 23 Jan 2019 03:17:55 -0800 Subject: [PATCH 18/38] add bash --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 5186c88..943f92a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,7 +13,7 @@ FROM alpine:3.8 as final # Install the cloudposse alpine repository ADD https://apk.cloudposse.com/ops@cloudposse.com.rsa.pub /etc/apk/keys/ RUN echo "@cloudposse https://apk.cloudposse.com/3.8/vendor" >> /etc/apk/repositories -RUN apk add --update variant@cloudposse +RUN apk add --update bash variant@cloudposse # Expose port of the app EXPOSE 8080 From 57fc839efef561a73646a8a04a491a4d61995e96 Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Wed, 23 Jan 2019 04:28:53 -0800 Subject: [PATCH 19/38] Add istio --- .editorconfig | 6 ++++- deploy/ctl | 10 +++++++ deploy/helmfile.yaml | 3 ++- deploy/releases/istio.yaml | 54 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 71 insertions(+), 2 deletions(-) create mode 100644 deploy/releases/istio.yaml diff --git a/.editorconfig b/.editorconfig index 7928ca4..da7face 100644 --- a/.editorconfig +++ b/.editorconfig @@ -5,4 +5,8 @@ indent_size = 4 [Makefile.*] indent_style = tab -indent_size = 4 \ No newline at end of file +indent_size = 4 + +[*.yaml] +indent_style = spaces +indent_size = 2 \ No newline at end of file diff --git a/deploy/ctl b/deploy/ctl index 51590b7..4bafac3 100755 --- a/deploy/ctl +++ b/deploy/ctl @@ -7,6 +7,16 @@ parameters: description: "Config file that keeps track of the current color" tasks: + + # https://istio.io/docs/tasks/traffic-management/ingress/#determining-the-ingress-ip-and-ports-when-using-an-external-load-balancer + ingress-host: + script: | + kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.status.loadBalancer.ingress[0].hostname}' + # https://istio.io/docs/setup/kubernetes/quick-start/ + istio-injection: + script: | + kubectl label namespace testing istio-injection=enabled + deps: description: "Install alpine dependencies" script: | diff --git a/deploy/helmfile.yaml b/deploy/helmfile.yaml index bd756f0..21de18c 100644 --- a/deploy/helmfile.yaml +++ b/deploy/helmfile.yaml @@ -1,3 +1,4 @@ # Ordered list of releases. helmfiles: - - "releases/app.yaml" \ No newline at end of file + - "releases/app.yaml" + - "releases/istio.yaml" diff --git a/deploy/releases/istio.yaml b/deploy/releases/istio.yaml new file mode 100644 index 0000000..8d54148 --- /dev/null +++ b/deploy/releases/istio.yaml @@ -0,0 +1,54 @@ +repositories: +# Cloud Posse incubator repo of helm charts +- name: "kubernetes-incubator" + url: "https://kubernetes-charts-incubator.storage.googleapis.com" + +releases: +# +# References: +# - https://github.com/helm/charts/tree/master/incubator/raw +# +- name: 'example-{{ requiredEnv "COLOR" }}' + labels: + color: "{{ requiredEnv "COLOR" }}" + chart: "kubernetes-incubator/raw" + version: "0.1.0" + wait: true + force: true + recreatePods: false + values: + - resources: + # Istio Gateway + - apiVersion: networking.istio.io/v1alpha3 + kind: Gateway + metadata: + name: example-app + spec: + selector: + # use istio default controller + istio: ingressgateway + servers: + - port: + number: 80 + name: http + protocol: HTTP + hosts: + - "{{ env "APP_HOSTNAME" }}" + + # Istio Virtual Service + - apiVersion: networking.istio.io/v1alpha3 + kind: VirtualService + metadata: + name: example-app + spec: + hosts: + - "{{ env "APP_HOSTNAME" }}" + gateways: + - example-app + http: + - route: + - destination: + host: example-{{ env "COLOR" }} + port: + number: 80 + weight: 100 \ No newline at end of file From 84587d7c34157314251c8d252f62168d2cdd827e Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Wed, 23 Jan 2019 04:40:11 -0800 Subject: [PATCH 20/38] helm init --- deploy/ctl | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/deploy/ctl b/deploy/ctl index 4bafac3..2a611ff 100755 --- a/deploy/ctl +++ b/deploy/ctl @@ -6,21 +6,29 @@ parameters: default: .color description: "Config file that keeps track of the current color" +- name: namespace + default: "default" + description: "Kubernetes namespace" + tasks: # https://istio.io/docs/tasks/traffic-management/ingress/#determining-the-ingress-ip-and-ports-when-using-an-external-load-balancer - ingress-host: + istio-ingress: + description: Output the FQHN of the Istio Ingress Gateway script: | - kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.status.loadBalancer.ingress[0].hostname}' + kubectl --namespace istio-system get service istio-ingressgateway -o jsonpath='{.status.loadBalancer.ingress[0].hostname}' + # https://istio.io/docs/setup/kubernetes/quick-start/ istio-injection: + description: Enable Istio Sidecar Injection for a namespce script: | - kubectl label namespace testing istio-injection=enabled + kubectl label namespace {{ get "namespace" }} istio-injection=enabled deps: description: "Install alpine dependencies" script: | ! which apk >/dev/null || apk add --update curl make bash git kubectl@cloudposse helm@cloudposse helmfile@cloudposse + helm init --client-only color: description: "Lookup the current color" @@ -34,12 +42,7 @@ tasks: blue-green: description: "Trigger a blue-green deployment" - parameters: - - name: namespace - default: "default" - description: "Kubernetes namespace" - - name: color type: string description: "Selected color to deploy" @@ -56,6 +59,7 @@ tasks: steps: - task: deps + - task: istio-injection - script: | config=${CF_VOLUME_PATH:-.}/{{ get "config" }} cur_color={{ get "color" }} @@ -64,4 +68,5 @@ tasks: echo "Updating {{ get "namespace" }}: $cur_color => $new_color" echo "$new_color" > ${config} export COLOR=$new_color + # Deploy the app and update istio virtual service helmfile --namespace {{ get "namespace" }} sync \ No newline at end of file From 05fcd84dc61c9117fe5a2333435be7b1253ecdff Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Wed, 23 Jan 2019 04:45:22 -0800 Subject: [PATCH 21/38] triage --- deploy/ctl | 1 - 1 file changed, 1 deletion(-) diff --git a/deploy/ctl b/deploy/ctl index 2a611ff..9777e3c 100755 --- a/deploy/ctl +++ b/deploy/ctl @@ -59,7 +59,6 @@ tasks: steps: - task: deps - - task: istio-injection - script: | config=${CF_VOLUME_PATH:-.}/{{ get "config" }} cur_color={{ get "color" }} From b4fc9b3655eb1eb41153bc12191933467cf8e704 Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Wed, 23 Jan 2019 04:55:31 -0800 Subject: [PATCH 22/38] add details --- deploy/ctl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deploy/ctl b/deploy/ctl index 9777e3c..1446fad 100755 --- a/deploy/ctl +++ b/deploy/ctl @@ -64,7 +64,7 @@ tasks: cur_color={{ get "color" }} new_color={{ get "color" | get }} echo "Config file is ${config}" - echo "Updating {{ get "namespace" }}: $cur_color => $new_color" + echo "Updating [${KUBE_CONTEXT}] context {{ get "namespace" }} namespace: $cur_color => $new_color" echo "$new_color" > ${config} export COLOR=$new_color # Deploy the app and update istio virtual service From e6004449478937a1c848ada59fbe7fcf661cec65 Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Wed, 23 Jan 2019 05:08:17 -0800 Subject: [PATCH 23/38] define context --- deploy/ctl | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/deploy/ctl b/deploy/ctl index 1446fad..28d88cf 100755 --- a/deploy/ctl +++ b/deploy/ctl @@ -23,6 +23,11 @@ tasks: description: Enable Istio Sidecar Injection for a namespce script: | kubectl label namespace {{ get "namespace" }} istio-injection=enabled + + use-context: + description: "Configure kube-context" + script: | + kubectl config use-context ${KUBE_CONTEXT} deps: description: "Install alpine dependencies" @@ -59,6 +64,8 @@ tasks: steps: - task: deps + - task: use-context + - task: istio-injection - script: | config=${CF_VOLUME_PATH:-.}/{{ get "config" }} cur_color={{ get "color" }} From a9c45ad3aa1bd9db748f31f95456d6683b61fdeb Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Wed, 23 Jan 2019 05:12:26 -0800 Subject: [PATCH 24/38] overwrite label --- deploy/ctl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deploy/ctl b/deploy/ctl index 28d88cf..70e9447 100755 --- a/deploy/ctl +++ b/deploy/ctl @@ -22,7 +22,7 @@ tasks: istio-injection: description: Enable Istio Sidecar Injection for a namespce script: | - kubectl label namespace {{ get "namespace" }} istio-injection=enabled + kubectl label namespace {{ get "namespace" }} istio-injection=enabled --overwrite=true use-context: description: "Configure kube-context" From f20203dfccb2f06a4715f8bd383b6b1654015bd8 Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Wed, 23 Jan 2019 05:26:29 -0800 Subject: [PATCH 25/38] fix istio name --- deploy/releases/istio.yaml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/deploy/releases/istio.yaml b/deploy/releases/istio.yaml index 8d54148..56b3301 100644 --- a/deploy/releases/istio.yaml +++ b/deploy/releases/istio.yaml @@ -8,9 +8,7 @@ releases: # References: # - https://github.com/helm/charts/tree/master/incubator/raw # -- name: 'example-{{ requiredEnv "COLOR" }}' - labels: - color: "{{ requiredEnv "COLOR" }}" +- name: 'example-istio' chart: "kubernetes-incubator/raw" version: "0.1.0" wait: true From 531401933b27d519c8061b0c35c1123e11473d7e Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Wed, 23 Jan 2019 06:02:47 -0800 Subject: [PATCH 26/38] fix yaml --- deploy/releases/istio.yaml | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/deploy/releases/istio.yaml b/deploy/releases/istio.yaml index 56b3301..db8d120 100644 --- a/deploy/releases/istio.yaml +++ b/deploy/releases/istio.yaml @@ -16,20 +16,21 @@ releases: recreatePods: false values: - resources: + # Istio Gateway - apiVersion: networking.istio.io/v1alpha3 kind: Gateway metadata: - name: example-app + name: example-app spec: - selector: + selector: # use istio default controller istio: ingressgateway - servers: - - port: - number: 80 - name: http - protocol: HTTP + servers: + - port: + number: 80 + name: http + protocol: HTTP hosts: - "{{ env "APP_HOSTNAME" }}" From 864e8f5d8989e00cc701213a12caed1ebe4ed791 Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Wed, 23 Jan 2019 06:10:41 -0800 Subject: [PATCH 27/38] tune settings --- deploy/releases/app.yaml | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/deploy/releases/app.yaml b/deploy/releases/app.yaml index cfab996..648151f 100644 --- a/deploy/releases/app.yaml +++ b/deploy/releases/app.yaml @@ -24,14 +24,14 @@ releases: pullPolicy: Always pullSecrets: - "pull-secret" - replicaCount: 2 + replicaCount: 10 # Deployment configuration deployment: enabled: true strategy: type: "RollingUpdate" rollingUpdate: - maxUnavailable: 0 + maxUnavailable: 2 revisionHistoryLimit: 10 # Configuration Settings @@ -40,7 +40,8 @@ releases: enabled: true env: # Color to deploy - COLOR: "cyan" + #COLOR: "#0099ff" # Blue + COLOR: "#009900" # Green # Service endpoint service: @@ -72,27 +73,30 @@ releases: - '{{ requiredEnv "COLOR" }}.{{ env "APP_HOSTNAME" }}' probes: + # Probe that ensures service is healthy livenessProbe: httpGet: path: /healthz port: default scheme: HTTP - periodSeconds: 60 - initialDelaySeconds: 5 + periodSeconds: 5 + initialDelaySeconds: 0 timeoutSeconds: 5 successThreshold: 1 - failureThreshold: 5 + failureThreshold: 3 scheme: HTTP + + # Probe that ensures service has started readinessProbe: httpGet: path: /healthz port: default scheme: HTTP - periodSeconds: 60 - initialDelaySeconds: 10 + periodSeconds: 3 + initialDelaySeconds: 0 timeoutSeconds: 5 successThreshold: 1 - failureThreshold: 5 + failureThreshold: 2 resources: requests: From 579bc9c1e85f41d2f6926ed88a06d257986939af Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Wed, 23 Jan 2019 06:22:59 -0800 Subject: [PATCH 28/38] save state after successful deploy --- deploy/ctl | 4 ++-- deploy/releases/app.yaml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/deploy/ctl b/deploy/ctl index 70e9447..77bd764 100755 --- a/deploy/ctl +++ b/deploy/ctl @@ -72,7 +72,7 @@ tasks: new_color={{ get "color" | get }} echo "Config file is ${config}" echo "Updating [${KUBE_CONTEXT}] context {{ get "namespace" }} namespace: $cur_color => $new_color" - echo "$new_color" > ${config} export COLOR=$new_color # Deploy the app and update istio virtual service - helmfile --namespace {{ get "namespace" }} sync \ No newline at end of file + helmfile --namespace {{ get "namespace" }} sync + echo "$new_color" > ${config} \ No newline at end of file diff --git a/deploy/releases/app.yaml b/deploy/releases/app.yaml index 648151f..6ef3278 100644 --- a/deploy/releases/app.yaml +++ b/deploy/releases/app.yaml @@ -40,8 +40,8 @@ releases: enabled: true env: # Color to deploy - #COLOR: "#0099ff" # Blue - COLOR: "#009900" # Green + COLOR: "#0099ff" # Blue + #COLOR: "#009900" # Green # Service endpoint service: From 4eced17bc5838ea5bfba3d2feecf0c7e53ed5be2 Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Wed, 23 Jan 2019 06:24:01 -0800 Subject: [PATCH 29/38] silence logs --- main.go | 1 - 1 file changed, 1 deletion(-) diff --git a/main.go b/main.go index cec3600..021a065 100644 --- a/main.go +++ b/main.go @@ -17,7 +17,6 @@ func main() { // Healthcheck endpoint http.HandleFunc("/healthz", func(w http.ResponseWriter, r *http.Request) { fmt.Fprintf(w, "OK") - fmt.Printf("GET %s\n", r.URL.Path) }) // Take one for the team From d3f5af851e48242ac30b993fd35f15d32ea6cd06 Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Wed, 23 Jan 2019 06:25:09 -0800 Subject: [PATCH 30/38] Disable death --- main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.go b/main.go index 021a065..f92c7af 100644 --- a/main.go +++ b/main.go @@ -24,7 +24,7 @@ func main() { http.HandleFunc("/boom", func(w http.ResponseWriter, r *http.Request) { fmt.Fprintf(w, string(boom)) fmt.Printf("Goodbye\n") - die() + //die() }) // Dashboard From 0765d5b0616c686f15b7a69cf8849d1133fbb1a1 Mon Sep 17 00:00:00 2001 From: Andriy Knysh Date: Wed, 23 Jan 2019 09:12:36 -0800 Subject: [PATCH 31/38] Update public/boom.html Co-Authored-By: osterman --- public/boom.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/boom.html b/public/boom.html index 36fb1c8..0ddae86 100644 --- a/public/boom.html +++ b/public/boom.html @@ -3,7 +3,7 @@ From 10e732471ee2b3fc8346fa26a652f79b9a5926d4 Mon Sep 17 00:00:00 2001 From: Andriy Knysh Date: Wed, 23 Jan 2019 09:12:58 -0800 Subject: [PATCH 33/38] Update deploy/releases/istio.yaml Co-Authored-By: osterman --- deploy/releases/istio.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/deploy/releases/istio.yaml b/deploy/releases/istio.yaml index db8d120..4d4a266 100644 --- a/deploy/releases/istio.yaml +++ b/deploy/releases/istio.yaml @@ -1,5 +1,5 @@ repositories: -# Cloud Posse incubator repo of helm charts +# Kubernetes incubator repo of helm charts - name: "kubernetes-incubator" url: "https://kubernetes-charts-incubator.storage.googleapis.com" @@ -50,4 +50,4 @@ releases: host: example-{{ env "COLOR" }} port: number: 80 - weight: 100 \ No newline at end of file + weight: 100 From 8fa849d55835ebb9ad8a497542dbf3df37e69526 Mon Sep 17 00:00:00 2001 From: Andriy Knysh Date: Wed, 23 Jan 2019 09:13:26 -0800 Subject: [PATCH 34/38] Update public/index.html Co-Authored-By: osterman --- public/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/index.html b/public/index.html index bab80ea..f187446 100644 --- a/public/index.html +++ b/public/index.html @@ -3,7 +3,7 @@