gke-service-networking
Configures GKE edge networking, traffic routing, load balancing, and private service endpoints. Use when configuring Gateway API manifests, standard Ingress, Cloud Armor WAF security policies, Container-Native Load Balancing (NEGs), Private Service Connect (PSC), or Google-managed SSL certificates on GKE. Don't use for core cluster IP planning, Dataplane V2 network policies, or node NAT egress (use gke-networking instead).
- License 许可
- Apache-2.0
- 最近更新
- 2026-11-14
- Stars
- ★ 126
- Forks
- 44
01 前言 Front Matter
- name
- gke-service-networking
- metadata
- { "category": "Networking" }
- description
- Configures GKE edge networking, traffic routing, load balancing, and private service endpoints. Use when configuring Gateway API manifests, standard Ingress, Cloud Armor WAF security policies, Container-Native Load Balancing (NEGs), Private Service Connect (PSC), or Google-managed SSL certificates on GKE. Don't use for core cluster IP planning, Dataplane V2 network policies, or node NAT egress (use gke-networking instead).
03 SKILL.md 正文
GKE Service Networking Skill
This skill provides workflows for exposing applications running on GKE securely to the internet or internal networks.
Workflows
1. Configure Gateway API (Recommended)
The Gateway API is the modern way to manage routing in Kubernetes.
Prerequisites: Gateway API must be enabled on the cluster (enabled by default in GKE 1.24+).
Example Gateway Manifest:
apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
name: {gateway_name}
namespace: {namespace}
spec:
gatewayClassName: gke-l7-global-external-managed # GKE managed external L7 load balancer
listeners:
- name: http
protocol: HTTP
port: 80
Example HTTPRoute Manifest:
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: {route_name}
namespace: {namespace}
spec:
parentRefs:
- name: {gateway_name}
rules:
- matches:
- path:
type: PathPrefix
value: /
backendRefs:
- name: {service_name}
port: 80
2. Configure Standard GKE Ingress
Use standard Ingress for simpler use cases or legacy setups.
Example Ingress Manifest:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {ingress_name}
namespace: {namespace}
annotations:
kubernetes.io/ingress.class: "gce"
spec:
rules:
- http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: {service_name}
port:
number: 80
3. Secure with Cloud Armor
Cloud Armor provides WAF and DDoS protection.
Enable Cloud Armor via BackendConfig:
- Create a Security Policy in Cloud Armor (usually via gcloud or Terraform).
- Reference it in a
BackendConfigin GKE.
Example BackendConfig:
apiVersion: cloud.google.com/v1
kind: BackendConfig
metadata:
name: {backend_config_name}
namespace: {namespace}
spec:
securityPolicy:
name: {security_policy_name}
-
Associate
BackendConfigwith yourServicevia annotations:# In your Kubernetes Service manifest metadata.annotations: cloud.google.com/backend-config: '{"default": "{backend_config_name}"}' # Or for specific port mappings: cloud.google.com/backend-config: '{"ports": {"80": "{backend_config_name}"}}'
4. Configure Google-Managed SSL Certificates
Automatically provision and renew SSL certificates.
Example ManagedCertificate (Legacy Ingress):
apiVersion: networking.gke.io/v1
kind: ManagedCertificate
metadata:
name: {certificate_name}
spec:
domains:
- {domain_name}
Reference it in Ingress annotations: networking.gke.io/managed-certificates: {certificate_name}.
Gateway API Approach: For standard Certificate Manager integration, create a
CertificateMap and reference it directly in the Gateway metadata annotations
using networking.gke.io/cert-map: {certificate_map_name}, or reference a
Kubernetes Secret in the HTTPS listener:
apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
name: {gateway_name}
namespace: {namespace}
annotations:
networking.gke.io/cert-map: {certificate_map_name} # For Certificate Manager maps
spec:
gatewayClassName: gke-l7-global-external-managed
listeners:
- name: https
protocol: HTTPS
port: 443
tls:
mode: Terminate
certificateRefs:
- kind: Secret
name: {secret_name} # Or directly reference a Kubernetes Secret
5. Enable Container-Native Load Balancing (Recommended)
Container-native load balancing allows load balancers to target Kubernetes Pods directly, rather than targeting nodes. This improves latency and distribution.
Prerequisites: Cluster must be VPC-native.
How it works:
- For GKE Ingress and Gateway API, container-native load balancing is enabled by default via Network Endpoint Groups (NEGs).
- To verify or explicitly enable it for a Service, use the
cloud.google.com/negannotation.
Example Service Manifest:
apiVersion: v1
kind: Service
metadata:
name: {service_name}
annotations:
cloud.google.com/neg: '{"ingress": true}' # Enabled for Ingress
spec:
ports:
- protocol: TCP
port: 80
targetPort: 8080
selector:
app: {app_name}
type: ClusterIP
6. Configure Private Service Connect (PSC)
Private Service Connect allows you to expose services in one VPC to consumers in another VPC securely, without VPC peering.
Steps:
- Create an internal load balancer for your service.
- Create a
ServiceAttachmentreferencing the load balancer.
Example ServiceAttachment Manifest:
apiVersion: networking.gke.io/v1
kind: ServiceAttachment
metadata:
name: {attachment_name}
namespace: {namespace}
spec:
connectionPreference: ACCEPT_AUTOMATIC
natSubnets:
- {nat_subnet_name} # Subnet dedicated for PSC NAT
resourceRef:
kind: Service
name: {service_name}
Share the ServiceAttachment URI with consumers to create a PSC endpoint in
their VPC.
Best Practices
- Prefer Gateway API: It offers more flexibility and role separation than Ingress.
- Enable Cloud Armor: Always protect public-facing endpoints with Cloud Armor.
- Use Managed Certificates: Avoid managing certificate renewals manually.
- Use Container-Native Load Balancing: Always use NEGs for HTTP(S) load balancing to reduce latency and improve traffic distribution.
04 同仓库更多 Skills
gke-workload-troubleshooting
Diagnoses GKE workload failures (CrashLoopBackOff, OOMKilled, ImagePullBackOff, Pending, etc.) via logs and events. Use when pods fail to start or crash repeatedly. Don't use for GKE cluster infrastructure provisioning, node pool creation, or non-Kubernetes Google Cloud services.
gke-workload-security
Audits, configures, and hardens workload-level security controls for Google Kubernetes Engine (GKE) applications and namespaces. Covers running security audits (`audit_cluster.sh`), enforcing Network Policies (default-deny and Dataplane V2 logging), isolating high-risk pods inside GKE Sandbox (`gVisor`), enforcing Pod Security Standards (`restricted` labeling) and pod securityContext, and mounting Secret Manager secrets via CSI (`SecretProviderClass`). Use when auditing workload security posture, isolating namespaces, applying pod security standards, or configuring network policies and secret volume mounts. Don't use for Workload Identity (use gke-workload-identity), cluster-wide control plane security, RBAC hardening, Binary Authorization, Shielded Nodes, or enabling platform-level GKE add-ons (use gke-platform-security instead).
gke-workload-scaling
Manages scaling for GKE workloads using HPA and VPA. Use when configuring Horizontal Pod Autoscaler (HPA), configuring Vertical Pod Autoscaler (VPA), or applying best practices for GKE workload autoscaling. Do not use for cluster-level autoscaling (Cluster Autoscaler), static cluster sizing, or configuring node-level machine styles directly.
gke-workload-identity
Configures and diagnoses Workload Identity Federation for GKE authentication failures for Pods (403 "iam.serviceAccounts.getAccessToken" / permission denied, "could not find default credentials", or GKE metadata server unreachable) by verifying cluster and node-pool Workload Identity configuration, the Kubernetes ServiceAccount (KSA) to IAM binding (direct principal binding and legacy Google ServiceAccount impersonation), target-resource IAM roles, and gke-metadata-server health. Use when setting up KSA/GSA bindings (`roles/iam.workloadIdentityUser`, `iam.gke.io/gcp-service-account`) or when a Pod cannot authenticate to Google Cloud APIs. Don't use for in-cluster Kubernetes RBAC errors (API-server authorization), general workload crashes (use gke-workload-troubleshooting), or Pod Security Standards and NetworkPolicies (use gke-workload-security).
gke-upgrades
Plans, executes, and validates Google Kubernetes Engine (GKE) cluster upgrades and maintenance operations for both Standard and Autopilot clusters. Produces upgrade plans, pre/post-upgrade checklists, maintenance runbooks with gcloud commands, release channel strategy, and troubleshooting guides. Handles node pool upgrade strategies (surge, blue-green), version compatibility, PDB management, and workload-specific concerns (stateful, GPU, operators). Use this skill whenever the user mentions GKE upgrades, Kubernetes version bumps, node pool maintenance, GKE patching, cluster version management, release channel selection, maintenance windows, surge upgrades, stuck upgrades, or any GKE lifecycle management task — even casual mentions like "we need to upgrade our clusters" or "plan our next GKE maintenance" or "our upgrade is stuck." Don't use for GKE cluster creation, application onboarding, general networking/routing setup, or security policy configurations (use gke-basics or relevant GKE skills instead).
gke-tpu-metrics-monitoring
Monitors and troubleshoots GKE TPU workloads, nodes, and node pools using GKE system metrics and PromQL. Use when monitoring TensorCore duty cycle, TPU memory, node readiness, multi-host TPU node pool availability, host maintenance or preemption interruptions, and calculating MTTR or MTBI metrics for GKE TPUs. Don't use for general non-TPU GKE workload monitoring or non-metric TPU debugging.