mcpField
C
container-orchestration

container-orchestration

github.com/0xdarkmatterクラウド・DevOps78111 回インストール2 週間前に更新
リポジトリ

container-orchestration について

コンテナ化アプリケーション向けに、Docker と Kubernetes のパターンをまとめたスキルです。デプロイや運用に使える設定例、コマンドリファレンス、テンプレート、関連資料を提供します。

主な機能

  1. 01Dockerfile のベストプラクティス
  2. 02Docker Compose の設定例
  3. 03Kubernetes の Deployment、Service、Ingress の例
  4. 04kubectl コマンドリファレンス
  5. 05テンプレートとビルド・プッシュスクリプト

活用シーン

  1. 01本番向け Dockerfile の作成
  2. 02Docker Compose によるサービス設定
  3. 03Kubernetes マニフェストの作成
  4. 04Kubernetes ワークロードの確認や再起動

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/0xdarkmatter/claude-mods --skill container-orchestration

インストール後、Claude Code で/container-orchestrationを入力して読み込まれたか確認します。

同梱ファイル

SKILL.md と一緒にインストールされる参考資料やスクリプト。

assets/
docker-compose.template.yml
Dockerfile.template
references/
dockerfile-patterns.md
ecs-fargate.md
helm-patterns.md
k8s-manifests.md
scripts/
build-push.sh
tests/
run.sh

詳細

コンテナーオーケストレーション

2026-07 時点で検証済みの情報です。

コンテナー化されたアプリケーション向けの Docker と Kubernetes のパターンです。

Dockerfile のベストプラクティス

# Use specific version, not :latest
FROM python:3.11-slim AS builder

# Set working directory
WORKDIR /app

# Copy dependency files first (better caching)
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# Copy application code
COPY src/ ./src/

# Production stage (multi-stage build)
FROM python:3.11-slim

WORKDIR /app

# Create non-root user
RUN useradd --create-home appuser
USER appuser

# Copy from builder
COPY --from=builder /app /app

# Set environment
ENV PYTHONUNBUFFERED=1

# Health check
HEALTHCHECK --interval=30s --timeout=3s \
  CMD curl -f http://localhost:8000/health || exit 1

EXPOSE 8000
CMD ["python", "-m", "uvicorn", "src.main:app", "--host", "0.0.0.0"]
Dockerfile のルール
DO:
- Use specific base image versions
- Use multi-stage builds
- Run as non-root user
- Order commands by change frequency
- Use .dockerignore
- Add health checks

DON'T:
- Use :latest tag
- Run as root
- Copy unnecessary files
- Store secrets in image
- Install dev dependencies in production

Docker Compose

# docker-compose.yml
version: "3.9"

services:
  app:
    build:
      context: .
      dockerfile: Dockerfile
    ports:
      - "8000:8000"
    environment:
      - DATABASE_URL=postgres://user:pass@db:5432/app
    depends_on:
      db:
        condition: service_healthy
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:8000/health"]
      interval: 30s
      timeout: 10s
      retries: 3

  db:
    image: postgres:15-alpine
    volumes:
      - postgres_data:/var/lib/postgresql/data
    environment:
      POSTGRES_USER: user
      POSTGRES_PASSWORD: pass
      POSTGRES_DB: app
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U user -d app"]
      interval: 10s
      timeout: 5s
      retries: 5

volumes:
  postgres_data:

Kubernetes の基本

Deployment
apiVersion: apps/v1
kind: Deployment
metadata:
  name: app
  labels:
    app: myapp
spec:
  replicas: 3
  selector:
    matchLabels:
      app: myapp
  template:
    metadata:
      labels:
        app: myapp
    spec:
      containers:
      - name: app
        image: myapp:1.0.0
        ports:
        - containerPort: 8000
        resources:
          requests:
            memory: "128Mi"
            cpu: "100m"
          limits:
            memory: "256Mi"
            cpu: "500m"
        livenessProbe:
          httpGet:
            path: /health
            port: 8000
          initialDelaySeconds: 10
          periodSeconds: 30
        readinessProbe:
          httpGet:
            path: /ready
            port: 8000
          initialDelaySeconds: 5
          periodSeconds: 10
        env:
        - name: DATABASE_URL
          valueFrom:
            secretKeyRef:
              name: app-secrets
              key: database-url
Service
apiVersion: v1
kind: Service
metadata:
  name: app-service
spec:
  selector:
    app: myapp
  ports:
  - port: 80
    targetPort: 8000
  type: ClusterIP
Ingress
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: app-ingress
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /
spec:
  ingressClassName: nginx
  rules:
  - host: app.example.com
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: app-service
            port:
              number: 80

kubectl クイックリファレンス

コマンド説明
kubectl get podsPod の一覧を表示
kubectl logs <pod>ログを表示
kubectl exec -it <pod> -- shPod 内でシェルを起動
kubectl apply -f manifest.yaml設定を適用
kubectl rollout restart deployment/appデプロイメントを再起動
kubectl rollout status deployment/appロールアウトの状態を確認
kubectl describe pod <pod>Pod をデバッグ
kubectl port-forward svc/app 8080:80ローカルポートを転送

追加リソース

  • ./references/dockerfile-patterns.md - Dockerfile の高度なテクニック
  • ./references/k8s-manifests.md - Kubernetes マニフェストの完全な例
  • ./references/helm-patterns.md - Helm チャートの構成と値
  • ./references/ecs-fargate.md - AWS Fargate 上の Amazon ECS(タスク定義、サービス、awsvpc ネットワーキング、IAM ロール、シークレット、スケーリング、ALB/NLB、ECS と Kubernetes の比較)

スクリプト

  • ./scripts/build-push.sh - Docker イメージをビルドしてプッシュ

アセット

  • ./assets/Dockerfile.template - 本番環境向け Dockerfile テンプレート
  • ./assets/docker-compose.template.yml - Compose のスターターテンプレート

コメント