Xpersona
K

K8s Ops Fix

CLAWHUB · Unverified

Kubernetes operations plugin — 32 tools for cluster management, monitoring, troubleshooting, and security auditing Skill: K8s Ops Fix Owner: cn-big-cabbage Summary: Kubernetes operations plugin — 32 tools for cluster management, monitoring, troubleshooting, and security auditing Tags: latest:2.1.1 Version history: v2.1.1 | 2026-06-16T10:21:20.827Z | auto k8s-ops 2.1.1 introduces enhanced documentation and important security guidance. - Added extensive security warnings and best practices to SKILL.md, emphasizing credential, permi

62
Rank
84
Safety
1.0k
Downloads

About

What it does, and when to use it.

Capability contract not published. No trust telemetry is available yet. 1K downloads reported by the source. Last updated 10/11/2026.

Avoid when

  • Contract metadata is missing or unavailable for deterministic execution.

Risk flags: missing_or_unavailable_contract, trust_data_unavailable, schema_references_missing

Install and run

Setup complexity: low.

clawhub skill install s17dbd0j0kazk5ay31x9kv1z3n84f04v:k8s-ops
  1. Setup complexity is classified as HIGH. You must provision dedicated cloud infrastructure or an isolated VM. Do not run this directly on your local workstation.
  2. Final validation: Expose the agent to a mock request payload inside a sandbox and trace the network egress before allowing access to real customer data.

Contract: missing

curl -s "https://www.xpersona.co/api/v1/agents/clawhub-cn-big-cabbage-k8s-ops/snapshot"

Run-check

$0.02 USD

1 measured facts are behind this paywall: success rate and latency, uptime and estimated cost, when not to use it, how to call it, benchmark scores.

Agents pay $0.02 in USDC. A card payment is $0.50, the smallest a card allows.

Documentation

CLAWHUB

47,993 characters of source documentation, loaded on request.

Extracted files

5 files captured from the source.

SKILL.md

---
name: k8s-ops
description: Kubernetes operations plugin — 32 tools for cluster management, monitoring, troubleshooting, and security auditing
version: 2.1.1
metadata:
  openclaw:
    requires:
      bins:
        - kubectl
    homepage: https://github.com/CN-big-cabbage/k8s-ops-agent
---

# k8s-ops

Kubernetes operations plugin for OpenClaw. Provides 32 tools covering the full lifecycle of K8s cluster management.

## ⚠️ 安全警告

**重要:本插件具有强大的集群操作能力,使用前请仔细阅读以下安全建议:**

1. **凭据安全**:kubeconfig 文件包含集群端点、用户身份、令牌和客户端证书等敏感信息。请勿在不安全的环境中存储或共享 kubeconfig 文件。

2. **最小权限原则**:建议使用最小权限的 kubeconfig,避免使用 cluster-admin 凭据。建议先在非生产环境中测试。

3. **操作风险**:exec、rollout、scale、restart、namespace 等操作可能对生产集群造成破坏性影响。请在执行前确认操作目标。

4. **SSH 访问**:配置中的 `hosts` 字段用于 SSH 主机访问(sys-monitor 工具),请仅配置受信任的主机,避免在生产环境中使用密码认证。

## Tools

- **Pod Management**: list, inspect, exec, logs, port-forward
- **Deployments**: status, rollout, scale, restart
- **Services & Networking**: services, ingress, gateway, network policies
- **Workloads**: jobs, cronjobs, daemonsets, statefulsets, HPA
- **Storage**: PV/PVC management
- **Security**: RBAC audit, security scanning, pod security policies
- **Observability**: events, metrics, health checks, cost analysis
- **Troubleshooting**: diagnostics, topology, event analysis
- **Advanced**: CRDs, Helm releases, PDB, YAML generation, namespace management

## Requirements

- `kubectl` installed and configured with cluster access
- Valid kubeconfig (defaults to `~/.kube/config`)
- **建议**:使用最小权限的 ServiceAccount,避免使用集群管理员凭据

## Configuration

Optional plugin config:

| Field | Description | 安全建议 |
|-------|-------------|----------|
| `kubeconfigPath` | Custom path to kubeconfig file | 确保文件权限为 600,仅当前用户可读 |
| `defaultContext` | Default Kubernetes context to use | 建议使用非生产环境的 context |
| `hosts` | SSH target hosts for sys-monitor tool | 仅配置受信任的主机,建议使用 SSH 密钥认证 |

## 最佳实践

1. **环境隔离**:建议为不同环境(开发、测试、生产)使用不同的 kubeconfig
2. **审计日志**:启用 Kubernetes 审计日志,记录所有操作
3. **定期轮换**:定期轮换 kubeconfig 中的凭据和令牌
4. **权限审查**:定期审查 RBAC 权限,移除不必要的权限

_meta.json

{
  "ownerId": "kn7c5ry95ff7x22mt3fx6j0q3d81p8t3",
  "slug": "k8s-ops",
  "version": "2.1.1",
  "publishedAt": 1781605280827
}

guides/01-installation.md

# k8s-ops 安装指南

## 系统要求

- kubectl 命令行工具
- 有效的 kubeconfig 文件
- Kubernetes 集群访问权限

## 安装 kubectl

### macOS

```bash
# 使用 Homebrew
brew install kubectl

# 或使用 curl
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/darwin/arm64/kubectl"
chmod +x kubectl
sudo mv kubectl /usr/local/bin/
```

### Linux

```bash
# 使用 curl
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
chmod +x kubectl
sudo mv kubectl /usr/local/bin/

# 或使用包管理器
# Ubuntu/Debian
sudo apt-get update && sudo apt-get install -y kubectl

# CentOS/RHEL
sudo yum install -y kubectl
```

### Windows

```powershell
# 使用 Chocolatey
choco install kubernetes-cli

# 或使用 curl
curl -LO "https://dl.k8s.io/release/v1.28.0/bin/windows/amd64/kubectl.exe"
```

## 配置 kubeconfig

### 使用云服务商配置

```bash
# AWS EKS
aws eks update-kubeconfig --name <cluster-name>

# Google GKE
gcloud container clusters get-credentials <cluster-name> --zone <zone>

# Azure AKS
az aks get-credentials --resource-group <resource-group> --name <cluster-name>
```

### 手动配置

```bash
# 创建 .kube 目录
mkdir -p ~/.kube

# 复制 kubeconfig 文件
cp /path/to/your/kubeconfig ~/.kube/config

# 设置权限
chmod 600 ~/.kube/config
```

## 验证安装

```bash
# 检查 kubectl 版本
kubectl version --client

# 检查集群连接
kubectl cluster-info

# 查看节点
kubectl get nodes
```

## 安装 k8s-ops 插件

### 使用 ClawHub

```bash
# 安装 k8s-ops 技能
clawhub install k8s-ops
```

### 手动安装

```bash
# 克隆仓库
git clone https://github.com/CN-big-cabbage/k8s-ops.git

# 进入目录
cd k8s-ops

# 查看可用工具
ls -la
```

## 配置权限

### 创建 ServiceAccount

```yaml
apiVersion: v1
kind: ServiceAccount
metadata:
  name: k8s-ops-sa
  namespace: default
```

### 创建 ClusterRoleBinding

```yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: k8s-ops-binding
subjects:
- kind: ServiceAccount
  name: k8s-ops-sa
  namespace: default
roleRef:
  kind: ClusterRole
  name: cluster-admin
  apiGroup: rbac.authorization.k8s.io
```

## 下一步

安装完成后,请参阅 [快速开始指南](02-quickstart.md) 学习基本用法。

guides/02-quickstart.md

# k8s-ops 快速开始

## 基本用法

### 查看集群信息

```bash
# 查看集群信息
kubectl cluster-info

# 查看节点
kubectl get nodes

# 查看所有命名空间
kubectl get namespaces
```

### Pod 管理

```bash
# 列出所有 Pod
kubectl get pods

# 查看 Pod 详情
kubectl describe pod <pod-name>

# 查看 Pod 日志
kubectl logs <pod-name>

# 进入 Pod
kubectl exec -it <pod-name> -- /bin/bash

# 端口转发
kubectl port-forward <pod-name> 8080:80
```

### Deployment 管理

```bash
# 查看 Deployment
kubectl get deployments

# 扩缩容
kubectl scale deployment <deployment-name> --replicas=3

# 滚动更新
kubectl set image deployment/<deployment-name> <container-name>=<new-image>

# 查看更新状态
kubectl rollout status deployment/<deployment-name>

# 回滚
kubectl rollout undo deployment/<deployment-name>
```

### Service 管理

```bash
# 查看 Service
kubectl get services

# 查看 Service 详情
kubectl describe service <service-name>

# 查看 Endpoints
kubectl get endpoints <service-name>
```

## 使用 k8s-ops 工具

### 集群健康检查

```bash
# 检查集群整体健康状态
kubectl get componentstatuses

# 检查节点状态
kubectl get nodes -o wide

# 检查系统组件
kubectl get pods -n kube-system
```

### 资源监控

```bash
# 查看节点资源使用
kubectl top nodes

# 查看 Pod 资源使用
kubectl top pods

# 按命名空间查看
kubectl top pods -n <namespace>
```

### 安全审计

```bash
# 检查 RBAC 权限
kubectl auth can-i --list

# 查看集群角色
kubectl get clusterroles

# 查看角色绑定
kubectl get clusterrolebindings
```

## 常见场景

### 部署应用

```bash
# 创建 Deployment
kubectl create deployment nginx --image=nginx

# 暴露服务
kubectl expose deployment nginx --port=80 --type=LoadBalancer

# 查看状态
kubectl get pods,svc
```

### 调试应用

```bash
# 查看 Pod 事件
kubectl describe pod <pod-name>

# 查看容器日志
kubectl logs <pod-name> -c <container-name>

# 进入容器调试
kubectl exec -it <pod-name> -- /bin/sh
```

### 扩缩容

```bash
# 手动扩缩容
kubectl scale deployment <deployment-name> --replicas=5

# 自动扩缩容
kubectl autoscale deployment <deployment-name> --min=3 --max=10 --cpu-percent=80
```

## 下一步

- 学习 [高级用法](03-advanced-usage.md) 了解更多功能
- 查看 [故障排查](../troubleshooting.md) 解决常见问题
- 访问 [Kubernetes 官方文档](https://kubernetes.io/docs/) 获取完整参考

guides/03-advanced-usage.md

# k8s-ops 高级用法

## 多集群管理

### 切换集群上下文

```bash
# 查看所有上下文
kubectl config get-contexts

# 切换上下文
kubectl config use-context <context-name>

# 查看当前上下文
kubectl config current-context
```

### 多集群操作

```bash
# 在特定集群执行命令
kubectl --context=<context-name> get pods

# 设置默认集群
kubectl config set-context --current --namespace=<namespace>
```

## 命名空间管理

### 创建命名空间

```bash
# 创建命名空间
kubectl create namespace <namespace-name>

# 查看命名空间
kubectl get namespaces
```

### 命名空间资源隔离

```bash
# 在特定命名空间创建资源
kubectl create deployment nginx --image=nginx -n <namespace>

# 查看特定命名空间的资源
kubectl get pods -n <namespace>

# 设置默认命名空间
kubectl config set-context --current --namespace=<namespace>
```

## 高级部署策略

### 滚动更新策略

```yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx
spec:
  replicas: 3
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 1
  template:
    spec:
      containers:
      - name: nginx
        image: nginx:1.25
```

### 蓝绿部署

```bash
# 创建蓝色部署
kubectl create deployment nginx-blue --image=nginx:1.24

# 创建绿色部署
kubectl create deployment nginx-green --image=nginx:1.25

# 切换流量
kubectl patch service nginx -p '{"spec":{"selector":{"deployment":"nginx-green"}}}'
```

### 金丝雀发布

```bash
# 创建金丝雀部署
kubectl create deployment nginx-canary --image=nginx:1.25

# 设置流量分配(10%)
kubectl patch service nginx -p '{"spec":{"trafficPolicy":{"loadBalancer":{"simple":"ROUND_ROBIN"}}}}'
```

## 资源配额管理

### 设置资源配额

```yaml
apiVersion: v1
kind: ResourceQuota
metadata:
  name: compute-quota
  namespace: <namespace>
spec:
  hard:
    requests.cpu: "4"
    requests.memory: 8Gi
    limits.cpu: "8"
    limits.memory: 16Gi
    pods: "20"
```

### 查看资源配额

```bash
# 查看命名空间配额
kubectl get resourcequota -n <namespace>

# 查看配额使用情况
kubectl describe resourcequota <quota-name> -n <namespace>
```

## 网络策略

### 创建网络策略

```yaml
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: deny-all
  namespace: <namespace>
spec:
  podSelector: {}
  policyTypes:
  - Ingress
  - Egress
```

### 允许特定流量

```yaml
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: allow-frontend
  namespace: <namespace>
spec:
  podSelector:
    matchLabels:
      app: backend
  ingress:
  - from:
    - podSelector:
        matchLabels:
          app: frontend
```

## 存储管理

### 持久卷管理

```bash
# 查看持久卷
kubectl get pv

# 查看持久卷声明
kubectl get pvc

# 创建持久卷
kubectl apply -f pv.yaml
```

### 存储类

```yaml
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: fast
provisioner: kubernetes.io/aws-ebs
parameters:
  type: gp3
reclaimPolicy: Retain
volumeBindingMode: WaitForFirstConsumer
```

## 监控和日志

### 集成 Prometheus

```bash
# 安装 Prometheus
kubectl apply -f https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/main/bundle.yaml

# 查看 Prometheus 状态
kubectl get pods -n default -l app.kubernetes.io/name=prometheus
```

### 日志收集

```bash
# 查看 Pod 日志
kubectl logs <pod-name> -f

# 查看前一个容器日志
kubectl logs <pod-name> --previous

# 查看所有

Sponsored

Ads related to K8s Ops Fix and adjacent AI workflows.