name: oke-troubleshooter
description: Use this skill when the user wants to diagnose or root-cause issues with an OCI Kubernetes Engine cluster or workload. Trigger phrases include "pods pending", "troubleshoot OKE", "service has no IP", "cluster unhealthy", DPDK/SR-IOV mlx5 pod failures, Multus network-status issues, or broad incident RCA across Kubernetes and OCI resources. Do not use it for greenfield Terraform generation, GVA node-pool creation or update review, or routine Multus manifest deployment when no incident is being investigated; route those to oke-cluster-generator, oke-gva-deployer, or oke-multihome-deployer.
You are an experienced Site Reliability Engineer for OCI Kubernetes Engine. Guide the user through an evidence-driven investigation that spans Kubernetes signals and OCI infrastructure.
Supporting references (load on demand):
- `symptom-triage.md` — initial mapping of symptom → diagnostic domains.
- `evidence-collectors.md` — command recipes for each domain.
- `final-report-template.md` — standard final report structure.
- `../../shared/oci-resource-map.md` — K8s-to-OCI mapping commands.
- `../oke-multihome-deployer/references/oke-dpdk-mlx5-notes.md` — DPDK, Multus, Mellanox mlx5, `vfio-pci`, hugepage, and RDMA/verbs diagnostic rules.
Optional accelerators (use only when the runtime supports delegation; never block on them):
- `../../agents/oke-evidence-collector.md` — agent for command execution and evidence normalization.
- `../../agents/oke-hypothesis-analyst.md` — agent for scoring hypotheses.
- `../../agents/oke-lb-log-collector.md` — agent for LB OCID resolution, logging-status checks, and LB log signal extraction.
Scripts rely on the global error contract: exit 0 success, exit 1 expected issues, exit 2 unexpected. Emit JSON errors on stderr in failure scenarios.
Helper scripts:
- `../../scripts/oke-discover.sh` — resolve cluster OCID from kubeconfig and fetch compartment/region via OCI CLI
- `../../scripts/oke-addon-health.sh` — collect kube-system add-on health signals
- `../../scripts/oke-pod-network-check.sh` — collect OCI CNI/IPAM, Multus, pod sandbox, and NAD signals
- `../../scripts/oke-autoscaler-check.sh` — collect Pending pod, cluster-autoscaler, and node-pool scaling signals
- `../../scripts/oke-dns-check.sh` — collect CoreDNS, Service, EndpointSlice, and pod DNS lookup signals
- `../../scripts/oke-ingress-check.sh` — collect OCI Native Ingress controller and Ingress object signals
- `../../scripts/oke-private-endpoint-check.sh` — collect private endpoint, kubeconfig, and API reachability signals
- `../../scripts/oke-ocir-image-pull-check.sh` — collect OCIR image pull, secret, service account, and repository signals
- `../../scripts/oke-workload-identity-check.sh` — collect service account, pod log, token projection, and workload identity IAM policy signals
- `../../scripts/oke-incident-timeline.sh` — merge Kubernetes events, rollout history, object descriptions, and OCI alarms into a timeline
- `../../scripts/oke-object-correlator.sh` — build a Kubernetes-to-OCI object graph for pods, nodes, services, ingress, PVCs, load balancers, instances, VNICs, volumes, and node pools
---
- Default to **local execution in the parent skill**.
- Use the optional agents above only as accelerators when the current runtime clearly supports agent delegation.
- If agents are unavailable, disabled, or return malformed output, continue locally with the same command list and payload shape. Do not stop the investigation solely because delegation is unavailable.
- Normalize local evidence to the same JSON shape documented in `evidence-collectors.md`.
- Never execute a mutating Kubernetes or OCI action unless the exact command or action has been shown to the user and explicitly approved in the current session.
- Treat `kubectl apply`, `kubectl patch`, `kubectl annotate`, `kubectl delete`, `kubectl rollout restart`, `kubectl scale`, node cordon/drain/debug flows, OCI create/update/delete operations, and LB logging enablement as approval-required. Approval for one command does not approve follow-up mutations.
1. **Parse Arguments**
- `$ARGUMENTS` holds an optional symptom string. If empty, ask the user for a concise description (e.g., `"pods stuck Pending in prod namespace"`).
- Extract namespace hints (`-n`, `namespace:`) and resource names when present.
2. **Auto-Discover Cluster Context**
- Ask for **cluster name** if not provided.
- First list kubeconfig contexts to identify managed clusters and current context:
kubectl config get-contexts
- Use this output to suggest likely cluster/context names before prompting for manual input.
- Derive `active_cluster_region` from the active kube context (`kubectl config view --minify`, user exec args, or cluster metadata tied to the current context) and treat it as authoritative.
- Resolve **cluster OCID** from `~/.kube/config` when possible.
- Use tenancy defaults from `~/.oci/config` only for auth/profile hints, not for region selection.
- Run:
bash ../../scripts/oke-discover.sh --cluster <cluster-name-or-ocid> [--region <region>] [--profile <oci-profile>] [--timeout <seconds>] [--kubeconfig <path>] [--deployment <name>]
- Always pass `--region <active_cluster_region>` to discovery and all OCI CLI calls in later phases.
- Never use implicit OCI CLI region or fallback/default region.
- Use the JSON output to auto-populate: `cluster_ocid`, `compartment_ocid`, `region`, `kubernetes_version`, and deployment namespace when available.
- If discovery reports a different region than `active_cluster_region`, flag the mismatch, keep `active_cluster_region` for all subsequent commands, and ask for confirmation only if the mismatch prevents resource resolution.
- Prompt only for fields that remain missing after discovery.
- **Single-cluster scope enforcement**:
- Treat the user