
Disclaimer: The code and configurations provided in this article are for educational purposes. GCP pricing, GKE features, and Antigravity features are subject to change. Always test agentic workflows in a non-production, sandboxed environment before granting cluster write permissions
In our previous posts, Enhancing GKE Operations with Gemini CLI and More GKE Operations with Gemini CLI, we looked at how natural language interfaces shift the way we interact with GKE, from an operations perspective. AI tooling that can intelligently query cluster health, surface logs, and explain complex error states on the fly can improve ways of operating and managing GKE clusters.
In this post I am going to explore this a bit further, by using Google’s Antigravity CLI and ADK to help me build an agent that will surface data from my clusters on the fly and build a GKE operational dashboard on demand. This dashboard will display information about Workload Right Sizing — which is an important lever in overall GKE cluster cost optimization.
This blog aims to expand on the previous blogs and showcase how AI agents and tools can be adopted into many aspects of GKE operations — in this case , for GKE cost optimization through workload rightsizing with VPA and resource usage analysis.
The focus is not on the structure or format of the resulting agent that has been built here, but more on the use case of AI in GKE operations.
Agent requirements
While I have an idea of how the end product could look, I know these kinds of projects of mine can get out of hand with feature upon feature. So to get going , I am going to build this agent with the following two main iterations:
- Bootstrap the agent and Gather the metrics data : From the current project, scrape GKE VPA and metrics data for applications in each GKE cluster in order to identify any over or under provisioned workloads. Recommend CPU and memory values for applications that are not sized optimally and output a potential savings of the new resource sizes were deployed. To make those deployments easier, generate Deployment or PodSpec files with the recommended CPU and Memory requests baked in.
- Check spot-vms use and Generate a Personalized Dashboard: From the gathered data, run a local web-based dashboard. This can be personalized over time
I am going to run these as sequential tasks in Antigravity CLI , as two different prompts, adding functionality with each revision.
Install Antigravity CLI
Detailed installation instructions are documented here: install Antigravity CLI. This installation gives you access to both the interactive Antigravity CLI and and the associated agents-cli shell command.
The installation for Linux looks like this:
(note — you then need to be authenticated to a google cloud project via the Google Cloud SDK)
# Install the agy CLI component
curl -fsSL https://antigravity.google/cli/install.sh | bash
# Google login
gcloud auth application-default login
# create workspace location
mkdir gke-rightsize-dash && cd gke-rightsize-dash
# Start the Antigravity environment inside your project directory
agy
This gives us our Antigravity CLI terminal:

Building the Agent
I will allow the commands to be processed when prompted by selecting “Yes, run command”, where I see no risk to the system, as follows:

Note — The below steps will show what I prompted to Antigravity, and the resulting files created as a result. These files or the contents may vary on different AI systems.
The files that make up this agent are located in this repo. The agent behaves as declared in the definition file at the end — agent.py, which can be used as the template for similar agents.
1. Grab the metrics data from VPA and Cloud metrics
For the first requirement I used the following prompt:
“Build an agent using Google ADK that helps rightsize workloads on GKE. It should look at VPA recommendations on our clusters in the current project, compare them with current CPU and memory requests, show potential savings where resources are underprovisioned, and output clean YAML manifests with the recommended sizes.”
After a while, the agent has been created , with the following output:

And the following guidance:

Looking at our generated workspace area we see the following file structure:

Where the key files are::
- ./gke_rightsize/agent.py — the Agent definition file, scaffolded by adk.
- ./gke_rightsize/metrics_collector.py — Collects VPA recommendations and resource metrics from Google Cloud Monitoring Logic interacting with kubectl to read VPA Custom Resource Definitions (CRDs).
- tests: contains the automated unit and integration test suite
- ./manifests — contains the updated deployment files with new resource sizing fields
The ./gke_rightsize/agent.py defines how our agent will act, having the specific instructions that define how this agent will work. Here is a snippet:

The resulting summary report shows all the information we requested around current and recommended CPU and memory resource request values and a OVER/UNDER provisioned status for easy viewing.

Ok, so far so good. We have an agent that can be run against our project and output really useful information. Let’s start the next phase and add a dashboard capability.
2. Adding some more Intelligence and show results in a web-based dashboard
For this requirement I used the following prompt:
“Flag if stateless workloads could run on Spot VMs, and Build an interactive web dashboard package to serve the results of this agent locally”
After accepting file changes and updates, we are presented with a dashboard that presents all the information I was after:

We have a summary of the overall potential savings with workload rightsizing, spot VM potential, and individual workload detail – with updated manifest files showing the new resource request sizes, an example of which is shown below:

What next for this agent?
We could extend this further extensions like
“Order the applications based on over-provisioned sizes”
“Configure such that multiple projects can be analysed together and group results based on project”
Whats Next
This blog shows a simple but valuable use case of how to use google AI tools in GKE operations. To try it out for yourself a
To find out more of how Google is deploying agentic AI to improve operations, have a look at the following article — AI in SRE
To get started on Antigravity, have a look at this codelab. This great article outlines the more detailed parameters and project design with Antigravity. For some more GKE operations hands-on guidance, have a look at this codelab that works through the steps of using Antigravity CLI and the Model Context Protocol (MCP) to troubleshoot a broken application on GKE.
On-Demand GKE Dashboards with Antigravity CLI — Workload Right-sizing was originally published in Google Cloud – Community on Medium, where people are continuing the conversation by highlighting and responding to this story.
Source Credit: https://medium.com/google-cloud/on-demand-gke-dashboards-with-antigravity-cli-workload-right-sizing-dfa81b0084f1?source=rss—-e52cf94d98af—4
