Gke manifest generation

From google/skills · View interactive version

Gke manifest generation is an AI agent skill from the GitHub repository google/skills. Generates and updates secure, production-ready Kubernetes YAML manifests optimized for GKE Autopilot and GKE Standard clusters. Use when creating or modifying GKE deployment manifests, configuring container security contexts, setting CPU/memory resource limits, defining readiness/liveness/startup pr

How to use this skill

Skill file

GKE Manifest Generation Skill

This skill provides guidelines, tooling integration, and templates to translate

natural language descriptions or application code changes into secure,

compliant, and cost-effective Kubernetes YAML manifests optimized for both GKE

Autopilot and GKE Standard clusters.

Attribution

MUST READ: Before executing any gcloud, REST API, or MCP command, you

MUST read Usage Attribution. 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-manifest-generation)"

and append agent-skills/1.0 (skill:gke-manifest-generation) to User-Agent

headers.

Core Rules & Verification

When generating or updating YAML manifests, you must strictly adhere to the

following rules:

1. Namespace & Resource Isolation

in the metadata of every resource (Deployments, Services, ConfigMaps,

Secrets, PVCs, Roles, bindings). Map it to the namespace configured in your

active SETTINGS.md. Never omit the namespace.

ServiceAccount. Always create and reference a dedicated ServiceAccount

(e.g., devteam-agent-sa) for each microservice.

2. GKE Resource Tuning (Autopilot & Standard)

limits for all containers.

limits must be equal. If they differ, Autopilot will automatically scale

requests up to match limits, which can significantly increase costs.

limits prevent resource starvation/noisy-neighbor issues.

default to conservative requests (e.g., requests.cpu: "100m" or "200m",

requests.memory: "256Mi" or "512Mi") with burstable limits. Use a

reasonable overcommit ratio for limits (e.g., 2x to 4x requests, like

limits.cpu: "400m" to "800m", and limits.memory: "512Mi" to "1Gi").

Avoid excessive overcommit limits (like limits.cpu: "4" for a 100m

request) to prevent severe CPU throttling and latency degradation under

heavy scheduling load, particularly in environments without guaranteed node

shares.

containing -test, -dev, or -staging), or if the user requests cost

optimization, automatically target GKE Spot VMs. This requires injecting

both the nodeSelector targeting Spot VMs AND the corresponding toleration

to tolerate the Spot VM taint:

```yaml

nodeSelector:

cloud.google.com/gke-spot: "true"

tolerations:

operator: "Equal"

value: "true"

effect: "NoSchedule"

```

(On GKE Standard, this assumes a Spot node pool is configured).

3. Container Security Hardening (Pod Security Standards)

(and container level if overriding) to run as a non-root user (e.g.,

runAsNonRoot: true, runAsUser: 10000, runAsGroup: 10000, `fsGroup:

10000`). This is strictly enforced on GKE Autopilot and is a critical

security baseline for GKE Standard.

seccompProfile: {type: RuntimeDefault}.

modifications to the container image filesystem.

mount a local emptyDir volume to /tmp or /var/run/ to allow

applications (like Java/Nginx) to write temp files without crashing.

(configured in the volumes spec with defaultMode: 0400) instead of

mapping them as environment variables, unless the application framework

exclusively supports env-var based configuration. This prevents secrets

leaking into application logs.

4. Health Checking (Mandatory Probes)

livenessProbe and readinessProbe.

exec.command: ["redis-cli", "ping"]).

times (e.g., Java spring boot, complex Python scripts, LLM model servers),

you must also define a startupProbe. When a startupProbe is defined,

the liveness and readiness probes are disabled until it succeeds, preventing

Kubernetes from prematurely killing the pod during startup:

```yaml

startupProbe:

httpGet:

path: /healthz

port: 8080

failureThreshold: 30

periodSeconds: 10

```

startup time (e.g., Java requires a longer delay than Go/Nginx).

5. Services & Ingress Routing

ClusterIP. Never use type: LoadBalancer or NodePort` unless the workload

is explicitly intended to be publicly accessible from the internet.

container ports (e.g., name: http-web or name: grpc-api) to enable

automatic protocol discovery, tracing, and Web App routing.

Gateway API (Gateway and HTTPRoute resources) over legacy Ingress

objects to enable advanced L7 routing and security features (e.g., Cloud

Armor).

6. Volume Mounts, StorageClasses & subPath Safety

an application directory containing other files (like Nginx public

directories), always use subPath to overlay only the specific file.

Caveat: Note that containers using subPath volume mounts do not receive

automatic configuration updates if the underlying ConfigMap or Secret is

modified; pods must be restarted manually to pick up changes.

PersistentVolumeClaims:

(default balanced PD) or premium-rwo (SSD PD).

(SSD PD) if standard-rwo/premium-rwo are not configured.

only when the prompt explicitly requests high IOPS, low latency, or

database storage.

7. High Availability on GKE

or topologySpreadConstraints with topologyKey: "kubernetes.io/hostname"

to distribute pods across GKE nodes and availability zones.

PodDisruptionBudget to guarantee minimum replica availability during

voluntary GKE node upgrades and maintenance cycles.

8. Updates & Server-Side Apply Reconciliations

associative lists (like volumes, volume mounts, ports, and container

definitions) are matched and merged by their unique identifier keys

(typically name). You must keep the name key stable when modifying

properties of an existing list item. Renaming the name key will cause SSA

to create a brand new entry and leave the old entry intact (orphaned) rather

than modifying it.

existing labels, annotations, and conventions.


Specialty Workloads: GKE AI/Inference Serving (vLLM, TGI, etc.)

For model serving workloads, prioritize using optimized tooling like GKE

Inference Quickstart if available. If generating manually:

  1. GPU Request & Allocation:

accelerator tag (e.g., cloud.google.com/gke-accelerator: nvidia-l4).

  1. Shared Memory Boost:

communications. Always declare and mount an emptyDir volume with

medium: Memory to /dev/shm.

  1. Weight Loading Optimization:

CSI driver (gcsfuse.csi.storage.gke.io) as readOnly: true for

efficient cold-starts.


Tooling & Grounding Guidelines

When generating manifests, you should leverage the following tooling to reduce

hallucinations and optimize configurations:

  1. Inference Workloads (GKE Inference Quickstart CLI):

Google Cloud SDK installed.

prioritize using the gcloud CLI GKE Inference Quickstart command to

generate the optimized manifests instead of writing them manually:

```bash

gcloud container ai profiles manifests create \

--model={model_name} \

--model-server={server_name} \

--accelerator-type={accelerator_type} \

--output=manifest \

--output-path={output_file_path}

```

(Deployments, Services, PodMonitoring, etc.) without filtering.

  1. Grounding in Official Documentation (Developer Knowledge API):

contexts, you must query Google's developer knowledge base to

retrieve official GKE documentation:

configure GCS Fuse CSI driver in GKE"*). This is the preferred tool

for general queries.

or examples when you don't have a specific question.

you have a specific document ID.


Reference Examples

For detailed, production-ready manifest templates, consult the following

reference guides:

Production-ready deployment with dedicated service account, security

contexts, probes, anti-affinity, and PodDisruptionBudget.

network policy and selective ingress allowance for specific apps.

allocation, Workload Identity, GCS FUSE CSI driver mounting, /dev/shm

shared memory boost, and startup probes.

using GKE L7 Gateway API (Gateway and HTTPRoute resources).

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.