k8s-capi
Cluster API lifecycle management for provisioning, scaling, and upgrading Kubernetes clusters. Use when managing cluster infrastructure or multi-cluster operations.
Packaged view
This page reorganizes the original catalog entry around fit, installability, and workflow context first. The original raw source lives below.
Install command
npx @skill-hub/cli install rohitg00-kubectl-mcp-server-k8s-capi
Repository
Skill path: kubernetes-skills/claude/k8s-capi
Cluster API lifecycle management for provisioning, scaling, and upgrading Kubernetes clusters. Use when managing cluster infrastructure or multi-cluster operations.
Open repositoryBest for
Primary workflow: Run DevOps.
Technical facets: Full Stack, Backend, DevOps.
Target audience: everyone.
License: Apache-2.0.
Original source
Catalog source: SkillHub Club.
Repository owner: rohitg00.
This is still a mirrored public skill entry. Review the repository before installing into production workflows.
What it helps with
- Install k8s-capi into Claude Code, Codex CLI, Gemini CLI, or OpenCode workflows
- Review https://github.com/rohitg00/kubectl-mcp-server before adding k8s-capi to shared team environments
- Use k8s-capi for development workflows
Works across
Favorites: 0.
Sub-skills: 0.
Aggregator: No.
Original source / Raw SKILL.md
---
name: k8s-capi
description: Cluster API lifecycle management for provisioning, scaling, and upgrading Kubernetes clusters. Use when managing cluster infrastructure or multi-cluster operations.
license: Apache-2.0
metadata:
author: rohitg00
version: "1.0.0"
tools: 11
category: infrastructure
---
# Cluster API Lifecycle Management
Manage Kubernetes clusters using kubectl-mcp-server's Cluster API tools (11 tools).
## When to Apply
Use this skill when:
- User mentions: "Cluster API", "CAPI", "cluster lifecycle", "machine", "workload cluster"
- Operations: provisioning clusters, scaling nodes, upgrading Kubernetes versions
- Keywords: "provision cluster", "scale workers", "machine deployment", "cluster class"
## Priority Rules
| Priority | Rule | Impact | Tools |
|----------|------|--------|-------|
| 1 | Detect CAPI installation first | CRITICAL | `capi_detect_tool` |
| 2 | Check cluster phase before operations | HIGH | `capi_cluster_get_tool` |
| 3 | Monitor machines during scaling | HIGH | `capi_machines_list_tool` |
| 4 | Get kubeconfig after provisioning | MEDIUM | `capi_cluster_kubeconfig_tool` |
## Quick Reference
| Task | Tool | Example |
|------|------|---------|
| Detect CAPI | `capi_detect_tool` | `capi_detect_tool()` |
| List clusters | `capi_clusters_list_tool` | `capi_clusters_list_tool(namespace)` |
| Get cluster kubeconfig | `capi_cluster_kubeconfig_tool` | `capi_cluster_kubeconfig_tool(name, namespace)` |
| Scale workers | `capi_machinedeployment_scale_tool` | `capi_machinedeployment_scale_tool(name, namespace, replicas)` |
## Check Installation
```python
capi_detect_tool()
```
## List Clusters
```python
# List all CAPI clusters
capi_clusters_list_tool(namespace="default")
# Shows:
# - Cluster name
# - Phase (Provisioning, Provisioned, Deleting)
# - Infrastructure ready
# - Control plane ready
```
## Get Cluster Details
```python
capi_cluster_get_tool(name="my-cluster", namespace="default")
# Shows:
# - Spec (control plane, infrastructure)
# - Status (phase, conditions)
# - Network configuration
```
## Get Cluster Kubeconfig
```python
# Get kubeconfig for workload cluster
capi_cluster_kubeconfig_tool(name="my-cluster", namespace="default")
# Returns kubeconfig to access the cluster
```
## Machines
### List Machines
```python
capi_machines_list_tool(namespace="default")
# Shows:
# - Machine name
# - Cluster
# - Phase (Running, Provisioning, Failed)
# - Provider ID
# - Version
```
### Get Machine Details
```python
capi_machine_get_tool(name="my-cluster-md-0-xxx", namespace="default")
```
## Machine Deployments
### List Machine Deployments
```python
capi_machinedeployments_list_tool(namespace="default")
# Shows:
# - Deployment name
# - Cluster
# - Replicas (ready/total)
# - Version
```
### Scale Machine Deployment
```python
# Scale worker nodes
capi_machinedeployment_scale_tool(
name="my-cluster-md-0",
namespace="default",
replicas=5
)
```
## Machine Sets
```python
capi_machinesets_list_tool(namespace="default")
```
## Machine Health Checks
```python
capi_machinehealthchecks_list_tool(namespace="default")
# Health checks automatically remediate unhealthy machines
```
## Cluster Classes
```python
# List cluster templates
capi_clusterclasses_list_tool(namespace="default")
# ClusterClasses define reusable cluster configurations
```
## Create Cluster
```python
kubectl_apply(manifest="""
apiVersion: cluster.x-k8s.io/v1beta1
kind: Cluster
metadata:
name: my-cluster
namespace: default
spec:
clusterNetwork:
pods:
cidrBlocks:
- 192.168.0.0/16
services:
cidrBlocks:
- 10.96.0.0/12
controlPlaneRef:
apiVersion: controlplane.cluster.x-k8s.io/v1beta1
kind: KubeadmControlPlane
name: my-cluster-control-plane
infrastructureRef:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: AWSCluster
name: my-cluster
""")
```
## Create Machine Deployment
```python
kubectl_apply(manifest="""
apiVersion: cluster.x-k8s.io/v1beta1
kind: MachineDeployment
metadata:
name: my-cluster-md-0
namespace: default
spec:
clusterName: my-cluster
replicas: 3
selector:
matchLabels:
cluster.x-k8s.io/cluster-name: my-cluster
template:
spec:
clusterName: my-cluster
version: v1.28.0
bootstrap:
configRef:
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
kind: KubeadmConfigTemplate
name: my-cluster-md-0
infrastructureRef:
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
kind: AWSMachineTemplate
name: my-cluster-md-0
""")
```
## Cluster Lifecycle Workflows
### Provision New Cluster
```python
1. kubectl_apply(cluster_manifest)
2. capi_clusters_list_tool(namespace) # Wait for Provisioned
3. capi_cluster_kubeconfig_tool(name, namespace) # Get access
```
### Scale Workers
```python
1. capi_machinedeployments_list_tool(namespace)
2. capi_machinedeployment_scale_tool(name, namespace, replicas)
3. capi_machines_list_tool(namespace) # Monitor
```
### Upgrade Cluster
```python
1. # Update control plane version
2. # Update machine deployment version
3. capi_machines_list_tool(namespace) # Monitor rollout
```
## Troubleshooting
### Cluster Stuck Provisioning
```python
1. capi_cluster_get_tool(name, namespace) # Check conditions
2. capi_machines_list_tool(namespace) # Check machine status
3. get_events(namespace) # Check events
4. # Check infrastructure provider logs
```
### Machine Failed
```python
1. capi_machine_get_tool(name, namespace)
2. get_events(namespace)
3. # Common issues:
# - Cloud provider quota
# - Invalid machine template
# - Network issues
```
## Related Skills
- [k8s-multicluster](../k8s-multicluster/SKILL.md) - Multi-cluster operations
- [k8s-operations](../k8s-operations/SKILL.md) - kubectl operations
---
## Referenced Files
> The following files are referenced in this skill and included for context.
### ../k8s-multicluster/SKILL.md
```markdown
---
name: k8s-multicluster
description: Manage multiple Kubernetes clusters, switch contexts, and perform cross-cluster operations. Use when working with multiple clusters, comparing environments, or managing cluster lifecycle.
license: Apache-2.0
metadata:
author: rohitg00
version: "1.0.0"
tools: 15
category: multicluster
---
# Multi-Cluster Kubernetes Management
Cross-cluster operations and context management using kubectl-mcp-server's multi-cluster support.
## When to Apply
Use this skill when:
- User mentions: "cluster", "context", "multi-cluster", "cross-cluster"
- Operations: switching contexts, comparing clusters, federated deployments
- Keywords: "different environment", "production vs staging", "all clusters"
## Priority Rules
| Priority | Rule | Impact | Tools |
|----------|------|--------|-------|
| 1 | Always specify context for prod | CRITICAL | `context` parameter |
| 2 | List contexts before switching | HIGH | `list_contexts_tool` |
| 3 | Compare before promoting | MEDIUM | `compare_namespaces` |
| 4 | Use naming conventions | LOW | `prod-*`, `staging-*` |
## Quick Reference
| Task | Tool | Example |
|------|------|---------|
| List contexts | `list_contexts_tool` | `list_contexts_tool()` |
| View kubeconfig | `kubeconfig_view` | `kubeconfig_view()` |
| List CAPI clusters | `capi_clusters_list_tool` | `capi_clusters_list_tool(namespace)` |
| Get CAPI kubeconfig | `capi_cluster_kubeconfig_tool` | `capi_cluster_kubeconfig_tool(name, namespace)` |
## Context Management
### List Available Contexts
```python
list_contexts_tool()
```
### View Current Context
```python
kubeconfig_view()
```
### Switch Context
CLI: `kubectl-mcp-server context <context-name>`
## Cross-Cluster Operations
All kubectl-mcp-server tools support the `context` parameter:
```python
get_pods(namespace="default", context="production-cluster")
get_pods(namespace="default", context="staging-cluster")
```
## Common Multi-Cluster Patterns
### Compare Environments
```python
compare_namespaces(
namespace1="production",
namespace2="staging",
resource_type="deployment",
context="production-cluster"
)
```
### Parallel Queries
Query multiple clusters simultaneously:
```python
get_pods(namespace="app", context="prod-us-east")
get_pods(namespace="app", context="prod-eu-west")
get_pods(namespace="app", context="development")
```
### Cross-Cluster Health Check
```python
for context in ["prod-1", "prod-2", "staging"]:
get_nodes(context=context)
get_pods(namespace="kube-system", context=context)
```
## Cluster API (CAPI) Management
For managing cluster lifecycle:
### List Managed Clusters
```python
capi_clusters_list_tool(namespace="capi-system")
```
### Get Cluster Details
```python
capi_cluster_get_tool(name="prod-cluster", namespace="capi-system")
```
### Get Workload Cluster Kubeconfig
```python
capi_cluster_kubeconfig_tool(name="prod-cluster", namespace="capi-system")
```
### Machine Management
```python
capi_machines_list_tool(namespace="capi-system")
capi_machinedeployments_list_tool(namespace="capi-system")
```
### Scale Cluster
```python
capi_machinedeployment_scale_tool(
name="prod-cluster-md-0",
namespace="capi-system",
replicas=5
)
```
See [CONTEXT-SWITCHING.md](CONTEXT-SWITCHING.md) for detailed patterns.
## Multi-Cluster Helm
Deploy charts to specific clusters:
```python
install_helm_chart(
name="nginx",
chart="bitnami/nginx",
namespace="web",
context="production-cluster"
)
list_helm_releases(
namespace="web",
context="staging-cluster"
)
```
## Multi-Cluster GitOps
### Flux Across Clusters
```python
flux_kustomizations_list_tool(
namespace="flux-system",
context="cluster-1"
)
flux_reconcile_tool(
kind="kustomization",
name="apps",
namespace="flux-system",
context="cluster-2"
)
```
### ArgoCD Across Clusters
```python
argocd_apps_list_tool(namespace="argocd", context="management-cluster")
```
## Federation Patterns
### Secret Synchronization
```python
get_secrets(namespace="app", context="source-cluster")
kubectl_apply(secret_manifest, namespace="app", context="target-cluster")
```
### Cross-Cluster Service Discovery
With Cilium ClusterMesh or Istio multi-cluster:
```python
cilium_nodes_list_tool(context="cluster-1")
istio_proxy_status_tool(context="cluster-2")
```
## Best Practices
1. **Naming Convention**: Use descriptive context names (`prod-us-east-1`, `staging-eu-west-1`)
2. **Access Control**: Different kubeconfigs per environment
3. **Always Specify Context**: Avoid accidental cross-cluster operations
4. **Cluster Groups**: Organize by purpose (`prod-*`, `staging-*`, `dev-*`)
## Related Skills
- [k8s-troubleshoot](../k8s-troubleshoot/SKILL.md) - Debug across clusters
- [k8s-gitops](../k8s-gitops/SKILL.md) - GitOps multi-cluster
- [k8s-capi](../k8s-capi/SKILL.md) - Cluster API management
```
### ../k8s-operations/SKILL.md
```markdown
---
name: k8s-operations
description: kubectl operations for applying, patching, deleting, and executing commands on Kubernetes resources. Use when modifying resources, running commands in pods, or managing resource lifecycle.
license: Apache-2.0
metadata:
author: rohitg00
version: "1.0.0"
tools: 14
category: operations
---
# 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 operations
```