Skip to content

Instantly share code, notes, and snippets.

@vfarcic
Created July 12, 2020 12:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save vfarcic/69dd7684c06cd2200f4e5dc3308a4e9d to your computer and use it in GitHub Desktop.
Save vfarcic/69dd7684c06cd2200f4e5dc3308a4e9d to your computer and use it in GitHub Desktop.
######################
# Creating A Cluster #
######################
minikube start \
--vm-driver virtualbox \
--cpus 4 \
--memory 8192
minikube addons enable default-storageclass
minikube addons enable storage-provisioner
istioctl manifest apply \
--set profile=demo
kubectl apply \
--kustomize github.com/weaveworks/flagger/kustomize/istio
#####################
# Deploying The App #
#####################
git clone \
https://github.com/vfarcic/go-demo-7.git
cd go-demo-7
git pull
kubectl create namespace go-demo-7
kubectl label namespace go-demo-7 \
istio-injection=enabled
kubectl --namespace go-demo-7 apply \
--filename k8s/db \
--recursive
ls -l k8s/app
cat k8s/app/*
kubectl --namespace go-demo-7 apply \
--filename k8s/app \
--recursive
export INGRESS_PORT=$(kubectl \
--namespace istio-system \
get service istio-ingressgateway \
--output jsonpath='{.spec.ports[?(@.name=="http2")].nodePort}')
export INGRESS_HOST=$(minikube ip):$INGRESS_PORT
echo $INGRESS_HOST
curl -v -H "Host: go-demo-7.acme.com" \
"http://$INGRESS_HOST/version"
kubectl --namespace go-demo-7 \
get gateways,ingresses
##############################
# Deploying Flagger Resource #
##############################
cat k8s/istio/flagger/exercise/flagger.yaml
kubectl --namespace go-demo-7 apply \
--filename k8s/istio/flagger/exercise/flagger.yaml
cat k8s/istio/flagger/exercise/gateway.yaml
kubectl --namespace go-demo-7 apply \
--filename k8s/istio/flagger/exercise/gateway.yaml
kubectl --namespace go-demo-7 \
get deployments
kubectl --namespace go-demo-7 \
rollout status \
deployment go-demo-7-primary
kubectl --namespace go-demo-7 \
get hpa
# Might be `<unknown>` if metrics server is not installed
for i in {1..10}; do
curl -H "Host: go-demo-7.acme.com" \
"http://$INGRESS_HOST/version"
sleep 0.25
done
kubectl --namespace go-demo-7 \
get services
kubectl --namespace go-demo-7 \
get destinationrules
kubectl --namespace go-demo-7 \
get virtualservices
kubectl --namespace go-demo-7 \
get canaries
kubectl --namespace go-demo-7 \
describe canary go-demo-7
###########################
# Deploying A New Release #
###########################
cat k8s/istio/flagger/exercise/deployment-0-0-2.yaml
diff k8s/app/deployment.yaml \
k8s/istio/flagger/exercise/deployment-0-0-2.yaml
echo $INGRESS_HOST
# Open a second terminal session
export INGRESS_HOST=[...]
while true; do
curl -H "Host: go-demo-7.acme.com" \
"http://$INGRESS_HOST/version"
sleep 1
done
# Go back to the first terminal session
kubectl --namespace go-demo-7 apply \
--filename k8s/istio/flagger/exercise/deployment-0-0-2.yaml
kubectl --namespace go-demo-7 \
get deployments
kubectl --namespace go-demo-7 \
get virtualservices
kubectl --namespace go-demo-7 \
describe virtualservice go-demo-7
kubectl --namespace go-demo-7 \
get pods
kubectl --namespace go-demo-7 \
get canaries
kubectl --namespace go-demo-7 \
describe canary go-demo-7
kubectl --namespace go-demo-7 \
describe virtualservice go-demo-7
kubectl --namespace go-demo-7 \
get canaries
# Go to the second terminal session and stop the loop with *ctrl+c*
#######################
# Visualizing Metrics #
#######################
# Go to the first terminal session
istioctl manifest apply \
--set values.grafana.enabled=true
kubectl --namespace istio-system \
port-forward $(kubectl \
--namespace istio-system \
get pod \
--selector app=grafana \
--output jsonpath='{.items[0].metadata.name}') \
3000:3000 &
cat k8s/grafana/flagger.json
# Copy the JSON
open "http://localhost:3000/dashboard/import"
# Paste the JSON
##############
# References #
##############
# https://docs.flagger.app/
###############
# Cleaning Up #
###############
cd ..
killall kubectl
kubectl delete namespace go-demo-7
# Destroy the cluster (optional)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment