Optimize Costs for Google Kubernetes Engine: Challenge Lab

In this article, we will go through the lab to Optimize Costs for Google Kubernetes Engine: Challenge Lab. In the previous, lab you will get familiar with Managing a GKE Multi-tenant Cluster with Namespaces, Exploring Cost-optimization for GKE Virtual Machines, Understanding and Combining GKE Autoscaling Strategies, and GKE Workload Optimization

The challenge contains 4 required tasks

  1. Create a cluster and deploy an app.
  2. Migrate to an Optimized Nodepool.
  3. Apply a Frontend Update.
  4. Autoscale from Estimated Traffic.

Challenge Scenario

  • You are the lead Google Kubernetes Engine admin on a team that manages the online shop for OnlineBoutique.
  • You are ready to deploy your team’s site to Google Kubernetes Engine but you are still looking for ways to make sure that you’re able to keep costs down and performance up.
  • You will be responsible for deploying the OnlineBoutique app to GKE and making some configuration changes that have been recommended for cost optimization.

Here are some guidelines you’ve been requested to follow when deploying:

  • Create the cluster in the region
  • The naming scheme is team-resource, e.g. a cluster could be named
  • For your initial cluster, start with machine size

1. Create our cluster and deploy our app

  • The First Step is to activate the cloud shell and type the following command to set a Zone for Future use.
  • Creating a Cluster with only two (2) nodes.
  • Creating namespaces to separate resources on your cluster following the 2 environments — and .
  • Deploying the application to the namespace with the following command in cloud shell.
  • In the Cloud Shell Copy and Paste the code.
  • In the GCP Console go to Navigation Menu >Kubernets Engine> Service and Ingress.
  • You can see all the namespaces are created.

2.Migrate to an Optimized Nodepool

  • Creating a new node pool named optimized-pool with custom-2–3584 as the machine type and number of nodes to 2.
  • Migrating your application’s deployments to the new nodepool by cordoning off and draining .
  • Deleting the default-pool.
  • Write Y.

3. Apply a Frontend Update

  • Setting a pod disruption budget for your frontend deployment. Naming it online boutique-frontend-pdb and set the min-availability of your deployment to 1.
  • Edit your frontend deployment and change its image to the updated one.
  • Find the image under spec replace.
  • Then Press ctrl+x then Y enter.
  • And Put Always in image pull policy.
  • Checking all modules are in Running State.

4. Autoscale from Estimated Traffic

  • Updating your cluster autoscaler to scale between 1 node minimum and 6 nodes maximum.

Congratulations! Done with the challenge lab.

Stay tuned till the next blog

If you Want to Connect with Me:

Linkedin: https://www.linkedin.com/in/mayank-chourasia-38421a134/

Twitter: https://twitter.com/ChourasiaMayank.

Google Developers Google Cloud Qwiklabs Google News Lab Kubernetes Advocate

I am Google Cloud Certified Associate Cloud Engineer and MS Azure Certifed. I have been working on different fields including Cloud Computing , Sap ABAP.