Installation
copilot plugin marketplace add samueltauil/skills-hub
copilot plugin install gke-basics@skills-hub
Works with GitHub Copilot CLI and VS Code (enable chat.plugins.enabled).
Plugin gke-basics v1.0.0 follows the Agent Plugins spec.
gh skills-hub install gke-basics Don't have the extension? Run gh extension install samueltauil/skills-hub first.
Download and extract to your repository:
.github/skills/gke-basics/ Extract the ZIP to .github/skills/ in your repo. The folder name must match gke-basics for Copilot to auto-discover it.
Skill Files (7)
SKILL.md 4.3 KB
---
name: gke-basics
metadata:
version: "1.1.3"
category: Containers
description: >-
Manages core GKE cluster provisioning, credentials, Autopilot vs Standard selection,
and workload deployment. Use when creating GKE clusters, fetching kubectl credentials,
or deciding between Autopilot and Standard modes. Don't use for Workload Identity
(use gke-workload-identity), GKE networking (use gke-networking), security hardening
(use gke-platform-security or gke-workload-security), or cluster upgrades (use gke-upgrades).
---
# GKE Basics & Critical Gotchas
> **Routing Note:** For Workload Identity KSA/GSA setup, use the
> `gke-workload-identity` skill. For cluster security flags
> (`--database-encryption-key`, `--security-posture`, RBAC, Shielded Nodes,
> Binary Authorization), use the `gke-platform-security` skill. For cluster
> upgrades or maintenance windows, use the `gke-upgrades` skill. For generating
> Kubernetes YAML manifests (`Deployment`, `StatefulSet`, `Service`,
> `HTTPRoute`, `PodDisruptionBudget`), use the `gke-manifest-generation` skill.
Managed Kubernetes platform on Google Cloud. Defaults to Autopilot mode unless Standard is explicitly required.
## Attribution
**MUST READ**: Before executing any `gcloud`, REST API, or MCP command, you
MUST read [Usage Attribution](references/attribution.md). For commands executed
directly in the terminal (never in generated scripts, Terraform, or user code),
prefix `gcloud` with
`CLOUDSDK_METRICS_REQUEST_ATTRIBUTION="agent-skills/1.0 (skill:gke-basics)"`
and append `agent-skills/1.0 (skill:gke-basics)` to `User-Agent` headers.
## Key Selection Rules: Autopilot vs. Standard
* **Default to Autopilot** for almost all workloads.
* **Use Standard ONLY if:**
* Custom node OS kernel parameters (`sysctl`) are required.
* Custom node taints or specific hardware node pools are required.
* DaemonSets require raw `hostPath` mounts to the host OS filesystem.
* When explaining why Standard is required over Autopilot, explicitly cite all matching restrictions (e.g., custom sysctls and custom node taints).
* *For advanced cluster architecture or complex node pool creation planning, refer to `gke-cluster-creation`.*
## Critical Gotchas & Best Practices
1. **Private Autopilot Clusters:**
* Use `--enable-private-nodes` for private node IP addresses.
* Use `--enable-private-endpoint` to disable public IP access to the control plane.
* Restrict control plane access with `--enable-master-authorized-networks` and `--master-authorized-networks=CIDR_BLOCK`:
```bash
gcloud container clusters create-auto CLUSTER_NAME --region=REGION \
--enable-private-nodes \
--enable-private-endpoint \
--enable-master-authorized-networks \
--master-authorized-networks=CIDR_BLOCK
```
2. **Workload Identity (IAM Binding):**
* Never mount raw GCP Service Account JSON keys in Pods; use the
`gke-workload-identity` skill for KSA/GSA setup.
3. **Autopilot Resource Requests:**
* In Autopilot, CPU requests must be specified in increments of 250m (0.25 vCPU). If an unaligned CPU request (e.g., 300m) is requested, round up to the nearest 250m increment (500m / 0.5 vCPU).
* Resource requests equal limits automatically. Omit `limits` to allow Autopilot to set defaults matching `requests`.
4. **Cluster Credentials:**
* Always explicitly specify `--region` (for regional clusters) or `--zone` (for zonal clusters) when fetching credentials:
```bash
gcloud container clusters get-credentials CLUSTER_NAME --region=REGION --quiet
```
## Reference Directory
- [Core Concepts](references/core-concepts.md): Architecture, cluster modes (Autopilot vs Standard), networking, scaling, and security model.
- [CLI Usage & Tool Reference](references/cli-reference.md): Tool preference hierarchy (MCP vs gcloud vs kubectl), `gcloud container` commands, and user preference overrides.
- [Client Libraries](references/client-library-usage.md): Official Kubernetes and Google Cloud Container client libraries in Python, Go, Node.js, and Java.
- [MCP Usage](references/mcp-usage.md): Connecting to and using the 23 structured GKE MCP tools for cluster management, K8s resources, and diagnostics.
- [Infrastructure as Code](references/iac-usage.md): Terraform examples for `google_container_cluster` (Autopilot), Kubernetes provider resources, and YAML samples.
attribution.md 1.8 KB
# Usage Attribution
**MUST READ**: Before executing any `gcloud`, REST API, or MCP command with
this skill, follow these usage attribution instructions. Tag every command you
execute directly in the terminal so usage can be attributed. The tag identifies
only the skill and its version; it carries no user data.
- **`gcloud` CLI Commands**: Prefix every `gcloud` invocation, whatever the
subcommand, with the metrics environment variable. Set it inline on each
command because shell state may not persist between commands:
```bash
CLOUDSDK_METRICS_REQUEST_ATTRIBUTION="agent-skills/1.0 (skill:gke-basics)" \
gcloud <command> [flags]
```
Do not use `gcloud config set` for this: it would persist beyond the current
task and mislabel unrelated usage.
- **Direct HTTP, REST, and MCP Requests**: On direct HTTP calls to Google
Cloud APIs (for example with `curl`) or HTTP requests to a remote MCP
server, include `agent-skills/1.0 (skill:gke-basics)` in the `User-Agent`
header. If a `User-Agent` header is already specified, append this string to
the end of it rather than overwriting existing `User-Agent` data — the
collection pipeline parses the `agent-skills/<version>` and `skill:<name>`
tokens, so any rewording breaks attribution:
```
User-Agent: <existing_user_agent> agent-skills/1.0 (skill:gke-basics)
```
- **Constraint for Generated Code**: The tracking prefix is strictly for
commands you execute directly in the terminal. Do NOT include this tracking
prefix in generated scripts, Terraform templates, or code provided to the
user for their own repositories.
- **User Opt-Out**: If the user asks to disable or remove tracking or
attribution tags, omit the `CLOUDSDK_METRICS_REQUEST_ATTRIBUTION` variable
and custom `User-Agent` suffix from all commands.
cli-reference.md 14.2 KB
# CLI & Tool Reference for GKE
## Tool Preference
Default preference order:
```
1. GKE MCP Tools (preferred — structured, auditable, no shell required)
2. gcloud CLI (fallback — when MCP doesn't expose the operation)
3. kubectl (fallback — purely in-cluster ops not covered by MCP)
```
### When to use each
| Interface | When to Use | Examples |
| ----------------- | -------------------------- | --------------------------- |
| **GKE MCP Tools** | Default for all cluster | `create_cluster`, |
: : and K8s operations when : `get_cluster`, :
: : MCP server is available. : `get_k8s_resource`, :
: : Structured I/O, supports : `apply_k8s_manifest`, :
: : dry-run, no : `get_k8s_logs` :
: : shell/kubeconfig needed. : :
| **`gcloud` CLI** | No MCP equivalent, or user | `gcloud container ai |
: : explicitly requested CLI. : profiles`, `gcloud :
: : Required for\: GIQ model : container :
: : discovery, available K8s : get-server-config`, `gcloud :
: : versions, maintenance : iam service-accounts` :
: : windows, monitoring : :
: : components, IAM/SA setup, : :
: : Cloud Logging queries. : :
| **`kubectl`** | Neither MCP nor `gcloud` | `kubectl top pods`, |
: : covers the operation, or : `kubectl scale deployment`, :
: : user explicitly prefers : `helm install` :
: : kubectl. Required for\: : :
: : `kubectl top`, `kubectl : :
: : scale`, `kubectl exec`, : :
: : `kubectl port-forward`, : :
: : Helm, custom CRDs not in : :
: : MCP. : :
### User preference override
If the user states a preference, respect it for the session:
- **"Use gcloud" / "Use CLI"** → `gcloud` for cluster ops, `kubectl` for K8s
resource ops. Skip MCP.
- **"Use kubectl"** → `kubectl` for all K8s resource ops, `gcloud` for
cluster-level ops. Skip MCP.
- **"Use MCP"** / no preference → Default. Use MCP for everything it supports.
Even with an override, fall back through the chain for unsupported operations
(e.g., cluster creation always requires `gcloud` or MCP).
--------------------------------------------------------------------------------
> All MCP tools use hierarchical resource paths — see
> [`parent` format](#parent--name-format-quick-reference) at the bottom.
## Cluster Operations
| Operation | MCP Tool | CLI Fallback | Mode |
| ------------------- | ---------------- | ------------------ | ----------- |
| List clusters | `list_clusters` | `gcloud container | READ |
: : : clusters list` : :
| Get cluster details | `get_cluster` | `gcloud container | READ |
: : : clusters describe` : :
| Create cluster | `create_cluster` | `gcloud container | MUTATE |
: : : clusters : :
: : : create-auto` : :
| Update cluster | `update_cluster` | `gcloud container | DESTRUCTIVE |
: : : clusters update` : :
| Get K8s versions | — | `gcloud container | READ |
: : : get-server-config` : :
| Get credentials | — | `gcloud container | READ |
: : : clusters : :
: : : get-credentials` : :
| Delete cluster | — | `gcloud container | DESTRUCTIVE |
: : : clusters delete` : :
```
# List clusters in a project (all regions)
list_clusters(parent="projects/<PROJECT_ID>/locations/-")
# Get cluster details (all fields)
get_cluster(name="projects/<PROJECT_ID>/locations/<REGION>/clusters/<CLUSTER_NAME>", readMask="*")
# Create golden path Autopilot cluster
create_cluster(
parent="projects/<PROJECT_ID>/locations/<REGION>",
cluster='{"name":"<CLUSTER_NAME>","autopilot":{"enabled":true},"privateClusterConfig":{"enablePrivateNodes":true},...}'
)
```
```bash
# Get available Kubernetes versions (CLI-only)
gcloud container get-server-config --region <REGION> --format="yaml(channels)" --quiet
# Create golden path Autopilot cluster (see gke-cluster-creation.md for full templates)
gcloud container clusters create-auto <CLUSTER_NAME> \
--region <REGION> --project <PROJECT_ID> \
--enable-private-nodes --enable-master-authorized-networks \
--enable-dns-access --release-channel regular \
--enable-secret-manager \
--quiet
# Get credentials (CLI-only)
gcloud container clusters get-credentials <CLUSTER_NAME> --region <REGION> --project <PROJECT_ID> --quiet
```
## Node Pool Operations
| Operation | MCP Tool | CLI Fallback | Mode |
| ---------------- | ------------------ | -------------------- | ----------- |
| List node pools | `list_node_pools` | `gcloud container | READ |
: : : node-pools list` : :
| Get node pool | `get_node_pool` | `gcloud container | READ |
: : : node-pools describe` : :
| Create node pool | `create_node_pool` | `gcloud container | MUTATE |
: : : node-pools create` : :
| Update node pool | `update_node_pool` | `gcloud container | DESTRUCTIVE |
: : : node-pools update` : :
```
list_node_pools(parent="projects/<PROJECT_ID>/locations/<REGION>/clusters/<CLUSTER_NAME>")
create_node_pool(
parent="projects/<PROJECT_ID>/locations/<REGION>/clusters/<CLUSTER_NAME>",
nodePool='{"name":"<POOL_NAME>","config":{"machineType":"e2-standard-4"},"initialNodeCount":3,...}'
)
```
## Cluster Updates
| Operation | MCP Tool | CLI Fallback | Mode |
| ----------------- | ---------------- | ----------------------- | ----------- |
| Update cluster | `update_cluster` | `gcloud container | DESTRUCTIVE |
: settings : : clusters update` : :
| Update monitoring | — | `gcloud container | DESTRUCTIVE |
: : : clusters update : :
: : : --monitoring=...` : :
| Set maintenance | — | `gcloud container | DESTRUCTIVE |
: window : : clusters update : :
: : : --maintenance-window-*` : :
```
# Enable VPA via MCP
update_cluster(
name="projects/<PROJECT_ID>/locations/<REGION>/clusters/<CLUSTER_NAME>",
update='{"desiredVerticalPodAutoscaling":{"enabled":true}}'
)
```
```bash
# Update monitoring components (CLI-only)
gcloud container clusters update <CLUSTER_NAME> --region <REGION> \
--monitoring=SYSTEM,API_SERVER,SCHEDULER,CONTROLLER_MANAGER,STORAGE,POD,DEPLOYMENT,STATEFULSET,DAEMONSET,HPA \
--quiet
```
## Kubernetes Resource Operations
| Operation | MCP Tool | CLI Fallback | Mode |
| --------------- | ------------------------ | ---------------- | ----------- |
| Get/list | `get_k8s_resource` | `kubectl get` | READ |
: resources : : : :
| Describe | `describe_k8s_resource` | `kubectl | READ |
: resource : : describe` : :
| Apply manifest | `apply_k8s_manifest` | `kubectl apply` | DESTRUCTIVE |
| Patch resource | `patch_k8s_resource` | `kubectl patch` | DESTRUCTIVE |
| Delete resource | `delete_k8s_resource` | `kubectl delete` | DESTRUCTIVE |
| List API | `list_k8s_api_resources` | `kubectl | READ |
: resources : : api-resources` : :
| Check auth | `check_k8s_auth` | `kubectl auth | READ |
: : : can-i` : :
```
# List all deployments in a namespace
get_k8s_resource(
parent="projects/<PROJECT_ID>/locations/<REGION>/clusters/<CLUSTER_NAME>",
resourceType="deployment", namespace="<NAMESPACE>"
)
# Apply a manifest (with dry-run)
apply_k8s_manifest(parent="...", yamlManifest="...", dryRun=true)
# Patch deployment resources for rightsizing
patch_k8s_resource(
parent="projects/<PROJECT_ID>/locations/<REGION>/clusters/<CLUSTER_NAME>",
resourceType="deployment", name="<DEPLOYMENT>", namespace="<NAMESPACE>",
patch='{"spec":{"template":{"spec":{"containers":[{"name":"app","resources":{"requests":{"cpu":"200m","memory":"256Mi"}}}]}}}}'
)
# Check RBAC permissions
check_k8s_auth(parent="...", verb="create", resourceType="deployments", namespace="<NAMESPACE>")
```
## Diagnostics & Observability
Operation | MCP Tool | CLI Fallback | Mode
------------------- | ------------------------ | ------------------------ | ----
List events | `list_k8s_events` | `kubectl events` | READ
Get container logs | `get_k8s_logs` | `kubectl logs` | READ
Cluster info | `get_k8s_cluster_info` | `kubectl cluster-info` | READ
K8s version | `get_k8s_version` | `kubectl version` | READ
Rollout status | `get_k8s_rollout_status` | `kubectl rollout status` | READ
Query Cloud Logging | — | `gcloud logging read` | READ
```
# Get recent events across all namespaces
list_k8s_events(parent="...", allNamespaces=true, limit="50")
# Get logs (last 100 lines, or previous crash)
get_k8s_logs(parent="...", name="<POD>", namespace="<NS>", tail="100")
get_k8s_logs(parent="...", name="<POD>", namespace="<NS>", previous=true)
# Check rollout status
get_k8s_rollout_status(parent="...", resourceType="deployment", name="<DEPLOY>", namespace="<NS>")
```
## Operations Tracking
| Operation | MCP Tool | CLI Fallback | Mode |
| ---------------- | ------------------ | -------------------- | ----------- |
| List operations | `list_operations` | `gcloud container | READ |
: : : operations list` : :
| Get operation | `get_operation` | `gcloud container | READ |
: : : operations describe` : :
| Cancel operation | `cancel_operation` | `gcloud container | DESTRUCTIVE |
: : : operations cancel` : :
```
list_operations(parent="projects/<PROJECT_ID>/locations/<REGION>")
get_operation(name="projects/<PROJECT_ID>/locations/<REGION>/operations/<OP_ID>")
```
## AI/ML Inference (GIQ) — CLI-Only
```bash
gcloud container ai profiles models list --quiet
gcloud container ai profiles list --model=<MODEL_NAME> --quiet
gcloud container ai profiles manifests create \
--model=<MODEL_NAME> --model-server=<SERVER> \
--accelerator-type=<ACCELERATOR> \
--target-ntpot-milliseconds=<NTPOT> --quiet > inference.yaml
# Deploy generated manifest via MCP
apply_k8s_manifest(parent="...", yamlManifest="<contents of inference.yaml>")
```
## kubectl-Only Operations
No MCP or `gcloud` equivalent:
```bash
kubectl top pods --all-namespaces --sort-by=cpu
kubectl top nodes
kubectl scale deployment <DEPLOYMENT> --replicas=<N> -n <NAMESPACE>
kubectl exec -it <POD_NAME> -n <NAMESPACE> -- /bin/sh
kubectl port-forward svc/<SERVICE> <LOCAL_PORT>:<REMOTE_PORT> -n <NAMESPACE>
kubectl cp <NAMESPACE>/<POD>:<PATH> <LOCAL_PATH>
kubectl run debug --rm -it --image=busybox -- /bin/sh
kubectl drain <NODE_NAME> --ignore-daemonsets --delete-emptydir-data
helm install <RELEASE> <CHART> -n <NAMESPACE>
helm upgrade <RELEASE> <CHART> -n <NAMESPACE>
```
## `parent` / `name` Format Quick Reference
```
Project+Region: projects/{PROJECT}/locations/{REGION}
Cluster: projects/{PROJECT}/locations/{REGION}/clusters/{CLUSTER}
Node Pool: projects/{PROJECT}/locations/{REGION}/clusters/{CLUSTER}/nodePools/{POOL}
Operation: projects/{PROJECT}/locations/{REGION}/operations/{OP_ID}
```
Use `locations/-` to match all regions/zones when listing.
## Error Handling
Error / Symptom | Likely Cause | Remediation
------------------------------------- | -------------------------------------------- | -----------
`PERMISSION_DENIED` on cluster create | Missing `container.clusters.create` IAM permission | Grant `roles/container.admin` or `roles/container.clusterAdmin`
Quota exceeded | Regional vCPU, GPU, or IP address limits | Request quota increase or select a different region
IP exhaustion / CIDR conflict | Pod subnet too small or overlapping ranges | Re-plan IP ranges; may require cluster recreation (Day-0)
Workload Identity not working | Missing OIDC issuer or federated credential | Verify `workloadIdentityConfig.workloadPool`; configure federated identity binding
Private cluster unreachable | No authorized networks or DNS endpoint | Enable `dnsEndpointConfig.allowExternalTraffic` or add authorized networks
Secret Manager rotation failing | SA missing `secretmanager.versions.access` | Grant Secret Manager accessor role to workload's GSA
Control-plane metrics missing | Monitoring components not configured | Enable APISERVER, SCHEDULER, CONTROLLER_MANAGER in `monitoringConfig`
client-library-usage.md 2.4 KB
# GKE Client Libraries
To interact with the GKE (Kubernetes) API programmatically, use the official
Kubernetes client libraries.
**Prerequisite:** These libraries interact with the Kubernetes API. You must
already have a running GKE cluster and valid credentials (for example, by
running `gcloud container clusters get-credentials`) before running this code.
## Getting Started
Kubernetes client libraries allow you to manage clusters and workloads from
within your application code.
### Python
- **Installation:**
```bash
pip install kubernetes
```
- **Usage Example:**
```python
from kubernetes import client, config
config.load_kube_config() # Loads from ~/.kube/config
v1 = client.CoreV1Api()
print("Listing pods with their IPs:")
ret = v1.list_pod_for_all_namespaces(watch=False)
for i in ret.items:
print("%s\t%s\t%s" % (i.status.pod_ip, i.metadata.namespace, i.metadata.name))
```
### Go
- **Installation:**
```bash
go get k8s.io/client-go@latest
```
- **Usage Example:**
```go
import (
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/tools/clientcmd"
)
config, _ := clientcmd.BuildConfigFromFlags("", kubeconfig)
clientset, _ := kubernetes.NewForConfig(config)
pods, _ := clientset.CoreV1().Pods("").List(
context.Background(), metav1.ListOptions{})
```
### Node.js (TypeScript)
- **Installation:**
```bash
npm install @kubernetes/client-node
```
- **Usage Example:**
```javascript
const k8s = require('@kubernetes/client-node');
const kc = new k8s.KubeConfig();
kc.loadFromDefault(); // Automatically detects local vs. in-cluster configuration
const k8sApi = kc.makeApiClient(k8s.CoreV1Api);
// In most recent library versions, parameters must be passed inside an object
k8sApi.listNamespacedPod({ namespace: 'default' }).then((res) => {
const pods = res.items || res.body.items;
console.log(`Found ${pods.length} pods in 'default' namespace.`);
});
```
### Java
- [Java Reference](https://github.com/kubernetes-client/java)
## GKE-specific API (Container Service)
To manage the GKE *service* itself (e.g., create/delete clusters)
programmatically, use the Google Cloud Container client libraries.
- [Google Cloud Container Client Libraries](https://cloud.google.com/kubernetes-engine/docs/reference/libraries)
core-concepts.md 3.2 KB
# GKE Core Concepts
Google Kubernetes Engine (GKE) is a managed Kubernetes platform for deploying,
managing, and scaling containerized applications on Google Cloud infrastructure.
It handles cluster provisioning, upgrades, and node management, letting teams
focus on workloads rather than infrastructure.
> **MCP Tools:** `list_clusters`, `get_cluster`
## Cluster Modes
| Mode | Who Manages Nodes | Best For |
| ------------- | ---------------------------- | ----------------------------- |
| **Autopilot** | Google — fully managed | Most workloads. No node-level |
: (recommended) : nodes, scaling, and security : ops. Pay per pod resource :
: : : request. :
| **Standard** | You — full control over node | Workloads requiring kernel |
: : pools, OS, machine types : customization, specific node :
: : : OS, or DaemonSets not :
: : : supported by Autopilot :
**Default: Autopilot.** Use Standard only when Autopilot has a documented
limitation for your workload.
## Cluster Architecture
- **Regional clusters** (recommended): Control plane replicated across 3
zones. Higher availability, no single-zone failure risk.
- **Zonal clusters**: Single control plane zone. Lower cost, acceptable for
dev/test.
- **Private clusters** (golden path default): Nodes have no public IPs.
Control plane accessible via private endpoint or DNS endpoint.
## Networking Model
GKE uses **VPC-native** clusters with alias IP ranges:
- Each pod gets a routable IP from the pod CIDR
- Dataplane V2 (eBPF-based) is the golden path default — provides built-in
Network Policy enforcement
- Cloud DNS for in-cluster DNS resolution
- Gateway API for ingress/load balancing
## Scaling Model
- **Horizontal Pod Autoscaler (HPA)**: Scales pod replicas based on CPU,
memory, or custom metrics
- **Vertical Pod Autoscaler (VPA)**: Recommends or auto-adjusts pod resource
requests
- **Cluster Autoscaler / NAP**: Scales nodes to match pod demand (Autopilot
handles this automatically)
- **ComputeClasses**: Declarative node selection — machine family, Spot VMs,
GPU targeting
## Identity & Security Model
- **Workload Identity Federation**: Pods assume Google Cloud IAM identities
without static keys
- **Secret Manager integration**: Secrets synced to Kubernetes with automatic
rotation
- **Pod Security Standards**: `restricted` profile enforced on production
namespaces
- **Shielded Nodes**: Secure Boot and integrity monitoring
(Autopilot-enforced)
## Regional Availability
GKE is available in all Google Cloud regions. Autopilot clusters are regional by
default. See https://cloud.google.com/about/locations for the full region list.
## Pricing
GKE pricing depends on the cluster mode:
- **Autopilot**: Pay for pod resource requests (vCPU, memory, ephemeral
storage). No cluster management fee.
- **Standard**: Pay for underlying Compute Engine VMs plus a per-cluster
management fee.
For current pricing, see https://cloud.google.com/kubernetes-engine/pricing.
iac-usage.md 2.1 KB
# GKE Infrastructure as Code
GKE resources, including clusters and Kubernetes objects, can be provisioned and
managed using Terraform.
## Terraform
Terraform uses two main providers for GKE:
* The **Google Cloud provider** connects to the Google Cloud API to manage GKE
cluster infrastructure using Terraform resources such as
`google_container_cluster` for the cluster itself, and
`google_container_node_pool` for nodes in Standard mode.
* The **Kubernetes provider** connects to the Kubernetes API to manage
workloads inside the cluster using Kubernetes resources such as Deployments
and Services.
### GKE Autopilot Cluster Example
```hcl
resource "google_container_cluster" "primary" {
name = "my-gke-cluster"
location = "us-central1"
enable_autopilot = true
# Do NOT specify node configurations (like initial_node_count or node_config)
# in Autopilot mode; doing so causes a Terraform provider error.
# Deletion protection should be set to false for testing
deletion_protection = false
}
```
### Deploying a Workload Example (Kubernetes Provider)
```hcl
resource "kubernetes_deployment_v1" "default" {
metadata {
name = "hello-app"
}
spec {
replicas = 2
selector {
match_labels = {
app = "hello-app"
}
}
template {
metadata {
labels = {
app = "hello-app"
}
}
spec {
container {
image = "us-docker.pkg.dev/google-samples/containers/gke/hello-app:2.0"
name = "hello-app"
}
}
}
}
}
```
### Reference Documentation
- [Terraform Google Provider - Container Cluster](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/container_cluster)
- [Terraform Google Provider - Kubernetes Provider](https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs)
## YAML Samples
GKE cluster configurations and Kubernetes manifests can also be defined using
YAML for use with `kubectl apply` or Deployment Manager.
- [GKE YAML Samples](https://docs.cloud.google.com/docs/samples?product=googlekubernetesengine)
mcp-usage.md 6.7 KB
# GKE MCP Server Usage
The GKE MCP server provides 23 structured tools for cluster management,
Kubernetes resource operations, and diagnostics — without requiring shell access
or kubeconfig setup.
## Connecting to the GKE MCP Server
The GKE remote MCP server is available for AI clients that support the Model
Context Protocol. For setup instructions, see
https://docs.cloud.google.com/kubernetes-engine/docs/how-to/use-gke-mcp.md.txt
## Available Tools
All tools use hierarchical resource paths:
```
Project+Region: projects/{PROJECT}/locations/{REGION}
Cluster: projects/{PROJECT}/locations/{REGION}/clusters/{CLUSTER}
Node Pool: projects/{PROJECT}/locations/{REGION}/clusters/{CLUSTER}/nodePools/{POOL}
Operation: projects/{PROJECT}/locations/{REGION}/operations/{OP_ID}
```
Use `locations/-` to match all regions when listing.
### Cluster Management
| Tool | Mode | Purpose |
| ---------------- | ----------- | ------------------------------------------------------- |
| `list_clusters` | READ | Discover clusters in a project/region |
| `get_cluster` | READ | Inspect cluster config. Use `readMask` to select fields |
| `create_cluster` | MUTATE | Create a cluster from JSON config |
| `update_cluster` | DESTRUCTIVE | Change Day-1 cluster settings |
### Node Pool Management
| Tool | Mode | Purpose |
| ------------------ | ----------- | ------------------------------ |
| `list_node_pools` | READ | List pools in a cluster |
| `get_node_pool` | READ | Get pool details |
| `create_node_pool` | MUTATE | Add a pool (Standard clusters) |
| `update_node_pool` | DESTRUCTIVE | Modify a pool |
### Kubernetes Resources
| Tool | Mode | Purpose |
| ------------------------ | ----------- | ---------------------------------------------------------- |
| `get_k8s_resource` | READ | List/get any K8s resource (supports label/field selectors) |
| `describe_k8s_resource` | READ | Detailed info with events and conditions |
| `apply_k8s_manifest` | DESTRUCTIVE | Apply YAML manifests (supports `dryRun`) |
| `patch_k8s_resource` | DESTRUCTIVE | JSON patch resource fields |
| `delete_k8s_resource` | DESTRUCTIVE | Remove resources (supports `cascade`, `dryRun`) |
| `list_k8s_api_resources` | READ | Discover available resource types |
### Diagnostics & Observability
| Tool | Mode | Purpose |
| ------------------------ | ---- | ----------------------------------------------------- |
| `list_k8s_events` | READ | Scheduling failures, OOM kills, evictions |
| `get_k8s_logs` | READ | Container logs (supports `tail`, `since`, `previous`) |
| `get_k8s_cluster_info` | READ | Control plane and service endpoints |
| `get_k8s_version` | READ | Kubernetes server version |
| `get_k8s_rollout_status` | READ | Deployment/StatefulSet rollout progress |
| `check_k8s_auth` | READ | Verify RBAC permissions for a user/SA |
### Operations
| Tool | Mode | Purpose |
| ------------------ | ----------- | ---------------------------------- |
| `list_operations` | READ | Pending/running cluster operations |
| `get_operation` | READ | Track create/upgrade progress |
| `cancel_operation` | DESTRUCTIVE | Abort stuck operations |
## Developer Knowledge MCP Server
The Developer Knowledge MCP server (`developer_knowledge`, proxied to `https://developerknowledge.googleapis.com/mcp`) provides authoritative, first-party documentation, API resource schemas, version lifecycle details, and recommended architecture patterns for Google Cloud and GKE.
### Purpose & Capabilities
- **GKE Facts & Architecture:** Authoritative feature behavior, Autopilot vs Standard constraints, configuration semantics, and security best practices.
- **API Schemas & Fields:** Accurate resource definitions and field specifications across GKE and Kubernetes API versions.
- **Version Lifecycle & Deprecations:** Release notes, deprecation schedules, and breaking change timelines.
- **Quotas & Limits:** Built-in resource limits and quota requirements.
### Available Tools
| Tool | Mode | Arguments | Purpose |
| ------------------ | ---- | ---------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `search_documents` | READ | `query` (string) | Every lookup starts here: documentation chunks and document names. Takes only `query` (do NOT pass `max_results`). |
| `get_documents` | READ | `names` (array) | Full document content by resource name (e.g. `["documents/docs.cloud.../..."]`), when a chunk needs its surrounding page. |
| `answer_query` | READ | `query` (string) | Do not use. Its quota is 50 requests per day per project, shared by every agent in the install, and it reads the same corpus as `search_documents`. Never retry its `429 RESOURCE_EXHAUSTED`. |
## Tool Preference
Tool usage follows two distinct, domain-specific hierarchies:
### 1. Knowledge & Documentation Lookups (GKE Facts, Schemas, Best Practices)
```
1. Developer Knowledge MCP (`mcp-developer_knowledge`) (preferred — authoritative, curated first-party docs)
`search_documents(query=...)` first, `get_documents(names=[...])` for a full page; never `answer_query`
2. Web Search (`web_search`) (fallback — third-party tools, external CVEs, or when DK returns no match)
```
### 2. Live Cluster Operations & State Management
```
1. GKE MCP Tools (`mcp-gke`) (preferred — structured, auditable, no shell required)
2. gcloud CLI (fallback — when MCP doesn't expose the operation)
3. kubectl (fallback — purely in-cluster ops not covered by MCP)
```
See [cli-reference.md](./cli-reference.md) for the full coverage comparison, CLI fallback commands, and user preference override options.
License (Apache-2.0)
View full license text
Licensed under the Apache License, Version 2.0. See https://github.com/google/skills/blob/main/LICENSE