Last active
December 23, 2023 03:20
-
-
Save vfarcic/6be19a176b5cbe0261c81aefc86d516b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Source: https://gist.github.com/6be19a176b5cbe0261c81aefc86d516b | |
###################### | |
# Creating A Cluster # | |
###################### | |
# Docker Desktop: https://gist.github.com/f753c0093a0893a1459da663949df618 (docker.sh) | |
# Minikube: https://gist.github.com/ddc923c137cd48e18a04d98b5913f64b (minikube.sh) | |
# GKE: https://gist.github.com/2351032b5031ba3420d2fb9a1c2abd7e (gke.sh) | |
# EKS: https://gist.github.com/be32717b225891b69da2605a3123bb33 (eks.sh) | |
# AKS: https://gist.github.com/c7c9a8603c560eaf88d28db16b14768c (aks.sh) | |
############################# | |
# Deploying The Application # | |
############################# | |
cd go-demo-8 | |
git pull | |
kubectl create namespace go-demo-8 | |
cat k8s/terminate-pods/app/* | |
kubectl --namespace go-demo-8 \ | |
apply --filename k8s/terminate-pods/app | |
kubectl --namespace go-demo-8 \ | |
rollout status deployment go-demo-8 | |
############################## | |
# Validating The Application # | |
############################## | |
kubectl --namespace go-demo-8 \ | |
get ingress | |
# If Minikube | |
minikube addons enable ingress | |
# If Docker Desktop, GKE, or AKS | |
kubectl apply \ | |
--filename https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.1.0/deploy/static/provider/cloud/deploy.yaml | |
# If EKS | |
kubectl apply \ | |
--filename https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.1.0/deploy/static/provider/aws/deploy.yaml | |
# If Minikube | |
export INGRESS_HOST=$(minikube ip) | |
# If Docker Desktop or EKS | |
export INGRESS_HOST=$(kubectl \ | |
--namespace ingress-nginx \ | |
get service ingress-nginx-controller \ | |
--output jsonpath="{.status.loadBalancer.ingress[0].hostname}") | |
# If GKE or AKS | |
export INGRESS_HOST=$(kubectl \ | |
--namespace ingress-nginx \ | |
get service ingress-nginx-controller \ | |
--output jsonpath="{.status.loadBalancer.ingress[0].ip}") | |
echo $INGRESS_HOST | |
# Repeat the `export` command if the output is empty | |
cat k8s/health/ingress.yaml | |
kubectl --namespace go-demo-8 \ | |
apply --filename k8s/health/ingress.yaml | |
curl -H "Host: go-demo-8.acme.com" \ | |
"http://$INGRESS_HOST" | |
################################# | |
# Validating Application Health # | |
################################# | |
cat chaos/health.yaml | |
chaos run chaos/health.yaml | |
kubectl --namespace go-demo-8 \ | |
get pods | |
cat chaos/health-pause.yaml | |
diff chaos/health.yaml \ | |
chaos/health-pause.yaml | |
chaos run chaos/health-pause.yaml | |
kubectl --namespace go-demo-8 \ | |
get pods | |
####################################### | |
# Validating Application Availability # | |
####################################### | |
cat chaos/health-http.yaml | |
diff chaos/health-pause.yaml \ | |
chaos/health-http.yaml | |
chaos run chaos/health-http.yaml | |
cat k8s/health/hpa.yaml | |
kubectl apply --namespace go-demo-8 \ | |
--filename k8s/health/hpa.yaml | |
kubectl --namespace go-demo-8 \ | |
get hpa | |
# Repeat if the number of replicas is not `2` | |
chaos run chaos/health-http.yaml | |
######################################## | |
# Terminating Application Dependencies # | |
######################################## | |
cat chaos/health-db.yaml | |
diff chaos/health-http.yaml \ | |
chaos/health-db.yaml | |
chaos run chaos/health-db.yaml | |
############################## | |
# Destroying What We Created # | |
############################## | |
cd .. | |
kubectl delete namespace go-demo-8 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment