k8s-operations
kubectl operations for applying, patching, deleting, and executing commands on Kubernetes resources. Use when modifying resources, running commands in pods, or managing resource lifecycle.
Best use case
k8s-operations is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
kubectl operations for applying, patching, deleting, and executing commands on Kubernetes resources. Use when modifying resources, running commands in pods, or managing resource lifecycle.
Teams using k8s-operations should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/k8s-operations/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How k8s-operations Compares
| Feature / Agent | k8s-operations | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
kubectl operations for applying, patching, deleting, and executing commands on Kubernetes resources. Use when modifying resources, running commands in pods, or managing resource lifecycle.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# kubectl Operations
Execute kubectl commands using kubectl-mcp-server's operations tools.
## When to Apply
Use this skill when:
- User mentions: "apply", "patch", "delete", "exec", "scale", "rollout"
- Operations: modifying resources, running commands, scaling workloads
- Keywords: "update", "change", "modify", "run command", "restart"
## Priority Rules
| Priority | Rule | Impact | Tools |
|----------|------|--------|-------|
| 1 | Dry run before apply in production | CRITICAL | `kubectl_apply(dry_run=True)` |
| 2 | Check current state before patching | HIGH | `describe_*` tools |
| 3 | Avoid force delete unless necessary | HIGH | `kubectl_delete` |
| 4 | Verify rollout status after changes | MEDIUM | `kubectl_rollout_status` |
## Quick Reference
| Task | Tool | Example |
|------|------|---------|
| Apply manifest | `kubectl_apply` | `kubectl_apply(manifest=yaml)` |
| Patch resource | `kubectl_patch` | `kubectl_patch(type, name, namespace, patch)` |
| Delete resource | `kubectl_delete` | `kubectl_delete(type, name, namespace)` |
| Exec command | `kubectl_exec` | `kubectl_exec(pod, namespace, command)` |
| Scale deployment | `scale_deployment` | `scale_deployment(name, namespace, replicas)` |
## Apply Resources
```python
kubectl_apply(manifest="""
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx
namespace: default
spec:
replicas: 3
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:latest
""")
kubectl_apply(file_path="/path/to/manifest.yaml")
kubectl_apply(manifest="...", dry_run=True)
```
## Patch Resources
```python
kubectl_patch(
resource_type="deployment",
name="nginx",
namespace="default",
patch={"spec": {"replicas": 5}}
)
kubectl_patch(
resource_type="deployment",
name="nginx",
namespace="default",
patch=[{"op": "replace", "path": "/spec/replicas", "value": 5}],
patch_type="json"
)
kubectl_patch(
resource_type="service",
name="my-svc",
namespace="default",
patch={"metadata": {"annotations": {"key": "value"}}},
patch_type="merge"
)
```
## Delete Resources
```python
kubectl_delete(resource_type="pod", name="my-pod", namespace="default")
kubectl_delete(
resource_type="pods",
namespace="default",
label_selector="app=test"
)
kubectl_delete(
resource_type="pod",
name="stuck-pod",
namespace="default",
force=True,
grace_period=0
)
```
## Execute Commands
```python
kubectl_exec(
pod="my-pod",
namespace="default",
command="ls -la /app"
)
kubectl_exec(
pod="my-pod",
namespace="default",
container="sidecar",
command="cat /etc/config/settings.yaml"
)
kubectl_exec(
pod="my-pod",
namespace="default",
command="sh -c 'curl -s localhost:8080/health'"
)
```
## Scale Resources
```python
scale_deployment(name="nginx", namespace="default", replicas=5)
scale_deployment(name="nginx", namespace="default", replicas=0)
kubectl_scale(
resource_type="statefulset",
name="mysql",
namespace="default",
replicas=3
)
```
## Rollout Management
```python
kubectl_rollout_status(
resource_type="deployment",
name="nginx",
namespace="default"
)
kubectl_rollout_history(
resource_type="deployment",
name="nginx",
namespace="default"
)
kubectl_rollout_restart(
resource_type="deployment",
name="nginx",
namespace="default"
)
rollback_deployment(name="nginx", namespace="default", revision=1)
```
## Labels and Annotations
```python
kubectl_label(
resource_type="pod",
name="my-pod",
namespace="default",
labels={"env": "production"}
)
kubectl_annotate(
resource_type="deployment",
name="nginx",
namespace="default",
annotations={"description": "Main web server"}
)
```
## Related Skills
- [k8s-deploy](../k8s-deploy/SKILL.md) - Deployment strategies
- [k8s-helm](../k8s-helm/SKILL.md) - Helm operationsRelated Skills
k8s-vind
Manage vCluster (virtual Kubernetes clusters) instances using vind. Use when creating, managing, or operating lightweight virtual clusters for development, testing, or multi-tenancy.
k8s-troubleshoot
Debug Kubernetes pods, nodes, and workloads. Use when pods are failing, containers crash, nodes are unhealthy, or users mention debugging, troubleshooting, or diagnosing Kubernetes issues.
k8s-storage
Kubernetes storage management for PVCs, storage classes, and persistent volumes. Use when provisioning storage, managing volumes, or troubleshooting storage issues.
k8s-service-mesh
Manage Istio service mesh for traffic management, security, and observability. Use for traffic shifting, canary releases, mTLS, and service mesh troubleshooting.
k8s-security
Audit Kubernetes RBAC, enforce policies, and manage secrets. Use for security reviews, permission audits, policy enforcement with Kyverno/Gatekeeper, and secret management.
k8s-rollouts
Progressive delivery with Argo Rollouts and Flagger. Use when implementing canary deployments, blue-green deployments, or traffic shifting strategies.
k8s-policy
Kubernetes policy management with Kyverno and Gatekeeper. Use when enforcing security policies, validating resources, or auditing policy compliance.
k8s-networking
Kubernetes networking management for services, ingresses, endpoints, and network policies. Use when configuring connectivity, load balancing, or network isolation.
k8s-multicluster
Manage multiple Kubernetes clusters, switch contexts, and perform cross-cluster operations. Use when working with multiple clusters, comparing environments, or managing cluster lifecycle.
k8s-kubevirt
Virtual machine management with KubeVirt on Kubernetes. Use when creating, managing, or troubleshooting VMs running on Kubernetes clusters.
k8s-kind
Manage kind (Kubernetes IN Docker) local clusters. Use when creating, testing, or developing with local Kubernetes clusters in Docker containers.
k8s-incident
Respond to Kubernetes incidents with runbooks and diagnostics. Use for outages, pod failures, node issues, network problems, and emergency response.