Skip to content
This repository was archived by the owner on Jan 5, 2023. It is now read-only.

Commit

Permalink
basic blue-green argo rollout for subgraphs
Browse files Browse the repository at this point in the history
Signed-off-by: Phil Prasek <[email protected]>
  • Loading branch information
prasek committed Jul 13, 2021
1 parent a66c5e8 commit 4629f86
Show file tree
Hide file tree
Showing 12 changed files with 13,108 additions and 33 deletions.
27 changes: 27 additions & 0 deletions .scripts/k8s-up-bare.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash

KUSTOMIZE_ENV="${1:-dev}"
ROLLOUT_STRATEGY="$2"

INFRA_ENV="${KUSTOMIZE_ENV}"
SUBGRAPHS_ENV="${KUSTOMIZE_ENV}"
ROUTER_ENV="${KUSTOMIZE_ENV}"

if [[ -n "$ROLLOUT_STRATEGY" ]]; then
INFRA_ENV="${INFRA_ENV}"
SUBGRAPHS_ENV="${SUBGRAPHS_ENV}-${ROLLOUT_STRATEGY}"
ROUTER_ENV="${ROUTER_ENV}"
fi

echo "Using Kustomizations:"
echo "- infra/${INFRA_ENV}/kustomization.yaml"
echo "- subgraphs/${SUBGRAPHS_ENV}/kustomization.yaml"
echo "- router/${ROUTER_ENV}/kustomization.yaml"

kind --version

if [ $(kind get clusters | grep -E 'kind') ]
then
kind delete cluster --name kind
fi
kind create cluster --image kindest/node:v1.21.1 --config=clusters/kind-cluster.yaml --wait 5m
19 changes: 4 additions & 15 deletions .scripts/k8s-up-flux.sh
Original file line number Diff line number Diff line change
@@ -1,20 +1,9 @@
#!/bin/bash

KUSTOMIZE_ENV="${1:-dev}"

echo "Using ${KUSTOMIZE_ENV}/kustomization.yaml"

kind --version

if [ $(kind get clusters | grep -E 'kind') ]
then
kind delete cluster --name kind
fi
source "$(dirname $0)/k8s-up-bare.sh"

set -x

kind create cluster --image kindest/node:v1.21.1 --config=clusters/kind-cluster.yaml --wait 5m

flux install

flux create source git k8s-graph-ops \
Expand All @@ -24,15 +13,15 @@ flux create source git k8s-graph-ops \
flux create kustomization infra \
--namespace=default \
--source=GitRepository/k8s-graph-ops.flux-system \
--path="./infra/${KUSTOMIZE_ENV}" \
--path="./infra/${INFRA_ENV}" \
--prune=true \
--interval=1m \
--validation=client

flux create kustomization subgraphs \
--namespace=default \
--source=GitRepository/k8s-graph-ops.flux-system \
--path="./subgraphs/${KUSTOMIZE_ENV}" \
--path="./subgraphs/${SUBGRAPHS_ENV}" \
--prune=true \
--interval=1m \
--validation=client
Expand All @@ -41,7 +30,7 @@ flux create kustomization router \
--depends-on=infra \
--namespace=default \
--source=GitRepository/k8s-graph-ops.flux-system \
--path="./router/${KUSTOMIZE_ENV}" \
--path="./router/${ROUTER_ENV}" \
--prune=true \
--interval=1m \
--validation=client
Expand Down
18 changes: 4 additions & 14 deletions .scripts/k8s-up.sh
Original file line number Diff line number Diff line change
@@ -1,21 +1,11 @@
#!/bin/bash

KUSTOMIZE_ENV="${1:-dev}"

echo "Using ${KUSTOMIZE_ENV}/kustomization.yaml"

kind --version

if [ $(kind get clusters | grep -E 'kind') ]
then
kind delete cluster --name kind
fi
kind create cluster --image kindest/node:v1.21.1 --config=clusters/kind-cluster.yaml --wait 5m
source "$(dirname $0)/k8s-up-bare.sh"

# important: use a newer kubectl version that supports extended kustomize resources
kubectl apply -k infra/$KUSTOMIZE_ENV
kubectl apply -k infra/$INFRA_ENV

kubectl apply -k subgraphs/$KUSTOMIZE_ENV
kubectl apply -k subgraphs/$SUBGRAPHS_ENV

echo waiting for nginx controller to start ...

Expand All @@ -29,7 +19,7 @@ code=1
last=""
until [[ $retry -le 0 || $code -eq 0 ]]
do
result=$(kubectl apply -k router/$KUSTOMIZE_ENV 2>/dev/null)
result=$(kubectl apply -k router/$ROUTER_ENV 2>/dev/null)
code=$?

if [[ "$result" != "$last" ]]
Expand Down
36 changes: 32 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ demo: k8s-up-dev smoke k8s-down
demo-flux: k8s-up-flux-dev smoke k8s-down

.PHONY: k8s-up
k8s-up:
.scripts/k8s-up.sh
k8s-up: k8s-up-dev

.PHONY: k8s-up-dev
k8s-up-dev:
Expand All @@ -24,8 +23,7 @@ k8s-up-prod:
.scripts/k8s-up.sh prod

.PHONY: k8s-up-flux
k8s-up-flux:
.scripts/k8s-up-flux.sh
k8s-up-flux: k8s-up-flux-dev

.PHONY: k8s-up-flux-dev
k8s-up-flux-dev:
Expand All @@ -39,6 +37,36 @@ k8s-up-flux-stage:
k8s-up-flux-prod:
.scripts/k8s-up-flux.sh prod

.PHONY: k8s-up-bluegreen
k8s-up-bluegreen: k8s-up-dev-bluegreen

.PHONY: k8s-up-dev-bluegreen
k8s-up-dev-bluegreen:
.scripts/k8s-up.sh dev bluegreen

.PHONY: k8s-up-stage-bluegreen
k8s-up-stage-bluegreen:
.scripts/k8s-up.sh stage bluegreen

.PHONY: k8s-up-prod-bluegreen
k8s-up-prod-bluegreen:
.scripts/k8s-up.sh prod bluegreen

.PHONY: k8s-up-flux-bluegreen
k8s-up-flux-bluegreen: k8s-up-flux-dev-bluegreen

.PHONY: k8s-up-flux-dev-bluegreen
k8s-up-flux-dev-bluegreen:
.scripts/k8s-up-flux.sh dev bluegreen

.PHONY: k8s-up-flux-stage-bluegreen
k8s-up-flux-stage-bluegreen:
.scripts/k8s-up-flux.sh stage bluegreen

.PHONY: k8s-up-flux-prod-bluegreen
k8s-up-flux-prod-bluegreen:
.scripts/k8s-up-flux.sh prod bluegreen

.PHONY: query
query:
.scripts/query.sh 80
Expand Down
Loading

0 comments on commit 4629f86

Please sign in to comment.