jpskill.com
🛠️ 開発・MCP コミュニティ

kubernetes

Kubernetesのデプロイ、サービス、ポッド、デバッグ、クラスター管理など、kubectlコマンドを用いたあらゆる操作を支援するSkill。

📜 元の英語説明(参考)

Kubernetes and kubectl mastery for deployments, services, pods, debugging, and cluster management. Use when user asks to "deploy to k8s", "create deployment", "debug pod", "kubectl commands", "scale service", "check pod logs", "create ingress", or any Kubernetes tasks.

🇯🇵 日本人クリエイター向け解説

一言でいうと

Kubernetesのデプロイ、サービス、ポッド、デバッグ、クラスター管理など、kubectlコマンドを用いたあらゆる操作を支援するSkill。

※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。

⚡ おすすめ: コマンド1行でインストール(60秒)

下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。

🍎 Mac / 🐧 Linux
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o kubernetes.zip https://jpskill.com/download/6099.zip && unzip -o kubernetes.zip && rm kubernetes.zip
🪟 Windows (PowerShell)
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/6099.zip -OutFile "$d\kubernetes.zip"; Expand-Archive "$d\kubernetes.zip" -DestinationPath $d -Force; ri "$d\kubernetes.zip"

完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。

💾 手動でダウンロードしたい(コマンドが難しい人向け)
  1. 1. 下の青いボタンを押して kubernetes.zip をダウンロード
  2. 2. ZIPファイルをダブルクリックで解凍 → kubernetes フォルダができる
  3. 3. そのフォルダを C:\Users\あなたの名前\.claude\skills\(Win)または ~/.claude/skills/(Mac)へ移動
  4. 4. Claude Code を再起動

⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。

🎯 このSkillでできること

下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。

📦 インストール方法 (3ステップ)

  1. 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
  2. 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
  3. 3. 展開してできたフォルダを、ホームフォルダの .claude/skills/ に置く
    • · macOS / Linux: ~/.claude/skills/
    • · Windows: %USERPROFILE%\.claude\skills\

Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。

詳しい使い方ガイドを見る →
最終更新
2026-05-17
取得日時
2026-05-17
同梱ファイル
1

📖 Skill本文(日本語訳)

※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。

Kubernetes

必須の kubectl コマンドと Kubernetes パターンです。

コンテキストと名前空間

# コンテキストを表示
kubectl config get-contexts
kubectl config current-context

# コンテキストを切り替え
kubectl config use-context production

# デフォルトの名前空間を設定
kubectl config set-context --current --namespace=my-app

# コマンドで名前空間を使用
kubectl get pods -n kube-system
kubectl get pods --all-namespaces  # または -A

Pods

# Pod を一覧表示
kubectl get pods
kubectl get pods -o wide              # 詳細情報
kubectl get pods -w                    # ウォッチモード
kubectl get pods --show-labels
kubectl get pods -l app=web            # ラベルで指定

# Pod の詳細
kubectl describe pod my-pod
kubectl get pod my-pod -o yaml

# ログ
kubectl logs my-pod
kubectl logs my-pod -f                 # フォロー
kubectl logs my-pod --tail=100
kubectl logs my-pod -c my-container    # 特定のコンテナ
kubectl logs my-pod --previous         # 以前のクラッシュ

# Pod に exec
kubectl exec -it my-pod -- /bin/sh
kubectl exec -it my-pod -c my-container -- bash

# ポートフォワード
kubectl port-forward my-pod 8080:80
kubectl port-forward svc/my-service 8080:80

# ファイルをコピー
kubectl cp my-pod:/app/file.txt ./file.txt
kubectl cp ./file.txt my-pod:/app/

# 削除
kubectl delete pod my-pod
kubectl delete pod my-pod --grace-period=0 --force

Deployments

# デプロイメントを作成
kubectl create deployment web --image=nginx:latest --replicas=3

# 一覧表示
kubectl get deployments
kubectl get deploy

# スケール
kubectl scale deployment web --replicas=5

# イメージを更新
kubectl set image deployment/web nginx=nginx:1.25

# ロールアウトステータス
kubectl rollout status deployment/web

# ロールバック
kubectl rollout undo deployment/web
kubectl rollout undo deployment/web --to-revision=2

# 履歴
kubectl rollout history deployment/web

# 再起動 (ローリング)
kubectl rollout restart deployment/web

Deployment YAML

apiVersion: apps/v1
kind: Deployment
metadata:
  name: web
  labels:
    app: web
spec:
  replicas: 3
  selector:
    matchLabels:
      app: web
  template:
    metadata:
      labels:
        app: web
    spec:
      containers:
        - name: web
          image: nginx:1.25
          ports:
            - containerPort: 80
          resources:
            requests:
              cpu: 100m
              memory: 128Mi
            limits:
              cpu: 500m
              memory: 256Mi
          livenessProbe:
            httpGet:
              path: /health
              port: 80
            initialDelaySeconds: 10
            periodSeconds: 30
          readinessProbe:
            httpGet:
              path: /ready
              port: 80
            initialDelaySeconds: 5
            periodSeconds: 10
          env:
            - name: NODE_ENV
              value: "production"
            - name: DB_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: db-secret
                  key: password

Services

# ClusterIP (内部)
apiVersion: v1
kind: Service
metadata:
  name: web
spec:
  selector:
    app: web
  ports:
    - port: 80
      targetPort: 8080

---
# LoadBalancer (外部)
apiVersion: v1
kind: Service
metadata:
  name: web-public
spec:
  type: LoadBalancer
  selector:
    app: web
  ports:
    - port: 80
      targetPort: 8080

---
# NodePort
apiVersion: v1
kind: Service
metadata:
  name: web-nodeport
spec:
  type: NodePort
  selector:
    app: web
  ports:
    - port: 80
      targetPort: 8080
      nodePort: 30080
# クイック公開
kubectl expose deployment web --port=80 --target-port=8080
kubectl expose deployment web --type=LoadBalancer --port=80

# サービスを一覧表示
kubectl get svc
kubectl describe svc web

ConfigMaps と Secrets

# ConfigMap
kubectl create configmap app-config --from-literal=key=value
kubectl create configmap app-config --from-file=config.yaml

# Secret
kubectl create secret generic db-creds \
  --from-literal=username=admin \
  --from-literal=password=secret123

# 表示
kubectl get configmap app-config -o yaml
kubectl get secret db-creds -o jsonpath='{.data.password}' | base64 -d

適用と削除

# マニフェストを適用
kubectl apply -f deployment.yaml
kubectl apply -f ./k8s/              # ディレクトリ内のすべてのファイル
kubectl apply -f https://example.com/manifest.yaml

# 削除
kubectl delete -f deployment.yaml
kubectl delete deployment web
kubectl delete all -l app=web        # ラベルで指定

# ドライラン
kubectl apply -f deployment.yaml --dry-run=client
kubectl apply -f deployment.yaml --dry-run=server

デバッグクイックリファレンス

# Pod が起動しない場合
kubectl describe pod my-pod          # Events セクションを確認
kubectl get events --sort-by='.lastTimestamp'

# CrashLoopBackOff の場合
kubectl logs my-pod --previous       # クラッシュしたコンテナのログ

# サービスに接続できない場合
kubectl get endpoints my-service     # エンドポイントが存在するか確認
kubectl run debug --rm -it --image=busybox -- wget -qO- http://my-service

# リソースの問題
kubectl top pods
kubectl top nodes
kubectl describe node <node-name>    # Allocatable と Allocated を比較確認

リファレンス

デバッグパターンについては: references/debugging.md YAML テンプレートについては: references/manifests.md

📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開

Kubernetes

Essential kubectl commands and Kubernetes patterns.

Context & Namespace

# View contexts
kubectl config get-contexts
kubectl config current-context

# Switch context
kubectl config use-context production

# Set default namespace
kubectl config set-context --current --namespace=my-app

# Use namespace in command
kubectl get pods -n kube-system
kubectl get pods --all-namespaces  # or -A

Pods

# List pods
kubectl get pods
kubectl get pods -o wide              # More details
kubectl get pods -w                    # Watch mode
kubectl get pods --show-labels
kubectl get pods -l app=web            # By label

# Pod details
kubectl describe pod my-pod
kubectl get pod my-pod -o yaml

# Logs
kubectl logs my-pod
kubectl logs my-pod -f                 # Follow
kubectl logs my-pod --tail=100
kubectl logs my-pod -c my-container    # Specific container
kubectl logs my-pod --previous         # Previous crash

# Exec into pod
kubectl exec -it my-pod -- /bin/sh
kubectl exec -it my-pod -c my-container -- bash

# Port forward
kubectl port-forward my-pod 8080:80
kubectl port-forward svc/my-service 8080:80

# Copy files
kubectl cp my-pod:/app/file.txt ./file.txt
kubectl cp ./file.txt my-pod:/app/

# Delete
kubectl delete pod my-pod
kubectl delete pod my-pod --grace-period=0 --force

Deployments

# Create deployment
kubectl create deployment web --image=nginx:latest --replicas=3

# List
kubectl get deployments
kubectl get deploy

# Scale
kubectl scale deployment web --replicas=5

# Update image
kubectl set image deployment/web nginx=nginx:1.25

# Rollout status
kubectl rollout status deployment/web

# Rollback
kubectl rollout undo deployment/web
kubectl rollout undo deployment/web --to-revision=2

# History
kubectl rollout history deployment/web

# Restart (rolling)
kubectl rollout restart deployment/web

Deployment YAML

apiVersion: apps/v1
kind: Deployment
metadata:
  name: web
  labels:
    app: web
spec:
  replicas: 3
  selector:
    matchLabels:
      app: web
  template:
    metadata:
      labels:
        app: web
    spec:
      containers:
        - name: web
          image: nginx:1.25
          ports:
            - containerPort: 80
          resources:
            requests:
              cpu: 100m
              memory: 128Mi
            limits:
              cpu: 500m
              memory: 256Mi
          livenessProbe:
            httpGet:
              path: /health
              port: 80
            initialDelaySeconds: 10
            periodSeconds: 30
          readinessProbe:
            httpGet:
              path: /ready
              port: 80
            initialDelaySeconds: 5
            periodSeconds: 10
          env:
            - name: NODE_ENV
              value: "production"
            - name: DB_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: db-secret
                  key: password

Services

# ClusterIP (internal)
apiVersion: v1
kind: Service
metadata:
  name: web
spec:
  selector:
    app: web
  ports:
    - port: 80
      targetPort: 8080

---
# LoadBalancer (external)
apiVersion: v1
kind: Service
metadata:
  name: web-public
spec:
  type: LoadBalancer
  selector:
    app: web
  ports:
    - port: 80
      targetPort: 8080

---
# NodePort
apiVersion: v1
kind: Service
metadata:
  name: web-nodeport
spec:
  type: NodePort
  selector:
    app: web
  ports:
    - port: 80
      targetPort: 8080
      nodePort: 30080
# Quick expose
kubectl expose deployment web --port=80 --target-port=8080
kubectl expose deployment web --type=LoadBalancer --port=80

# List services
kubectl get svc
kubectl describe svc web

ConfigMaps & Secrets

# ConfigMap
kubectl create configmap app-config --from-literal=key=value
kubectl create configmap app-config --from-file=config.yaml

# Secret
kubectl create secret generic db-creds \
  --from-literal=username=admin \
  --from-literal=password=secret123

# View
kubectl get configmap app-config -o yaml
kubectl get secret db-creds -o jsonpath='{.data.password}' | base64 -d

Apply & Delete

# Apply manifest
kubectl apply -f deployment.yaml
kubectl apply -f ./k8s/              # All files in directory
kubectl apply -f https://example.com/manifest.yaml

# Delete
kubectl delete -f deployment.yaml
kubectl delete deployment web
kubectl delete all -l app=web        # By label

# Dry run
kubectl apply -f deployment.yaml --dry-run=client
kubectl apply -f deployment.yaml --dry-run=server

Debugging Quick Reference

# Pod not starting?
kubectl describe pod my-pod          # Check Events section
kubectl get events --sort-by='.lastTimestamp'

# CrashLoopBackOff?
kubectl logs my-pod --previous       # Logs from crashed container

# Can't connect to service?
kubectl get endpoints my-service     # Check if endpoints exist
kubectl run debug --rm -it --image=busybox -- wget -qO- http://my-service

# Resource issues?
kubectl top pods
kubectl top nodes
kubectl describe node <node-name>    # Check Allocatable vs Allocated

Reference

For debugging patterns: references/debugging.md For YAML templates: references/manifests.md