k8s-query
Query Kubernetes resources (pods, deployments, services, events). Use when checking cluster state and resource status.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Query Kubernetes resources (pods, deployments, services, events). Use when checking cluster state and resource status.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
Generic migration orchestrator that reads CHANGELOG.md to understand and execute version-specific migrations
Determine feature slug interactively by auto-detecting next number and prompting user for description
Share personal documents to the shared namespace with atomic git commit and push
Use when creating implementation plans to generate properly structured plans with phases, success criteria, and project references.
Use when documenting research findings to create properly structured research documents with frontmatter, sections, and file references.
ALWAYS check this skill before using grep, glob, Task tool, or doing any codebase exploration. Guides you to use specialized agents that are more efficient than basic tools.
| name | k8s-query |
| description | Query Kubernetes resources (pods, deployments, services, events). Use when checking cluster state and resource status. |
Check status of Kubernetes pods, deployments, services, and events.
# Check kubectl context
kubectl config current-context || {
echo "No kubectl context. Run: kubectl config use-context <context>"
exit 1
}
# Show current context and namespace
CURRENT_CONTEXT=$(kubectl config current-context)
CURRENT_NAMESPACE=$(kubectl config view --minify -o jsonpath='{..namespace}' || echo 'default')
echo "K8s Context: $CURRENT_CONTEXT"
echo "Namespace: $CURRENT_NAMESPACE"
# If context suggests different environment, prompt to switch
# Example: User mentions "production namespace" but current context is "staging-cluster"
# Detect from query context and prompt:
# echo "Query mentions 'production' but current context is '$CURRENT_CONTEXT'"
# echo "Switch to production context? Run: kubectl config use-context prod-cluster"
# read -p "Continue with current context? (y/n) " -n 1 -r
Follow this approach for effective Kubernetes debugging:
kubectl get pods -n <namespace>kubectl describe pod <pod-name> -n <namespace> (events at bottom)kubectl logs <pod-name> -n <namespace>kubectl logs <pod-name> --previous -n <namespace># Step 1: Check pod status
kubectl get pods -n production -l app=api-gateway
# Step 2: If pod is failing, describe for events
kubectl describe pod api-gateway-abc123 -n production
# Look at Events section at bottom for errors
# Step 3: If pod running but misbehaving, check logs
kubectl logs api-gateway-abc123 -n production --tail=200
# Step 4: If pod crashed/restarted, check previous logs
kubectl logs api-gateway-abc123 --previous -n production
# Step 5: Check namespace events for broader context
kubectl get events -n production --sort-by='.lastTimestamp' | tail -20
For large outputs or correlation with other tools, save to tmp file:
# Save pod list to tmp file
kubectl get pods -n production -o json > /tmp/k8s-pods-$(date +%Y%m%d-%H%M%S).json
# Save logs for offline analysis
kubectl logs api-gateway-xyz -n production --tail=1000 > /tmp/api-gateway-logs-$(date +%Y%m%d-%H%M%S).log
# Save events for correlation
kubectl get events -n production --sort-by='.lastTimestamp' > /tmp/k8s-events-$(date +%Y%m%d-%H%M%S).txt
# Then analyze or correlate with GCP logs
grep -i error /tmp/api-gateway-logs-*.log
Benefits:
For detailed command reference, see:
# Get pods in namespace
kubectl get pods -n <namespace>
# Describe pod (includes events)
kubectl describe pod <pod-name> -n <namespace>
# Get pod logs
kubectl logs <pod-name> -n <namespace> --tail=200
# Get previous logs (after crash)
kubectl logs <pod-name> --previous -n <namespace>
# Get events
kubectl get events -n <namespace> --sort-by='.lastTimestamp'
-n <namespace> for all commands or set default: kubectl config set-context --current --namespace=<namespace>--all-namespaces or -A to search across all namespaces-l for label selectors: -l app=api,tier=frontend--field-selector for field-based filtering (e.g., status.phase=Failed)-o wide for additional columns (pod IP, node name)-o json or -o yaml for full resource definitions