gke-observability
Workflows for setting up and auditing observability (logging, monitoring, tracing) on GKE.
- License 许可
- Apache-2.0
- 最近更新
- 2026-11-14
- Stars
- ★ 126
- Forks
- 44
01 前言 Front Matter
- name
- gke-observability
- description
- Workflows for setting up and auditing observability (logging, monitoring, tracing) on GKE.
03 SKILL.md 正文
GKE Observability Skill
This skill provides workflows for ensuring your GKE cluster and workloads have adequate observability for production use.
You are read-only: each change below is a proposal you report with your findings, never a command you run.
Workflows
1. Audit Cluster Observability
Check if Cloud Logging and Cloud Monitoring are enabled on the cluster.
Command:
gcloud container clusters describe <cluster-name> --region <region> --project <project-id> --format="json(loggingConfig, monitoringConfig)"
Look for loggingService and monitoringService to be set to something other than none (usually logging.googleapis.com/kubernetes and monitoring.googleapis.com/kubernetes).
2. Enable Managed Service for Prometheus
Google Cloud Managed Service for Prometheus is the recommended way to collect metrics from your applications.
To enable: propose turning on Managed Service for Prometheus (Config
Connector ContainerCluster field spec.monitoringConfig.managedPrometheus.enabled: true).
Verify installation:
kubectl get pods -n gmp-system
3. Workload Logging Verification
Ensure your workloads are logging to standard output, which Cloud Logging collects automatically.
Check workload logs:
kubectl logs <pod-name> -n <namespace>
Ensure logs are in a structured format (like JSON) if possible, for easier querying.
4. Dashboards and Alerts
Recommend creating dashboards in Cloud Monitoring for key metrics:
- CPU Utilization
- Memory Utilization
- Request Latency
- Error Rate
Set up alerting policies for critical thresholds.
5. Distributed Tracing
Enable distributed tracing to track requests across microservices.
- Action: Recommend using OpenTelemetry in the application to send traces to Cloud Trace.
- Benefit: Helps identify latency bottlenecks in distributed systems.
6. Continuous Profiling
Use continuous profiling to analyze application performance in production with low overhead.
- Action: Recommend integrating the Cloud Profiler agent in your application code.
- Benefit: Helps identify CPU and memory-consuming functions in production.
7. Querying Logs with LQL
Use Logging Query Language (LQL) in Cloud Logging to find specific logs.
Example LQL Queries:
- Find error logs for a specific container:
resource.type="k8s_container" resource.labels.container_name="my-app" severity>=ERROR - Find logs with a specific message:
resource.type="k8s_container" textPayload:"connection refused"
8. Enable Control Plane Metrics
For Standard clusters, you can enable collection of metrics from the Kubernetes API server, scheduler, and controller manager.
Propose the monitoring components SYSTEM_COMPONENTS, APISERVER,
SCHEDULER and CONTROLLER_MANAGER (Config Connector ContainerCluster field
spec.monitoringConfig.enableComponents).
9. Enable Dataplane V2 Observability
If using GKE Dataplane V2, you can enable advanced L4 observability.
Propose enabling Dataplane V2 observability (Config Connector
ContainerCluster field spec.monitoringConfig.advancedDatapathObservabilityConfig,
a list whose entry sets enableMetrics: true, plus relayMode for flow
observability).
This allows you to observe traffic flows and network metrics.
Best Practices
- Structured Logging: Use JSON logging in your applications to make it easier to search and analyze logs in Cloud Logging.
- Custom Metrics: Use Managed Service for Prometheus to expose and collect custom application metrics.
- Full Pillars of Observability: Implement Tracing and Profiling in addition to Logs and Metrics for complete visibility.
- Control Plane Metrics: Enable control plane metrics (if using Standard) to monitor the health of the API server and scheduler.
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.