.cursorrules YAML Kubernetes DevOps

Docker + Kubernetes コンテナ化

DockerとKubernetes開発のベストプラクティス。マルチステージビルド、Helmチャート、セキュリティスキャン、本番デプロイパターン。

.cursorrules · 60 lines
You are an expert in Docker, Kubernetes, and container orchestration for production environments.

Docker Best Practices
- Use multi-stage builds to minimize image size.
- Pin base image versions (e.g., node:20.11-alpine, NOT node:latest).
- Run containers as non-root users; use USER directive.
- Order Dockerfile instructions for optimal layer caching (dependencies before source code).
- Use .dockerignore to exclude unnecessary files from build context.
- Implement health checks with HEALTHCHECK instruction.
- Use COPY over ADD unless extracting archives.
- Minimize the number of layers by combining RUN commands.
- Scan images for vulnerabilities with tools like Trivy or Snyk.

Kubernetes Resources
- Always set resource requests and limits for CPU and memory.
- Use namespaces for logical isolation of workloads.
- Implement proper labels and annotations for resource management.
- Use ConfigMaps for configuration and Secrets for sensitive data.
- Never store secrets in plain text; use sealed-secrets or external-secrets.

Deployment Patterns
- Use Deployments for stateless applications, StatefulSets for stateful.
- Implement rolling update strategy with maxSurge and maxUnavailable.
- Define proper readiness and liveness probes.
- Use PodDisruptionBudgets for high-availability workloads.
- Implement horizontal pod autoscaling (HPA) based on metrics.

Networking
- Use Services for internal communication (ClusterIP for internal, LoadBalancer for external).
- Implement Ingress controllers for HTTP/HTTPS routing.
- Use NetworkPolicies to restrict pod-to-pod communication.
- Configure proper DNS settings and service discovery.

Helm Charts
- Use Helm for packaging and deploying Kubernetes applications.
- Template common patterns; use helpers (_helpers.tpl) for reusable snippets.
- Implement values.yaml with sensible defaults and per-environment overrides.
- Version charts following SemVer.
- Use helm lint and helm template for validation.

Security
- Implement Pod Security Standards (restricted profile for production).
- Use ServiceAccounts with minimal RBAC permissions.
- Enable audit logging on the cluster.
- Regularly update and patch base images.
- Use OPA/Gatekeeper or Kyverno for policy enforcement.
- Scan manifests with kubesec or kube-score.

Observability
- Implement structured logging (JSON format) for easy parsing.
- Use Prometheus + Grafana for metrics collection and dashboards.
- Set up alerting rules for critical conditions.
- Use distributed tracing (Jaeger, OpenTelemetry) for microservices.
- Centralize logs with EFK stack or Loki.

CI/CD Integration
- Use GitOps practices with ArgoCD or Flux.
- Implement image tagging with git SHA or semantic versions.
- Automate manifest validation in CI pipelines.
- Use kustomize for environment-specific overlays.
Share on X

こちらもおすすめ

DevOps カテゴリの他のルール

もっとルールを探す

CLAUDE.md、.cursorrules、AGENTS.md、Image Prompts の全 157 ルールをチェック。