Back to Skills

k8s-query

verified

Query Kubernetes resources (pods, deployments, services, events). Use when checking cluster state and resource status.

View on GitHub

Marketplace

eveld-claude

eveld/claude

Plugin

workflows

Repository

eveld/claude
3stars

skills/k8s-query/SKILL.md

Last Verified

January 23, 2026

Install Skill

Select agents to install to:

Scope:
npx add-skill https://github.com/eveld/claude/blob/main/skills/k8s-query/SKILL.md -a claude-code --skill k8s-query

Installation paths:

Claude
.claude/skills/k8s-query/
Powered by add-skill CLI

Instructions

# Query Kubernetes Resources

Check status of Kubernetes pods, deployments, services, and events.

## When to Use

- Checking if pods are running
- Viewing pod/deployment status
- Investigating pod failures or restarts
- Checking resource events and logs

## Pre-flight Checks

### Authentication and Context
```bash
# 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
```

## Common Commands

### 1. Get Resources
```bash
# Get all pods in namespace
kubectl get pods -n <namespace>

# Get pods with labels
kubectl get pods -n production -l app=api-gateway

# Get deployments
kubectl get deployments -n <namespace>

# Get services
kubectl get services -n <namespace>

# All resources
kubectl get all -n <namespace>
```

### 2. Describe Resources (Detailed Info)
```bash
# Describe pod
kubectl describe pod <pod-name> -n <namespace>

# Describe deployment
kubectl describe deployment <deployment-name> -n <namespace>

# Describe service
kubectl describe service <service-name> -n <namespace>
```

### 3. Get Logs
```bash
# Get pod logs (current)
kubectl logs <pod-name> -n <namespace>

# Get logs with tail limit
kubectl logs <pod-name> --tail=200 -n <namespace>

# Get previous container logs (after crash)
kubectl logs <pod-name> --previo

Validation Details

Front Matter
Required Fields
Valid Name Format
Valid Description
Has Sections
Allowed Tools
Instruction Length:
4050 chars