home / skills / ntaksh42 / agents / kubernetes-helper

kubernetes-helper skill

/.claude/skills/kubernetes-helper

This skill helps you generate Kubernetes manifests and Helm charts with best practices, plus troubleshooting tips for deployments, services, and ingress.

npx playbooks add skill ntaksh42/agents --skill kubernetes-helper

Review the files below or copy the command above to add this skill to your agents.

Files (1)
SKILL.md
3.1 KB
---
name: kubernetes-helper
description: Generate and manage Kubernetes manifests including deployments, services, and ingress. Use when deploying applications to Kubernetes or managing k8s resources.
---

# Kubernetes Helper Skill

Kubernetesマニフェストとコマンドを生成するスキルです。

## 概要

Deployment、Service、ConfigMap等のマニフェストを自動生成します。

## 主な機能

- **マニフェスト生成**: Deployment、Service、Ingress等
- **ベストプラクティス**: リソース制限、ヘルスチェック
- **Helm Charts**: チャート生成
- **トラブルシューティング**: よくある問題の解決

## 生成例

### Deployment

```yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: myapp
  labels:
    app: myapp
spec:
  replicas: 3
  selector:
    matchLabels:
      app: myapp
  template:
    metadata:
      labels:
        app: myapp
    spec:
      containers:
      - name: myapp
        image: myapp:1.0.0
        ports:
        - containerPort: 8080
        env:
        - name: DATABASE_URL
          valueFrom:
            secretKeyRef:
              name: myapp-secrets
              key: database-url
        resources:
          requests:
            memory: "128Mi"
            cpu: "100m"
          limits:
            memory: "256Mi"
            cpu: "200m"
        livenessProbe:
          httpGet:
            path: /health
            port: 8080
          initialDelaySeconds: 30
          periodSeconds: 10
        readinessProbe:
          httpGet:
            path: /ready
            port: 8080
          initialDelaySeconds: 5
          periodSeconds: 5
```

### Service

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

### ConfigMap

```yaml
apiVersion: v1
kind: ConfigMap
metadata:
  name: myapp-config
data:
  app.conf: |
    server {
      listen 80;
      server_name example.com;
    }
  database.yml: |
    production:
      adapter: postgresql
      database: myapp
```

### Secret

```yaml
apiVersion: v1
kind: Secret
metadata:
  name: myapp-secrets
type: Opaque
stringData:
  database-url: postgresql://user:pass@host:5432/db
  api-key: sk_live_abc123
```

### Ingress

```yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: myapp-ingress
  annotations:
    cert-manager.io/cluster-issuer: letsencrypt
spec:
  tls:
  - hosts:
    - example.com
    secretName: myapp-tls
  rules:
  - host: example.com
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: myapp-service
            port:
              number: 80
```

## よく使うコマンド

```bash
# Podの確認
kubectl get pods

# ログ確認
kubectl logs <pod-name>

# Podに入る
kubectl exec -it <pod-name> -- /bin/sh

# マニフェスト適用
kubectl apply -f deployment.yaml

# リソース削除
kubectl delete -f deployment.yaml

# スケーリング
kubectl scale deployment myapp --replicas=5
```

## バージョン情報

- スキルバージョン: 1.0.0

Overview

This skill generates and manages Kubernetes manifests and common kubectl commands for deploying applications to Kubernetes clusters. It produces Deployments, Services, Ingress, ConfigMaps, Secrets, and can suggest Helm chart structure and troubleshooting steps. Use it to accelerate manifest creation and enforce practical defaults like resource limits and health checks.

How this skill works

The skill inspects requested application parameters (image, ports, env, replicas, secrets) and outputs ready-to-apply YAML manifests for Deployment, Service, ConfigMap, Secret, and Ingress. It incorporates best-practice settings such as resource requests/limits, liveness/readiness probes, and TLS-ready Ingress annotations. It can also output common kubectl commands for applying, debugging, and scaling resources.

When to use it

  • When creating deployment manifests for a new application
  • When converting app settings into ConfigMap/Secret and deployment YAML
  • When adding health checks, resource limits, or autoscaling hints
  • When generating TLS-enabled Ingress rules or LoadBalancer services
  • When you need quick kubectl commands for troubleshooting and operations

Best practices

  • Define resource requests and limits to improve scheduling and stability
  • Add liveness and readiness probes to detect and manage unhealthy pods
  • Keep secrets out of plain manifests; prefer stringData or external secret stores
  • Use labels and selectors consistently for service-targeting and management
  • Annotate Ingress with certificate issuer and use TLS for production traffic

Example use cases

  • Generate a Deployment and Service for a web app listening on port 8080 with 3 replicas and probes
  • Create a ConfigMap for application configuration files and a Secret for database credentials
  • Produce an Ingress with cert-manager annotations and TLS secret for a domain
  • Output kubectl commands to apply manifests, view pod logs, exec into pods, and scale deployments
  • Create a basic Helm chart scaffold for an app with values for image, replicas, and service type

FAQ

Can the skill include secrets in manifests?

It can generate Secret manifests using stringData for convenience, but for production prefer external secret stores or sealed secrets to avoid exposing sensitive data in repo history.

Will generated manifests include health checks and resource limits?

Yes. The skill adds sensible default liveness/readiness probes and CPU/memory requests and limits that you can adjust to match your workload.