What is Google Kubernetes Engine?
Kubernetes is an open-source, extensible, and portable platform for managing containerized workloads and services. But turns out, Kubernetes is not that simple to manage, from installation to provisioning, to upgrades, SLAs, and scaling. Here Google Kubernetes Engine (GKE) comes into the picture. Google Kubernetes Engine is a managed service for running Kubernetes. Apart from making it easy for you to create clusters, it offers some advanced cluster management features, including load balancing, auto-scaling, auto upgrades, auto repairs, logging, monitoring, and more.
All Kubernetes objects in your containerized app run on top of a cluster, which is the foundation of GKE. Using Google Kubernetes Engine for cluster creation can help you abstract the complexities of a Kubernetes implementation. But, it can cost a lot if you don’t follow the best practices of cloud cost management and monitoring practices. In this blog, we will discover how you can use GKE and how to optimize its cost.
Features & Benefits of GKE:
Before moving forward, let’s understand the benefits and use cases of Google Kubernetes Engine (GKE).
- Load Balancing: Load balancing for compute engine instance google cloud offers server-side load balancing so you can distribute incoming traffic across multiple virtual machine instances load balancer can scale your application to support heavy traffic detection and automatically remove unhealthy virtual machine instances using health checks and route traffic to the closest virtual machine this is a managed service which means its component is redundant and highly available so if a load balancing component fails it is restarted or replaced automatically and immediately.
- Auto Scaling: GKE’s cluster auto scaler automatically resizes the number of nodes in a given node pool based on the demand of your workloads you don’t need to manually add or remove nodes or overprovision your node pools instead you specify a minimum and maximum size for the node pool and the rest is automatic.
- Auto Upgrade: Auto updates will help you keep the nodes in your cluster up to date with the cluster control plane version when your control plane is updated with auto-update you don’t have to manually track and update your nodes when the control plane is updated on your behalf it also provides better security by automatically ensuring that security updates are applied and kept up to date with the latest Kubernetes features.
- Monitoring & Logging: Google Kubernetes Engine includes native integration with cloud monitoring and cloud logging when you create a gk cluster running on the google cloud operations for GKE is enabled by default and provides a monitoring dashboard specifically tailored for Kubernetes with cloud operations for GKE you can control whether or not cloud logging collects application logs you also have the option to disable the cloud monitoring and cloud logging integration altogether.
Getting started with GKE
To use Google Kubernetes Engine make sure you already have a GCP account, create your project, and make sure to enable the Artifact Registry and Google Kubernetes Engine APIs. And then open your Cloud Shell from Console and set the PROJECT_ID
environment variable.
To set PROJECT_ID
use command:
export PROJECT_ID=YOUR_PROJECT_ID
gcloud config set project $PROJECT_ID
Then create a repository with the following command, just make sure to choose your region (replace YOUR_REGION
) according to your convenience:
gcloud artifacts repositories create hello-repo \
--repository-format=docker \
--location=YOUR_REGION \
--description="Docker repository"
Now, download or create a source code and Dockerfile. Then build and tag the Docker image for hello-app
:
docker build -t YOUR_REGION-docker.pkg.dev/${PROJECT_ID}/hello-repo/hello-app:v1 .
Run docker images
command to verify that the build was successful:
Finally, let’s push the Docker image to Artifact Registry run these commands to configure and push the docker image to the repository:
gcloud auth configure-docker us-west1-docker.pkg.dev
docker push us-west1-docker.pkg.dev/${PROJECT_ID}/hello-repo/hello-app:v1
Understanding GKE Pricing:
Till here we understood how to use GKE now, let’s jump into its pricing.
Service | Description | Price (USD) |
---|---|---|
Cluster operation mode | Standard mode or Autopilot mode | $0.10 per cluster per hour |
Cluster management fees | The cluster management fee applies to all GKE clusters irrespective of the mode of operation, cluster size, or topology. | $0.10 per cluster per hour |
Multi-cluster ingress pricing | Multi-cluster ingress standalone pricing is based on the number of Pods considered Multi-Cluster Ingress backends. | $3.00 per backend Pod per month (730 hours) |
Google Kubernetes Engine Cost Optimization Strategies:
There are a handful of critical areas to practice cost optimization in a GKE environment. We’ll focus on three of these areas and how they fit into a monitoring system for cost optimization, specifically culture, bin packing, and app right-sizing.
- Culture: Teams who own GKE environments are not simply trying to drive down costs while ignoring everything else. They instead must balance cost-saving techniques while ensuring the applications running on GKE are still performant, stable, and continue to deliver value to their users. To effectively balance all of this, teams have begun incorporating cloud financial management, or FinOps, into their culture. This is the practice of building systems for financial accountability in the pay-as-you-go cloud world. Now, put this into the context of Kubernetes. The rapid adoption of Kubernetes in particular means that many teams are still learning and establishing their own best practices. This is true when it comes to managing the cost of running their clusters, especially as they grow. Continuous monitoring of these environments enables the necessary cultural shift. When teams have proper tuning and data at their disposal to practice cost optimization, the awareness shifts the discipline earlier in the software development lifecycle.
- Bin Packing: We want to focus on a cluster administrator-centric monitoring system. We can do so with a focus on cluster bin packing. Bin packing is the ability to effectively schedule workloads across nodes in a cluster, in such a way that ensures there are few wasted resources CPU and memory, for example. Efficient bin packing is achieved with a real-time understanding of how much resources workloads request, and how those workloads fit into the various amounts of allocatable resources that the VMs and the cluster have available. Cluster administrators, when empowered with the right monitoring data, can improve how they support cluster tenants, while also ensuring that provision infrastructure is not wasted. We can even set up alerting policies on the data collected for the most egregious cases of overprovisioning to proactively kick off the process of cost optimization.
- App Right-sizing: A monitoring system that captures recommendations for app right-sizing. This enables developers to better understand how much of the requested resources are actually being utilized by their application. With a deep understanding of scenarios where they may be overprovisioned in their workload requests, developers can make informed decisions on how they can easily reduce costs. Now that we’ve looked at the importance of culture, bin packing, and app right-sizing for GKE cost optimization, the next step is setting up the monitoring system.
Conclusion
The best long-term strategy is to establish a FinOps practice within your organization. Economize is committed to making your cloud spending simpler and noise-free to help engineering teams like yours understand and optimize it. Get started today with a personalized demo for your organization.