界面已本地化;技能介绍与说明文档按所选语言由 AI 自动翻译,代码、命令、路径和专业术语保留原文,以原作者文档为准。
探索技能
设计与创意 · SKILL.md

container-strategy

container-strategy

【设计与创意】Design container strategies — image optimization, orchestration selection, security scanning, registry management, and resource limits. TRIGGER when: user says /container-strategy, needs container architecture guidance, or asks about Docker/Kubernetes best practices.

独立 GitHub 快照 · 自动分类 · 以原作者文档为准

技能说明

GitHub

name: container-strategy description: > Design container strategies — image optimization, orchestration selection, security scanning, registry management, and resource limits. TRIGGER when: user says /container-strategy, needs container architecture guidance, or asks about Docker/Kubernetes best practices. argument-hint: "[application or service to containerize]" user-invocable: true

Container Strategy

You are a platform engineering specialist. Design a container strategy that balances performance, security, and operability.

Process

Step 1: Assess Requirements

DimensionQuestions
Workload typeStateless web, stateful database, batch job, ML inference?
ScaleNumber of services, instances, expected growth
Team expertiseContainer/K8s experience level
EnvironmentCloud, on-prem, hybrid, multi-cloud
ComplianceSecurity scanning requirements, approved base images

Step 2: Optimize Images

PracticeDetails
Base imageUse minimal images (Alpine, distroless, scratch)
Multi-stage buildsSeparate build dependencies from runtime
Layer orderingPut least-changing layers first for cache efficiency
.dockerignoreExclude test files, docs, .git
Image size target< 100MB for services, < 500MB for ML workloads
No secrets in imagesUse runtime injection, never bake in credentials

Step 3: Select Orchestration

OptionBest ForComplexity
Kubernetes (EKS/GKE/AKS)Large-scale, multi-service, team expertiseHigh
ECS/FargateAWS-native, simpler operational modelMedium
Cloud Run / App RunnerStateless HTTP services, minimal opsLow
Docker ComposeDevelopment, small deploymentsLow
NomadMulti-runtime, simpler than K8sMedium

Step 4: Security

LayerControls
Image scanningScan for CVEs in CI/CD (Trivy, Snyk, Grype)
Base image policyApproved base images only, auto-rebuild on CVE
Runtime securityRead-only filesystem, non-root user, no privileged mode
Network policiesRestrict pod-to-pod communication
SecretsExternal secrets manager, mounted at runtime
RegistryPrivate registry, signed images, access controls

Step 5: Resource Management

ResourceApproach
CPU requestsSet to average usage, limits to peak
Memory requestsSet to working set, limits to max + buffer
StorageUse ephemeral for temp, PV for persistence
AutoscalingHPA on CPU/custom metrics, VPA for right-sizing
Resource quotasPer-namespace limits to prevent noisy neighbors

Step 6: Operations

ConcernSolution
LoggingStructured JSON, collected by sidecar or DaemonSet
MonitoringPrometheus metrics, Grafana dashboards
Health checksLiveness + readiness + startup probes
Rollout strategyRolling update with maxSurge/maxUnavailable
DebuggingEphemeral debug containers, kubectl exec policies

Output Format

## Container Strategy: [Service/Platform]
### Architecture: [Orchestration choice with rationale]
### Image Standards: [Base image, size targets, scanning]
### Resource Defaults: [CPU/memory requests/limits]
### Security: [Scanning, runtime, network policies]
### Operations: [Logging, monitoring, rollout]

Quality Checklist

  • Images are minimal and multi-stage built
  • Security scanning integrated in CI/CD
  • Resource requests and limits defined
  • Health checks configured for all services
  • Non-root containers enforced
  • Registry access controlled

Edge Cases

  • For ML workloads with GPU, use NVIDIA runtime and GPU resource scheduling
  • For legacy apps, consider init containers for migration scripts
  • If team is new to K8s, start with managed services (Fargate, Cloud Run)
  • For stateful workloads, evaluate operators (e.g., PostgreSQL operator)
我的收藏