config-distribution
Patterns for distributing configuration and secrets to services safely and consistently across environments (env vars, config files, secret managers, K8s External Secrets, and change process)
安装与使用
请根据来源仓库和你的 AI 工具说明安装此技能。先阅读技能文件和依赖要求,再添加到工作流。
查看来源 ↗使用指南技能说明
Config Distribution
Overview
วิธีการ distribute configuration ไปยัง services ต่างๆ อย่างปลอดภัยและ consistent: environment variables, config files, secrets management
Why This Matters
- Centralized management: Config อยู่ที่เดียว
- Security: Secrets แยกจาก code
- Flexibility: เปลี่ยน config โดยไม่ต้อง redeploy
- Audit: Track config changes
Core Concepts
1. Config vs Secrets (แบ่งให้ชัด)
- Config: timeouts, hosts, feature toggles (บางแบบ), limits
- Secrets: passwords, API keys, signing keys, tokens → ต้องมาจาก secret manager และห้ามลง repo/logs
- อ้างอิงมาตรฐาน:
64-meta-standards/config-env-conventions/SKILL.md
2. Precedence / Hierarchy
Priority (highest to lowest):
1. Runtime secrets (Vault, AWS SM)
2. Environment variables
3. Environment-specific config files
4. Default config files
5. Code defaults
3. Distribution Methods
Environment Variables (Simple)
# docker-compose.yml
services:
app:
environment:
- DATABASE_URL=postgresql://...
- REDIS_URL=redis://...
env_file:
- .env.production
Config Service (Advanced)
// Fetch from central config service
const config = await configService.get({
service: 'user-service',
environment: 'production',
});
External Secrets (K8s)
apiVersion: external-secrets.io/v1beta1
kind: ExternalSecret
metadata:
name: app-secrets
spec:
secretStoreRef:
name: aws-secrets-manager
target:
name: app-secrets
data:
- secretKey: DATABASE_URL
remoteRef:
key: prod/database
property: url
4. Validation & Fail-Fast
- validate config ที่ startup (type/format/range) ก่อนรับ traffic
- ป้องกันการ log ค่า secret ด้วย redaction/denylist
- ทุก key ต้อง document ใน
.env.example(ค่า secret ให้เว้นว่าง + comment แหล่งที่มา)
Quick Start
- กำหนด source-of-truth: secret manager (secrets) + env vars/config file (non-secrets)
- ใช้ schema validation ที่ startup (เช่น Zod/JSON schema)
- ทำ reload strategy ที่ปลอดภัย (ถ้าต้อง reload runtime)
- ทำ change process ที่มี audit + rollback
Config Change Process
- Update config in source (Git/Vault)
- CI validates config
- Deploy/reload applications
- Verify via health checks
Production Checklist
- Secrets อยู่ใน secret manager เท่านั้น (ไม่อยู่ใน repo, image, logs)
- Config precedence ถูกกำหนดและ document ชัดเจน
- Config validated at startup (fail fast)
-
.env.exampleครบ keys และระบุ required/optional - มี audit trail และ rollback ของ config changes
Anti-patterns
- Secrets in env files: เผลอ commit หรือรั่วจาก log/backup
- No validation: config ผิดแล้วพังตอน runtime
- Snowflake configs: แต่ละ service ตั้งชื่อ/ความหมายไม่เหมือนกัน
- Uncontrolled reload: reload config กลางทางจน behavior เปลี่ยนโดยไม่มี guardrails
Integration Points
- Secret managers (Vault, AWS/GCP/Azure Secret Manager)
- Kubernetes (External Secrets Operator)
- CI/CD (config linting, policy checks)
- Observability (log redaction, config change audit events)
Further Reading
使用示例
查看来源仓库中的使用示例与配置说明。
查看来源 ↗来源历史
- 收录时间
- 2026-01-20
- 索引更新时间
- 2026-01-26
- Branch
- main
收录与同步日期属于本站记录。源码修改历史请查看来源仓库。
GitHub ↗chat Comments (0)
Sign in to join the discussion and leave a comment.
No comments yet. Be the first to share your thoughts!