{"data":{"slug":"github-google-skills-skills-cloud-gke-service-networking-1876495ebe91","title":"Configure GKE Service Networking for Secure Exposures","summary":"Configure GKE edge networking, traffic routing, load balancing, and private service endpoints for secure application exposure. This includes setting up Gateway API, Ingress, Cloud Armor WAF, and Google-Managed SSL certificates.","url":"https:\/\/skillshunter.net\/skills\/github-google-skills-skills-cloud-gke-service-networking-1876495ebe91","json_url":"https:\/\/skillshunter.net\/api\/public\/v1\/skills\/github-google-skills-skills-cloud-gke-service-networking-1876495ebe91","markdown_url":"https:\/\/skillshunter.net\/skills\/github-google-skills-skills-cloud-gke-service-networking-1876495ebe91.md","download_url":"https:\/\/skillshunter.net\/skills\/github-google-skills-skills-cloud-gke-service-networking-1876495ebe91\/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 commands executed directly in the terminal, prefix `gcloud` with `CLOUDSDK_METRICS_REQUEST_ATTRIBUTION=\"agent-skills\/1.0 (skill:gke-service-networking)\"` and append `agent-skills\/1.0 (skill:gke-service-networking)` to `User-Agent` headers. The cluster must be VPC-native, and Gateway API must be enabled (enabled by default on GKE 1.26+ clusters).","instructions":"---\nname: gke-service-networking\ndescription: >-\n  Configures GKE edge networking, traffic routing, load balancing, and private\n  service endpoints. Use when configuring Gateway API manifests, standard\n  Ingress, Cloud Armor WAF security policies, Container-Native Load Balancing\n  (NEGs), Private Service Connect (PSC), or Google-managed SSL certificates on\n  GKE, and to troubleshoot Ingress and load-balancer 502\/5xx errors, backend\n  health-check failures, connection draining, and TLS\/SSL policy enforcement.\n  Don't use for core cluster IP planning, Dataplane V2 network policies, or\n  node NAT egress (use gke-networking instead).\nmetadata:\n  version: \"1.1.1\"\n  category: Networking\n---\n\n# GKE Service Networking Skill\n\nThis skill provides workflows for exposing applications running on GKE securely\nto the internet or internal networks.\n\nDeployable manifest templates live in `assets\/` \u2014 edit the `# Replace ...`\nplaceholders before applying.\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-service-networking)\"`\nand append `agent-skills\/1.0 (skill:gke-service-networking)` to `User-Agent` headers.\n\n## Workflows\n\n### 1. Configure Gateway API (Recommended)\n\nThe Gateway API is the modern way to manage routing in Kubernetes.\n\n**Prerequisites**: Gateway API must be enabled on the cluster (enabled by\ndefault on new clusters running GKE 1.26+; on older supported versions enable it\nwith `--gateway-api=standard`).\n\n**Templates:**\n\n-   `assets\/gateway.yaml` \u2014 external Gateway using the\n    `gke-l7-global-external-managed` GatewayClass with an HTTP listener.\n-   `assets\/httproute.yaml` \u2014 HTTPRoute attaching to the Gateway via\n    `parentRefs` and routing a path prefix to a Service `backendRef`.\n-   `assets\/httproute-traffic-split.yaml` \u2014 HTTPRoute demonstrating weighted\n    traffic splitting (e.g. 90\/10) for canary deployments across backend\n    services.\n\n```bash\nkubectl apply -f assets\/gateway.yaml\nkubectl apply -f assets\/httproute.yaml\n```\n\n**Traffic Splitting (Canary Deployments):**\n\nHTTPRoute supports weighted traffic splitting across multiple backend Services\nfor canary rollouts:\n\n```yaml\nspec:\n  rules:\n    - backendRefs:\n        - name: app-v1\n          port: 80\n          weight: 90\n        - name: app-v2\n          port: 80\n          weight: 10\n```\n\n### 2. Configure Standard GKE Ingress\n\nUse standard Ingress for simpler use cases or legacy setups.\n\n**Template:** `assets\/ingress.yaml` \u2014 GCE Ingress (`kubernetes.io\/ingress.class:\n\"gce\"` annotation) routing to a Service.\n\n### 3. Secure with Cloud Armor\n\nCloud Armor provides WAF and DDoS protection.\n\n1.  Create a Security Policy in Cloud Armor:\n\n    ```bash\n    gcloud compute security-policies create {security_policy_name} \\\n      --description \"WAF policy for {app_name}\"\n\n    # Example rule: block an abusive IP range\n    gcloud compute security-policies rules create 1000 \\\n      --security-policy {security_policy_name} \\\n      --action deny-403 \\\n      --src-ip-ranges \"203.0.113.0\/24\" \\\n      --description \"Block abusive range\"\n    ```\n\n2.  Reference it in a `BackendConfig`: `assets\/backendconfig.yaml` (sets\n    `spec.securityPolicy.name`).\n\n3.  Associate the `BackendConfig` with your `Service` via annotations:\n\n    ```yaml\n    # In your Kubernetes Service manifest metadata.annotations:\n    cloud.google.com\/backend-config: '{\"default\": \"{backend_config_name}\"}'\n    # Or for specific port mappings:\n    cloud.google.com\/backend-config: '{\"ports\": {\"80\": \"{backend_config_name}\"}}'\n    ```\n\n### 4. Configure Google-Managed SSL Certificates\n\nAutomatically provision and renew SSL certificates.\n\n**Legacy Ingress approach:** apply `assets\/managed-certificate.yaml` (a\n`ManagedCertificate` listing your domains), then reference it in the Ingress\nannotations:\n\n```yaml\nnetworking.gke.io\/managed-certificates: {certificate_name}\n```\n\n**Gateway API approach:** for standard Certificate Manager integration, create a\n`CertificateMap` and reference it in the Gateway metadata annotations using the\nexact annotation `networking.gke.io\/certmap` (spelled without any hyphens in\n`certmap`):\n\n```yaml\nmetadata:\n  annotations:\n    networking.gke.io\/certmap: {certificate_map_name}\n```\n\n> [!IMPORTANT] The annotation key is strictly `networking.gke.io\/certmap` (do\n> not use `cert-map` or `certificate-map`).\n\nAlternatively, reference a Kubernetes Secret in the HTTPS listener's\n`tls.certificateRefs`. Both variants are in `assets\/gateway-https.yaml`.\n\n### 5. Enable Container-Native Load Balancing (Recommended)\n\nContainer-native load balancing allows load balancers to target Kubernetes Pods\ndirectly, rather than targeting nodes. This improves latency and distribution.\n\n**Prerequisites**: Cluster must be VPC-native.\n\n**How it works**: the `cloud.google.com\/neg` annotation on a Service triggers\ncreation of a NEG that mirrors the Pod IPs. GKE often adds it for you \u2014 but not\nalways, and knowing which case you are in is the whole point.\n\n```yaml\n# In your Kubernetes Service manifest metadata.annotations:\ncloud.google.com\/neg: '{\"ingress\": true}'\n```\n\n**When the annotation is automatic** (do not add it by hand):\n\n-   **Internal Ingress** \u2014 container-native load balancing is *always* used, not\n    optional. Internal Ingress always uses `GCE_VM_IP_PORT` NEGs and requires a\n    VPC-native cluster.\n-   **External Ingress**, but only when all four hold: the cluster is\n    VPC-native, is not on Shared VPC, does not use GKE Network Policy, and has\n    the `HttpLoadBalancing` add-on enabled (on by default \u2014 do not disable it).\n    GKE then annotates Services automatically.\n\n**When you must add it explicitly**:\n\n-   **Standalone NEGs** \u2014 you manage the load balancer yourself instead of\n    letting Ingress own it. Required if the LB must be configured outside GKE,\n    since Ingress overwrites managed load balancer settings on sync or upgrade.\n    You become responsible for every part of the load balancer.\n-   **Any external-Ingress cluster failing one of the four conditions above** \u2014\n    Shared VPC, GKE Network Policy, or non-VPC-native. Enable per Service.\n-   **Legacy configurations** \u2014 some older external Ingress objects created on\n    VPC-native clusters still use instance group backends.\n\n**Not supported \/ no NEG fallback**:\n\n-   Windows Server node pools.\n-   Routes-based (non-VPC-native) clusters with external Ingress \u2014 the Ingress\n    controller falls back to unmanaged instance groups spanning all nodes.\n\n> **Scale consequence**: without NEGs a cluster is capped at 1,000 nodes, and\n> non-NEG Services behind Ingress stop functioning correctly beyond that. With\n> NEGs there is no GKE node limit.\n\n### 6. Configure Private Service Connect (PSC)\n\nPrivate Service Connect allows you to expose services in one VPC to consumers in\nanother VPC securely, without VPC peering.\n\n**Prerequisite**: The backing Service must be an internal passthrough Network\nLoad Balancer \u2014 i.e. `type: LoadBalancer` with the\n`networking.gke.io\/load-balancer-type: \"Internal\"` annotation. The\n`ServiceAttachment` requires this; a ClusterIP or external LoadBalancer Service\nwill not work.\n\n**Steps:**\n\n1.  Create an internal LoadBalancer Service for your workload.\n2.  Create a `ServiceAttachment` referencing that Service:\n    `assets\/service-attachment.yaml` (sets `connectionPreference`, the PSC NAT\n    subnet, and the Service `resourceRef`).\n3.  Share the `ServiceAttachment` URI with consumers to create a PSC endpoint in\n    their VPC.\n\n### 7. Topology Aware Routing (Cost & Latency Optimization)\n\nTo minimize cross-zone data transfer costs and network latency, configure\nKubernetes Services with Topology Aware Routing. This routes traffic to Pods in\nthe same zone as the originating client:\n\n```yaml\n# In your Kubernetes Service manifest metadata.annotations:\nservice.kubernetes.io\/topology-mode: auto\n```\n\n## Troubleshooting\n\nDiagnose Ingress \/ load-balancer data-plane failures. These map to both Ingress\n(`BackendConfig` \/ `FrontendConfig`) and Gateway (`GCPBackendPolicy` \/\n`HealthCheckPolicy` \/ `GCPGatewayPolicy`). Stay at the read-only \u2192 propose-manifest\nboundary; never apply live mutations directly.\n\n### 502 \/ 5xx with UNHEALTHY backends (health checks)\n\nThe Google Cloud load-balancer health check is **separate** from Kubernetes\nliveness\/readiness probes \u2014 it runs from outside the cluster, so a Pod can be\n`Ready` while the backend service still shows `UNHEALTHY`.\n\n1.  **Allow the Google health-check source ranges** to the node\/Pod serving port.\n    GKE usually creates this rule automatically, but on Shared VPC or with\n    hand-managed firewalls it can be missing:\n\n    ```bash\n    gcloud compute firewall-rules create allow-lb-health-checks \\\n      --allow tcp:SERVING_PORT \\\n      --source-ranges 130.211.0.0\/22,35.191.0.0\/16 \\\n      --target-tags NODE_TAG\n    ```\n\n2.  **Point the health check at a healthy endpoint.** If the default `\/` returns a\n    non-200, set a custom health check with a `BackendConfig` (Ingress) or a\n    `HealthCheckPolicy` (Gateway):\n\n    ```yaml\n    # BackendConfig (Ingress)\n    spec:\n      healthCheck:\n        requestPath: \/healthz\n        port: 8080\n        checkIntervalSec: 15\n        timeoutSec: 5\n    ```\n\n3.  Confirm the Service is container-native (NEG) so the check targets Pod IPs\n    rather than nodes (see workflow 5).\n\n### 502 \/ dropped requests during rollouts or on long requests\n\n-   **Enable connection draining** so in-flight requests finish before a backend\n    Pod is removed during a rolling update or scale-down:\n\n    ```yaml\n    # BackendConfig (Ingress)\n    spec:\n      connectionDraining:\n        drainingTimeoutSec: 60\n    ```\n\n-   **Raise the backend timeout** for slow or streaming responses \u2014 a 502\/408 on a\n    request that runs longer than the backend response timeout is the classic\n    symptom. Set `timeoutSec` in the `BackendConfig` (Ingress) or `GCPBackendPolicy`\n    (Gateway).\n\n### TLS \/ SSL handshake failures or weak-cipher enforcement\n\n-   **Ingress:** attach an SSL policy (minimum TLS version \/ cipher profile) with a\n    `FrontendConfig` `sslPolicy`, and optionally force HTTP\u2192HTTPS with\n    `redirectToHttps`:\n\n    ```yaml\n    # FrontendConfig (external Ingress only)\n    spec:\n      sslPolicy: gke-ingress-ssl-policy\n      redirectToHttps:\n        enabled: true\n    ```\n\n-   **Gateway:** attach the SSL policy name in a `GCPGatewayPolicy`. For a regional\n    Gateway, create and reference a **regional** SSL policy.\n\n## Gotchas\n\n1.  **Certificate Manager API must be enabled** for the\n    `networking.gke.io\/certmap` annotation to work (`gcloud services enable\n    certificatemanager.googleapis.com`); without it the Gateway fails to\n    provision the certificate map.\n2.  **Regional Gateway classes need a proxy-only subnet**: classes like\n    `gke-l7-regional-external-managed` and `gke-l7-rilb` require a subnet with\n    `--purpose=REGIONAL_MANAGED_PROXY` in the region; the Gateway stays\n    unprogrammed without it.\n3.  **ManagedCertificate provisioning depends on DNS**: the certificate stays in\n    `Provisioning` until the domain's A\/AAAA records point at the load balancer\n    IP, and can take 15-60 minutes after DNS is correct.\n\n## References\n\n-   [Ingress features (BackendConfig \/ FrontendConfig)](https:\/\/docs.cloud.google.com\/kubernetes-engine\/docs\/how-to\/ingress-configuration.md.txt)\n-   [Container-native load balancing (NEGs)](https:\/\/docs.cloud.google.com\/kubernetes-engine\/docs\/how-to\/load-balance-ingress.md.txt)\n-   [Configure Gateway resources (GCPGatewayPolicy \/ HealthCheckPolicy \/ GCPBackendPolicy)](https:\/\/docs.cloud.google.com\/kubernetes-engine\/docs\/how-to\/configure-gateway-resources.md.txt)\n-   [Health check concepts](https:\/\/docs.cloud.google.com\/load-balancing\/docs\/health-check-concepts.md.txt)\n","use_cases":["Expose applications securely to the internet or internal networks","Set up traffic routing with Gateway API or standard Ingress","Secure applications with Cloud Armor WAF and DDoS protection","Automate SSL certificate management with Google-Managed Certificates","Enable container-native load balancing for improved latency and distribution"],"limitations":[],"compatibility":[],"setup_tip":null,"sample_input":null,"sample_output":null,"source_url":"https:\/\/github.com\/google\/skills\/blob\/e3c591afe426ea585e4c21799e5199d6d47cd1be\/skills\/cloud\/gke-service-networking\/SKILL.md","source_commit":"e3c591afe426ea585e4c21799e5199d6d47cd1be","license":null,"version":null,"listing_approved_at":"2026-11-17","created_at":"2026-11-16T16:35:33.000000Z","updated_at":"2026-11-17T10:20:00.000000Z","seo_title":"Configure GKE Service Networking for Secure Exposures","seo_description":"Configure GKE edge networking, traffic routing, load balancing, and private service endpoints for secure application exposure.","seo_keywords":["GKE service networking configuration","secure application exposure on GKE","configure GKE edge networking","GKE traffic routing setup","Cloud Armor WAF integration","Google-Managed SSL certificate setup"]}}