{"data":{"slug":"github-google-skills-skills-cloud-gke-manifest-generation-3d3d75a6dd6d","title":"GKE Manifest Generation","summary":"Generate secure, production-ready Kubernetes YAML manifests for GKE Autopilot and GKE Standard clusters, including namespace declarations, dedicated ServiceAccounts, and resource limits.","url":"https:\/\/skillshunter.net\/skills\/github-google-skills-skills-cloud-gke-manifest-generation-3d3d75a6dd6d","json_url":"https:\/\/skillshunter.net\/api\/public\/v1\/skills\/github-google-skills-skills-cloud-gke-manifest-generation-3d3d75a6dd6d","markdown_url":"https:\/\/skillshunter.net\/skills\/github-google-skills-skills-cloud-gke-manifest-generation-3d3d75a6dd6d.md","download_url":"https:\/\/skillshunter.net\/skills\/github-google-skills-skills-cloud-gke-manifest-generation-3d3d75a6dd6d\/download","category":{"slug":"software-development","name":"Software & Development"},"editor_note":"Before executing any `gcloud`, REST API, or MCP command, you must read [Usage Attribution](references\/attribution.md). For terminal commands, 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. Ensure the Google Cloud SDK is installed.","instructions":"---\nname: gke-manifest-generation\nmetadata:\n  version: \"1.0.1\"\n  category: Containers\ndescription: >-\n  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 probes, mounting secrets and volumes, configuring GKE Gateway API routes, targeting Spot VMs, or deploying AI model inference workloads (vLLM, TGI, Gemma). Don't use for live cluster operations, pod troubleshooting (use gke-workload-troubleshooting), or cluster infrastructure provisioning (use gke-cluster-creation).\n---\n\n# GKE Manifest Generation Skill\n\nThis skill provides guidelines, tooling integration, and templates to translate\nnatural language descriptions or application code changes into secure,\ncompliant, and cost-effective Kubernetes YAML manifests optimized for both GKE\nAutopilot and GKE Standard clusters.\n\n## Attribution\n\n**MUST READ**: Before executing any `gcloud`, REST API, or MCP command, you\nMUST read [Usage Attribution](references\/attribution.md). For commands executed\ndirectly in the terminal (never in generated scripts, Terraform, or user code),\nprefix `gcloud` with\n`CLOUDSDK_METRICS_REQUEST_ATTRIBUTION=\"agent-skills\/1.0 (skill:gke-manifest-generation)\"`\nand append `agent-skills\/1.0 (skill:gke-manifest-generation)` to `User-Agent` headers.\n\n## Core Rules & Verification\n\nWhen generating or updating YAML manifests, you **must** strictly adhere to the\nfollowing rules:\n\n### 1. Namespace & Resource Isolation\n\n-   **Explicit Namespace**: Always declare `namespace: {namespace}` explicitly\n    in the metadata of every resource (Deployments, Services, ConfigMaps,\n    Secrets, PVCs, Roles, bindings). Map it to the namespace configured in your\n    active `SETTINGS.md`. Never omit the namespace.\n-   **Dedicated ServiceAccount**: Avoid using the namespace's `default`\n    ServiceAccount. Always create and reference a dedicated `ServiceAccount`\n    (e.g., `devteam-agent-sa`) for each microservice.\n\n### 2. GKE Resource Tuning (Autopilot & Standard)\n\n-   **Resources Requests & Limits**: Always specify CPU and Memory requests and\n    limits for all containers.\n    -   *GKE Autopilot*: Requests determine pod billing directly; requests and\n        limits must be equal. If they differ, Autopilot will automatically scale\n        requests up to match limits, which can significantly increase costs.\n    -   *GKE Standard*: Requests ensure stable scheduling and bin-packing;\n        limits prevent resource starvation\/noisy-neighbor issues.\n-   **Density Defaults**: For stateless apps or sidecars on GKE Standard,\n    default to conservative requests (e.g., `requests.cpu: \"100m\"` or `\"200m\"`,\n    `requests.memory: \"256Mi\"` or `\"512Mi\"`) with burstable limits. Use a\n    reasonable overcommit ratio for limits (e.g., 2x to 4x requests, like\n    `limits.cpu: \"400m\"` to `\"800m\"`, and `limits.memory: \"512Mi\"` to `\"1Gi\"`).\n    Avoid excessive overcommit limits (like `limits.cpu: \"4\"` for a `100m`\n    request) to prevent severe CPU throttling and latency degradation under\n    heavy scheduling load, particularly in environments without guaranteed node\n    shares.\n-   **Spot VMs for Staging\/Dev**: For non-production workloads (e.g., namespaces\n    containing `-test`, `-dev`, or `-staging`), or if the user requests cost\n    optimization, automatically target GKE Spot VMs. This requires injecting\n    both the `nodeSelector` targeting Spot VMs AND the corresponding toleration\n    to tolerate the Spot VM taint:\n\n    ```yaml\n    nodeSelector:\n      cloud.google.com\/gke-spot: \"true\"\n    tolerations:\n      - key: \"cloud.google.com\/gke-spot\"\n        operator: \"Equal\"\n        value: \"true\"\n        effect: \"NoSchedule\"\n    ```\n\n    (On GKE Standard, this assumes a Spot node pool is configured).\n\n### 3. Container Security Hardening (Pod Security Standards)\n\n-   **Non-Root Execution**: Always configure `securityContext` at the Pod level\n    (and container level if overriding) to run as a non-root user (e.g.,\n    `runAsNonRoot: true`, `runAsUser: 10000`, `runAsGroup: 10000`, `fsGroup:\n    10000`). This is strictly enforced on GKE Autopilot and is a critical\n    security baseline for GKE Standard.\n-   **Minimal Privileges**: Always set `allowPrivilegeEscalation: false` and\n    `seccompProfile: {type: RuntimeDefault}`.\n-   **Read-Only Root Filesystem**: Set `readOnlyRootFilesystem: true` to prevent\n    modifications to the container image filesystem.\n    -   *Writable Directory Fallback*: If `readOnlyRootFilesystem` is enabled,\n        mount a local `emptyDir` volume to `\/tmp` or `\/var\/run\/` to allow\n        applications (like Java\/Nginx) to write temp files without crashing.\n-   **Secret Volume Mounting**: Prefer mounting Secrets as read-only files\n    (configured in the `volumes` spec with `defaultMode: 0400`) instead of\n    mapping them as environment variables, unless the application framework\n    exclusively supports env-var based configuration. This prevents secrets\n    leaking into application logs.\n\n### 4. Health Checking (Mandatory Probes)\n\n-   **Liveness & Readiness Probes**: Every Deployment container must define both\n    `livenessProbe` and `readinessProbe`.\n    -   **Web\/API**: Use `httpGet` probes.\n    -   **TCP Services**: Use `tcpSocket` probes.\n    -   **Databases\/Caches**: Use command-based `exec` probes (e.g.,\n        `exec.command: [\"redis-cli\", \"ping\"]`).\n-   **Startup Probes for Slow-Starting Apps**: For applications with slow boot\n    times (e.g., Java spring boot, complex Python scripts, LLM model servers),\n    you **must** also define a `startupProbe`. When a `startupProbe` is defined,\n    the liveness and readiness probes are disabled until it succeeds, preventing\n    Kubernetes from prematurely killing the pod during startup:\n\n    ```yaml\n    startupProbe:\n      httpGet:\n        path: \/healthz\n        port: 8080\n      failureThreshold: 30\n      periodSeconds: 10\n    ```\n\n-   **Sensible Defaults**: Set `initialDelaySeconds: 5` to `15` depending on\n    startup time (e.g., Java requires a longer delay than Go\/Nginx).\n\n### 5. Services & Ingress Routing\n\n-   **Internal ClusterIP**: Default all internal microservices to `type:\n    ClusterIP`. Never use `type: LoadBalancer` or `NodePort` unless the workload\n    is explicitly intended to be publicly accessible from the internet.\n-   **Port Naming**: Always assign clear, standard names to service and\n    container ports (e.g., `name: http-web` or `name: grpc-api`) to enable\n    automatic protocol discovery, tracing, and Web App routing.\n-   **Prefer Gateway API**: When exposing APIs externally, prioritize using GKE\n    Gateway API (`Gateway` and `HTTPRoute` resources) over legacy `Ingress`\n    objects to enable advanced L7 routing and security features (e.g., Cloud\n    Armor).\n\n### 6. Volume Mounts, StorageClasses & subPath Safety\n\n-   **Avoid Directory Overwrites**: When mounting a `ConfigMap` or `Secret` to\n    an application directory containing other files (like Nginx public\n    directories), always use `subPath` to overlay only the specific file.\n    *Caveat*: Note that containers using `subPath` volume mounts do not receive\n    automatic configuration updates if the underlying ConfigMap or Secret is\n    modified; pods must be restarted manually to pick up changes.\n-   **StorageClass Selection**: Use the correct GKE storage class in\n    PersistentVolumeClaims:\n    -   *CSI Driver Clusters (Autopilot & Modern Standard)*: Use `standard-rwo`\n        (default balanced PD) or `premium-rwo` (SSD PD).\n    -   *Legacy Standard Clusters*: Use `standard` (default PD) or `premium`\n        (SSD PD) if `standard-rwo`\/`premium-rwo` are not configured.\n    -   *Database rule*: Use SSD storage classes (`premium-rwo` or `premium`)\n        only when the prompt explicitly requests high IOPS, low latency, or\n        database storage.\n\n### 7. High Availability on GKE\n\n-   **Topology Spread**: For deployments with >1 replica, use `podAntiAffinity`\n    or `topologySpreadConstraints` with `topologyKey: \"kubernetes.io\/hostname\"`\n    to distribute pods across GKE nodes and availability zones.\n-   **PodDisruptionBudget**: For deployments with >1 replica, declare a\n    `PodDisruptionBudget` to guarantee minimum replica availability during\n    voluntary GKE node upgrades and maintenance cycles.\n\n### 8. Updates & Server-Side Apply Reconciliations\n\n-   **Stable List Keys**: Under Kubernetes Server-Side Apply (SSA), elements in\n    associative lists (like volumes, volume mounts, ports, and container\n    definitions) are matched and merged by their unique identifier keys\n    (typically `name`). You **must** keep the `name` key stable when modifying\n    properties of an existing list item. Renaming the `name` key will cause SSA\n    to create a brand new entry and leave the old entry intact (orphaned) rather\n    than modifying it.\n-   **Minimal Diff**: Make only the changes requested. Adhere closely to\n    existing labels, annotations, and conventions.\n\n--------------------------------------------------------------------------------\n\n## Specialty Workloads: GKE AI\/Inference Serving (vLLM, TGI, etc.)\n\nFor model serving workloads, prioritize using optimized tooling like GKE\nInference Quickstart if available. If generating manually:\n\n1.  **GPU Request & Allocation**:\n    -   Always request `nvidia.com\/gpu` in both `requests` and `limits`.\n    -   Add a `nodeSelector` or node affinity targeting the desired GKE\n        accelerator tag (e.g., `cloud.google.com\/gke-accelerator: nvidia-l4`).\n2.  **Shared Memory Boost**:\n    -   Model servers require high shared memory (`\/dev\/shm`) for inter-process\n        communications. Always declare and mount an `emptyDir` volume with\n        `medium: Memory` to `\/dev\/shm`.\n3.  **Weight Loading Optimization**:\n    -   Mount model weight directories (like GCS buckets) using the GKE GCS Fuse\n        CSI driver (`csi.storage.gke.io`) as `readOnly: true` for efficient\n        cold-starts.\n\n--------------------------------------------------------------------------------\n\n## Tooling & Grounding Guidelines\n\nWhen generating manifests, you should leverage the following tooling to reduce\nhallucinations and optimize configurations:\n\n1.  **Inference Workloads (GKE Inference Quickstart CLI)**:\n\n    -   Make sure you have the\n        [Google Cloud SDK](https:\/\/cloud.google.com\/sdk\/docs\/install) installed.\n    -   For all AI\/LLM inference workloads (e.g. model serving), you **must**\n        prioritize using the `gcloud` CLI GKE Inference Quickstart command to\n        generate the optimized manifests instead of writing them manually:\n\n        ```bash\n        gcloud container ai profiles manifests create \\\n          --model={model_name} \\\n          --model-server={server_name} \\\n          --accelerator-type={accelerator_type} \\\n          --output=manifest \\\n          --output-path={output_file_path}\n        ```\n\n    -   *Constraint*: You must include all resources returned by this command\n        (Deployments, Services, PodMonitoring, etc.) without filtering.\n\n2.  **Grounding in Official Documentation (Developer Knowledge API)**:\n\n    -   For GKE-specific features, API defaults, manifest examples, or security\n        contexts, you **must** query Google's developer knowledge base to\n        retrieve official GKE documentation:\n        -   **`answer_query`**: Use this to ask direct questions (e.g., *\"How to\n            configure GCS Fuse CSI driver in GKE\"*). This is the preferred tool\n            for general queries.\n        -   **`search_documents`**: Use this to search for relevant GKE guides\n            or examples when you don't have a specific question.\n        -   **`get_document`**: Use this to fetch full document contents when\n            you have a specific document ID.\n\n--------------------------------------------------------------------------------\n\n## Reference Examples\n\nFor detailed, production-ready manifest templates, consult the following\nreference guides:\n\n-   **[Basic Hardened Nginx Workload](references\/basic-workload.md)**:\n    Production-ready deployment with dedicated service account, security\n    contexts, probes, anti-affinity, and PodDisruptionBudget.\n-   **[Network Policy](references\/network-policy.md)**: Default-deny ingress\n    network policy and selective ingress allowance for specific apps.\n-   **[AI\/LLM Inference Workload](references\/ai-inference.md)**: GPU resource\n    allocation, Workload Identity, GCS FUSE CSI driver mounting, `\/dev\/shm`\n    shared memory boost, and startup probes.\n-   **[GKE Gateway API Routing](references\/gateway-api.md)**: Exposing workloads\n    using GKE L7 Gateway API (`Gateway` and `HTTPRoute` resources).\n","use_cases":["Creating or modifying GKE deployment manifests","Configuring container security contexts","Setting CPU\/memory resource limits","Defining readiness\/liveness\/startup probes","Mounting secrets and volumes","Configuring GKE Gateway API routes"],"limitations":[],"compatibility":[],"setup_tip":null,"sample_input":null,"sample_output":null,"source_url":"https:\/\/github.com\/google\/skills\/blob\/e3c591afe426ea585e4c21799e5199d6d47cd1be\/skills\/cloud\/gke-manifest-generation\/SKILL.md","source_commit":"e3c591afe426ea585e4c21799e5199d6d47cd1be","license":null,"version":null,"listing_approved_at":"2026-11-17","created_at":"2026-11-16T16:11:07.000000Z","updated_at":"2026-11-17T10:20:00.000000Z","seo_title":"Generate GKE Kubernetes Manifests","seo_description":"Create secure, production-ready Kubernetes YAML manifests for GKE Autopilot and GKE Standard clusters with detailed guidelines and templates.","seo_keywords":["Generate GKE Kubernetes Manifests","Create secure Kubernetes YAML","Update GKE Deployment Manifests","Configure GKE Security Contexts","Set GKE Resource Limits","Define GKE Probes"]}}