Skip to content

Instantly share code, notes, and snippets.

@vfarcic
Last active January 18, 2022 00:52
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/675f4b3ee2c55ee718cf132e71e04c6e to your computer and use it in GitHub Desktop.
Save vfarcic/675f4b3ee2c55ee718cf132e71e04c6e to your computer and use it in GitHub Desktop.
######################
# Create The Cluster #
######################
gcloud auth login
REGION=us-east1
MACHINE_TYPE=n1-standard-1
gcloud container clusters \
create devops25 \
--region $REGION \
--machine-type $MACHINE_TYPE \
--enable-autoscaling \
--num-nodes 1 \
--max-nodes 3 \
--min-nodes 1
kubectl create clusterrolebinding \
cluster-admin-binding \
--clusterrole cluster-admin \
--user $(gcloud config get-value account)
###################
# Install Ingress #
###################
kubectl apply \
-f https://raw.githubusercontent.com/kubernetes/ingress-nginx/1cd17cd12c98563407ad03812aebac46ca4442f2/deploy/mandatory.yaml
kubectl apply \
-f https://raw.githubusercontent.com/kubernetes/ingress-nginx/1cd17cd12c98563407ad03812aebac46ca4442f2/deploy/provider/cloud-generic.yaml
##################
# Install Tiller #
##################
kubectl create \
-f https://raw.githubusercontent.com/vfarcic/k8s-specs/master/helm/tiller-rbac.yml \
--record --save-config
helm init --service-account tiller
kubectl -n kube-system \
rollout status deploy tiller-deploy
##################
# Get Cluster IP #
##################
export LB_IP=$(kubectl -n ingress-nginx \
get svc ingress-nginx \
-o jsonpath="{.status.loadBalancer.ingress[0].ip}")
echo $LB_IP
# Repeat the `export` command if the output is empty
############################
# Install Prometheus Chart #
############################
PROM_ADDR=mon.$LB_IP.nip.io
AM_ADDR=alertmanager.$LB_IP.nip.io
helm upgrade -i prometheus \
stable/prometheus \
--namespace metrics \
--version 7.1.3 \
--set server.ingress.hosts={$PROM_ADDR} \
--set alertmanager.ingress.hosts={$AM_ADDR} \
-f mon/prom-values.yml
kubectl -n metrics \
rollout status \
deploy prometheus-server
#######################
# Destroy the cluster #
#######################
gcloud container clusters \
delete devops25 \
--region $REGION \
--quiet
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment