← 返回 Skills 市场
jokerzeng

K8s Yaml Connect

作者 JokerZeng · GitHub ↗ · v1.0.0 · MIT-0
cross-platform ✓ 安全检测通过
112
总下载
0
收藏
0
当前安装
1
版本数
在 OpenClaw 中安装
/install k8s-yaml-connect
功能描述
Connect to Kubernetes clusters using YAML configuration files. Use when you need to apply, validate, or manage Kubernetes resources via kubectl with YAML inp...
使用说明 (SKILL.md)

Kubernetes YAML Connect Skill

This skill enables connection to Kubernetes clusters using YAML configuration files as input. It provides tools to apply, validate, and manage Kubernetes resources through kubectl commands.

When to Use

Use this skill when:

  • You have Kubernetes YAML configuration files that need to be applied to a cluster
  • You need to validate YAML syntax before deployment
  • You want to create or update kubeconfig from YAML input
  • You need to switch between Kubernetes contexts
  • You want to check cluster status and resources

Prerequisites

Required

  • kubectl must be installed and available in PATH
  • Kubernetes cluster accessible (local or remote)
  • Appropriate permissions for the target cluster

Installing kubectl

If kubectl is not installed, you can install it using:

macOS:

# Using Homebrew
brew install kubectl

# Or download directly
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/darwin/amd64/kubectl"
chmod +x kubectl
sudo mv kubectl /usr/local/bin/

Linux:

# Using package manager (Ubuntu/Debian)
sudo apt-get update
sudo apt-get install -y kubectl

# Or download directly
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/

Windows:

# Using Chocolatey
choco install kubernetes-cli

# Or download from official release

Verify installation:

kubectl version --client

Core Workflow

1. Validate YAML Syntax

Before applying any YAML, always validate the syntax:

kubectl apply --dry-run=client -f - \x3C\x3C'EOF'
[YAML_CONTENT]
EOF

2. Apply YAML to Cluster

Apply validated YAML to the current context:

kubectl apply -f - \x3C\x3C'EOF'
[YAML_CONTENT]
EOF

3. Create/Update Kubeconfig from YAML

If you have kubeconfig YAML, save it and update context:

# Save kubeconfig
cat > /tmp/kubeconfig.yaml \x3C\x3C'EOF'
[KUBECONFIG_YAML]
EOF

# Set KUBECONFIG environment variable
export KUBECONFIG=/tmp/kubeconfig.yaml

# Verify connection
kubectl cluster-info

4. Context Management

List and switch contexts:

# List available contexts
kubectl config get-contexts

# Switch to specific context
kubectl config use-context [CONTEXT_NAME]

# Get current context
kubectl config current-context

Common Operations

Deploy a Deployment

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
spec:
  replicas: 3
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:1.14.2
        ports:
        - containerPort: 80

Create a Service

apiVersion: v1
kind: Service
metadata:
  name: nginx-service
spec:
  selector:
    app: nginx
  ports:
    - protocol: TCP
      port: 80
      targetPort: 80
  type: LoadBalancer

Create a ConfigMap

apiVersion: v1
kind: ConfigMap
metadata:
  name: app-config
data:
  APP_ENV: "production"
  LOG_LEVEL: "info"

Error Handling

Check for Common Issues

# Check if kubectl is installed
command -v kubectl

# Check cluster connectivity
kubectl version --short

# Check if context is set
kubectl config view --minify

Validate YAML Before Applying

Always use dry-run first to catch errors:

kubectl apply --dry-run=client -f [FILE_OR_STDIN]

Security Considerations

  1. Never commit sensitive data in YAML files (use Secrets or external config)
  2. Validate YAML from untrusted sources before applying
  3. Use namespaces to isolate resources
  4. Apply least privilege RBAC permissions

Examples

Example 1: Apply Simple Deployment

# YAML content as variable
YAML_CONTENT=$(cat \x3C\x3C'EOF'
apiVersion: apps/v1
kind: Deployment
metadata:
  name: test-deployment
spec:
  replicas: 2
  selector:
    matchLabels:
      app: test
  template:
    metadata:
      labels:
        app: test
    spec:
      containers:
      - name: test
        image: nginx:alpine
EOF
)

# Apply to cluster
kubectl apply -f - \x3C\x3C\x3C "$YAML_CONTENT"

Example 2: Multi-resource YAML

kubectl apply -f - \x3C\x3C'EOF'
---
apiVersion: v1
kind: ConfigMap
metadata:
  name: app-config
data:
  key: value
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: app-deployment
spec:
  replicas: 2
  selector:
    matchLabels:
      app: myapp
  template:
    metadata:
      labels:
        app: myapp
    spec:
      containers:
      - name: app
        image: myapp:latest
        envFrom:
        - configMapRef:
            name: app-config
EOF

References

For more detailed information, see:

Troubleshooting

Common Issues

  1. Connection refused: Check if cluster is running and accessible
  2. Unauthorized: Verify kubeconfig and permissions
  3. YAML syntax error: Validate YAML with kubectl apply --dry-run
  4. Resource already exists: Use kubectl apply for updates or kubectl replace for forced updates

Debug Commands

# Get detailed error information
kubectl describe [RESOURCE_TYPE] [RESOURCE_NAME]

# Check events
kubectl get events --sort-by='.lastTimestamp'

# Check pod logs
kubectl logs [POD_NAME]

Remember: Always test YAML in a non-production environment first when possible.

安全使用建议
This skill appears to do what it claims, but take these precautions before using it: - Ensure kubectl is installed locally and you understand the cluster you will target. kubectl will contact whatever cluster the kubeconfig points to. - Kubeconfig files contain credentials: only provide kubeconfig YAML from trusted sources and prefer using the -t/--temp option when testing. - The scripts will create files in your home (~/.kube/...) and print commands to merge configs or export KUBECONFIG; they do not automatically update your shell profiles but will show commands that, if executed, make changes permanent. - Validate any YAML from external sources (use dry-run) to avoid applying malicious workloads to your clusters. - If you need higher assurance, inspect the scripts locally and run them in a non-production environment first.
功能分析
Type: OpenClaw Skill Name: k8s-yaml-connect Version: 1.0.0 The skill provides a set of utility scripts and instructions for managing Kubernetes clusters using kubectl. It includes functionality for validating YAML manifests, applying resources to a cluster, and managing kubeconfig files (scripts/apply-yaml.sh, scripts/set-kubeconfig.sh, scripts/validate-yaml.sh). The behavior is transparent, well-documented, and aligns with the stated purpose of Kubernetes resource management without any signs of malicious intent, data exfiltration, or unauthorized persistence.
能力评估
Purpose & Capability
Name/description (apply/validate/manage Kubernetes YAML and kubeconfig) align with included scripts and README. Requiring kubectl and tools like kubeval/yamllint is expected for this functionality. package.json lists kubectl as a peerDependency (informational) — reasonable though kubectl is not an npm package.
Instruction Scope
SKILL.md and scripts explicitly describe running kubectl commands, validating YAML, and creating/updating kubeconfig files. The scripts read stdin or files and call kubectl/kubeval/yamllint as needed. They do not instruct the agent to read unrelated system files or send data to external endpoints beyond normal kubectl communication with the cluster.
Install Mechanism
No automated install/download steps are included; scripts are local and instruction-only. SKILL.md gives legitimate kubectl installation examples using official release URLs/package managers (dl.k8s.io, brew, apt, choco). No arbitrary remote URLs or archive extraction performed by the skill itself.
Credentials
The skill declares no required env vars, which matches the registry metadata, but runtime use relies on KUBECONFIG and $HOME (for writing kubeconfig files). This is proportionate for kubeconfig management, but kubeconfig files can contain cluster credentials—users should avoid providing kubeconfigs from untrusted sources.
Persistence & Privilege
Scripts create files under the user's home (e.g., ~/.kube/config-<timestamp>) or temporary files and print commands to merge or export KUBECONFIG. The skill does not automatically modify shell profiles or other skills' configurations, nor is it forced to always load (always:false). Users should be aware the scripts can create/replace kubeconfig files if run with non-temp options.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install k8s-yaml-connect
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /k8s-yaml-connect 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.0
- Initial release of k8s-yaml-connect. - Enables connecting to Kubernetes clusters using YAML configuration files. - Supports applying, validating, and managing Kubernetes resources via kubectl with YAML input. - Handles kubeconfig creation, context switching, and resource deployment from YAML. - Includes troubleshooting steps, best practices, and security considerations.
元数据
Slug k8s-yaml-connect
版本 1.0.0
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 1
常见问题

K8s Yaml Connect 是什么?

Connect to Kubernetes clusters using YAML configuration files. Use when you need to apply, validate, or manage Kubernetes resources via kubectl with YAML inp... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 112 次。

如何安装 K8s Yaml Connect?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install k8s-yaml-connect」即可一键安装,无需额外配置。

K8s Yaml Connect 是免费的吗?

是的,K8s Yaml Connect 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

K8s Yaml Connect 支持哪些平台?

K8s Yaml Connect 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 K8s Yaml Connect?

由 JokerZeng(@jokerzeng)开发并维护,当前版本 v1.0.0。

💬 留言讨论