Kubernetes is one of the most popular container orchestration platforms for automated deployment, management and scaling. Google Kubernetes Engine (GKE) simplifies the process of cluster creation and management at a high level. GKE makes use of the underlying Google cloud platform architecture to abstract the implementation of a Kubernetes cluster.
But how do you track usage metering to analyze the usage and costs of your cluster’s workload? GKE usage metering thus becomes a necessary factor to consider while determining resource consumption, workload identification and tracking resource requests.
In this blog, we will discover how you can enable GKE metering through the Google cloud platform and get started with your analysis.
Configuring GKE usage metering
We would also create a BigQuery data-set for either a single cluster or multiple clusters in the project or even the entire project. The data-set holds the GKE usage metering data information for one or more projects. While creating a data-set you can trade-off between administration simplification or granular access.
Furthermore, enable GKE usage metering while creating a new cluster or by modifying an existing cluster. You can optionally create a Google Data Studio dashboard to visualize the resource usage of your clusters. While creating the dashboard with Google’s initial beta template, make sure to create a new dashboard to visualize actual resource consumption.
Creating the BigQuery data-set
Before enabling the GKE usage metering, we would be creating the BigQuery data-sets as part of the project and configure clusters to use the same. We can use a single BigQuery data-set to store information for multiple clusters as part of the same project. You can visit creating data-sets for more information on configuring the same.
We will also ensure that the
default table expiration for the data-set is set to
Never so that the table doesn’t expire. However, if a table expires in the second GKE usage metering Beta, it is automatically recreated as an empty table.
The BigQuery data-set provided via the Google service account (service-PROJECT_ID@container-engine-robot.iam.gserviceaccount.com) and with the Kubernetes Engine Service Agent role, is written to. When a BigQuery data-set or table, being used to log the GKE usage metering data, is accidentally deleted, we will get a warning stating Failed to upload a record to BigQuery from Cloud logging. We can re-create the data-set or configure the cluster to use a different data-set. However, the historical data would be lost.
Enabling GKE usage metering
The GKE usage metering can be enabled, either via the Cloud console or the
gcloud command. While enabling the GKE usage metering, the resource consumption metering is enabled while the network egress metering is disabled by default.
While using the Google cloud console, it is not possible to enable GKE usage metering while selectively disabling resource consumption metering. We must use
gcloud to achieve the same.
A new cluster can be created using the Google cloud console. You can optionally configure an existing cluster. To create or configure a cluster with GKE usage metering enabled, follow these steps:
- Go to the Google Kubernetes Engine page in Cloud Console.
- If an existing cluster is being configured, scroll to the cluster you wish to modify and click Actions and then click Edit.
- If you are creating a new cluster, scroll to the navigation pane, and under the Cluster, click Features. If an existing cluster is being configured, navigate under Features, and click Edit next to the GKE usage metering.
- Select Enable GKE usage metering. While configuring an existing cluster, enter the name of the BigQuery data-set. This also works for GKE Autopilot.
- Optional: Select Enable network egress metering after reviewing the instructions in Optional: Enabling network egress metering.
- Configure the rest of the steps as per the requirements, and click Create. While configuring an existing cluster, click Save changes.
GKE cost breakdown with Economize
We can now analyze the cluster, SKU and namespace wise breakdown of our GKE costs on Economize. You can group them using label keys and drag and drop columns to display. It gives you greater flexibility to analyze your Kubernetes cost breakdown directly through your cluster and nodes list.