forked from quiccklabs/Labs_solutions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Optimize Costs for Google Kubernetes Engine: Challenge Lab
52 lines (25 loc) · 1.56 KB
/
Optimize Costs for Google Kubernetes Engine: Challenge Lab
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
Task 1:
ZONE=us-central1-b
gcloud container clusters create Cluster_Name --project=$DEVSHELL_PROJECT_ID --zone=$ZONE --machine-type=n1-standard-2 --num-nodes=2
kubectl create namespace dev
kubectl create namespace prod
git clone https://github.com/GoogleCloudPlatform/microservices-demo.git &&
cd microservices-demo && kubectl apply -f ./release/kubernetes-manifests.yaml --namespace dev
Task 2:
gcloud container node-pools create Pool_Name --cluster=Cluster_Name --machine-type=custom-2-3584 --num-nodes=2 --zone=$ZONE
for node in $(kubectl get nodes -l cloud.google.com/gke-nodepool=default-pool -o=name); do kubectl cordon "$node"; done
for node in $(kubectl get nodes -l cloud.google.com/gke-nodepool=default-pool -o=name); do kubectl drain --force --ignore-daemonsets --delete-local-data --grace-period=10 "$node"; done
kubectl get pods -o=wide --namespace=dev
gcloud container node-pools delete default-pool --cluster Cluster_Name --zone $ZONE
Task 3:
kubectl create poddisruptionbudget onlineboutique-frontend-pdb --selector app=frontend --min-available 1 --namespace dev
KUBE_EDITOR="nano" kubectl edit deployment/frontend --namespace dev
Find image under spec
replace image: gcr.io/qwiklabs-resources/onlineboutique-frontend:v2.1
and in imagePullPolicy: Always
Press ctrl+x then Y then enter
Task 4:-
kubectl autoscale deployment frontend --cpu-percent=50 --min=1 --max=13 --namespace dev
kubectl get hpa --namespace dev
ZONE=us-central1-b
gcloud beta container clusters update Cluster_Name --enable-autoscaling --min-nodes 1 --max-nodes 6 --zone=$ZONE