关于 devops-flow
devops-flow 是一款技能,可依据 SPEC 和 REQ 文档生成基础设施、CI/CD、Kubernetes 配置及部署脚本,面向希望自动化多环境部署流程的团队。
主要功能
- 01生成 IaC 配置
- 02创建 CI/CD 流水线
- 03生成 Kubernetes 清单
- 04创建部署与回滚脚本
- 05生成 Ansible Playbook
- 06配置监控与安全
适用场景
- 01根据 SPEC 文档配置云基础设施
- 02创建应用发布流水线
- 03生成环境专用部署脚本
- 04准备 Kubernetes 与 Ansible 配置
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ vladm3105/ aidoc-flow-framework --skill devops-flow安装后在 Claude Code 中输入/devops-flow确认已加载。
详细介绍
devops-flow
描述:基础设施即代码、CI/CD 流水线自动化和部署管理
类别:DevOps 与部署
复杂度:高(多云 + 编排 + 自动化)
用途
根据 SPEC 文档和 ADR 决策,自动化基础设施配置、CI/CD 流水线和部署流程。确保在各环境中实现一致、可重复且安全的部署。
功能
1. 基础设施即代码(IaC)
- Terraform:云无关的基础设施配置
- CloudFormation:AWS 原生基础设施
- Ansible:配置管理与资源配置
- Pulumi:使用标准编程语言实现的现代 IaC
- Kubernetes manifests:容器编排
2. CI/CD 流水线生成
- GitHub Actions:工作流自动化
- GitLab CI:流水线配置
- Jenkins:流水线即代码
- CircleCI:云原生 CI/CD
- Azure DevOps:与 Microsoft 生态系统集成
3. 容器配置
- Dockerfile:容器镜像定义
- Docker Compose:多容器应用
- Kubernetes:生产环境编排
- Helm charts:Kubernetes 包管理
- 容器镜像仓库:镜像存储与版本管理
4. 部署策略
- 蓝绿部署:零停机部署
- 金丝雀部署:逐步发布并进行监控
- 滚动部署:按顺序更新实例
- 功能开关:渐进式启用功能
- 回滚流程:自动故障恢复
5. 环境管理
- 环境隔离:dev、staging、production
- 配置管理:特定于环境的配置
- 密钥管理:Vault、AWS Secrets Manager 等
- 基础设施版本管理:状态管理
- 成本优化:资源标记与监控
6. 监控与可观测性
- 日志:集中式日志聚合
- 指标:性能与运行状况监控
- 告警:事件响应自动化
- 追踪:分布式请求跟踪
- 仪表板:实时可视化
7. 安全与合规
- 安全扫描:容器与基础设施扫描
- 合规检查:策略执行
- 访问控制:IAM 和 RBAC
- 网络安全:防火墙规则、VPC 配置
- 审计日志:变更跟踪
8. 灾难恢复
- 备份自动化:数据与配置备份
- 恢复流程:自动恢复
- 故障转移:多区域冗余
- 数据复制:跨区域同步
- RTO/RPO:恢复目标实施
DevOps 工作流
graph TD
A[SPEC Document] --> B[Extract Requirements]
B --> C{Infrastructure Needed?}
C -->|Yes| D[Generate IaC Templates]
C -->|No| E[Generate CI/CD Pipeline]
D --> F[Terraform/CloudFormation]
F --> G[Validate Infrastructure Code]
G --> H{Validation Pass?}
H -->|No| I[Report Issues]
H -->|Yes| J[Generate Deployment Pipeline]
E --> J
J --> K[CI/CD Configuration]
K --> L[Add Build Stage]
L --> M[Add Test Stage]
M --> N[Add Security Scan]
N --> O[Add Deploy Stage]
O --> P[Environment Strategy]
P --> Q{Deployment Type}
Q -->|Blue-Green| R[Generate Blue-Green Config]
Q -->|Canary| S[Generate Canary Config]
Q -->|Rolling| T[Generate Rolling Config]
R --> U[Add Monitoring]
S --> U
T --> U
U --> V[Add Rollback Procedure]
V --> W[Generate Documentation]
W --> X[Review & Deploy]
I --> X
使用说明
根据 SPEC 生成基础设施
devops-flow generate-infra \
--spec specs/SPEC-API-V1.md \
--cloud aws \
--output infrastructure/
生成的 Terraform 结构:
infrastructure/
├── main.tf # Main configuration
├── variables.tf # Input variables
├── outputs.tf # Output values
├── providers.tf # Cloud provider config
├── modules/
│ ├── vpc/ # Network infrastructure
│ ├── compute/ # EC2, Lambda, etc.
│ ├── database/ # RDS, DynamoDB
│ └── storage/ # S3, EBS
└── environments/
├── dev.tfvars # Development config
├── staging.tfvars # Staging config
└── prod.tfvars # Production config
生成 CI/CD 流水线
devops-flow generate-pipeline \
--type github-actions \
--language python \
--deploy-strategy blue-green \
--output .github/workflows/
生成的 GitHub Actions 工作流:
name: CI/CD Pipeline
on:
push:
branches: [main, develop]
pull_request:
branches: [main]
env:
PYTHON_VERSION: '3.11'
AWS_REGION: us-east-1
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install dependencies
run: |
pip install ruff mypy
- name: Run linters
run: |
ruff check .
mypy .
test:
needs: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Run tests
run: |
pytest --cov=. --cov-report=xml
- name: Upload coverage
uses: codecov/codecov-action@v3
security:
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Security scan
run: |
bandit -r . -f json -o security-report.json
- name: Upload security report
uses: actions/upload-artifact@v3
with:
name: security-report
path: security-report.json
build:
needs: [lint, test, security]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Build Docker image
run: |
docker build -t app:${{ github.sha }} .
- name: Push to registry
run: |
docker push registry.example.com/app:${{ github.sha }}
deploy-staging:
needs: build
if: github.ref == 'refs/heads/develop'
runs-on: ubuntu-latest
environment: staging
steps:
- name: Deploy to staging
run: |
aws ecs update-service \
--cluster staging-cluster \
--service app-service \
--force-new-deployment
deploy-production:
needs: build
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
environment: production
steps:
- name: Deploy blue-green
run: |
# Deploy to green environment
./scripts/deploy-green.sh
# Run smoke tests
./scripts/smoke-tests.sh
# Switch traffic to green
./scripts/switch-traffic.sh
# Keep blue for rollback
生成 Kubernetes 配置
devops-flow generate-k8s \
--spec specs/SPEC-API-V1.md \
--replicas 3 \
--output k8s/
生成的 Kubernetes manifests:
# k8s/deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: api-service
labels:
app: api
version: v1
spec:
replicas: 3
selector:
matchLabels:
app: api
template:
metadata:
labels:
app: api
version: v1
spec:
containers:
- name: api
image: registry.example.com/api:latest
ports:
- containerPort: 8000
env:
- name: DATABASE_URL
valueFrom:
secretKeyRef:
name: api-secrets
key: database-url
resources:
requests:
memory: "256Mi"
cpu: "250m"
limits:
memory: "512Mi"
cpu: "500m"
livenessProbe:
httpGet:
path: /health
port: 8000
initialDelaySeconds: 30
periodSeconds: 10
readinessProbe:
httpGet:
path: /ready
port: 8000
initialDelaySeconds: 5
periodSeconds: 5
---
# k8s/service.yaml
apiVersion: v1
kind: Service
metadata:
name: api-service
spec:
selector:
app: api
ports:
- protocol: TCP
port: 80
targetPort: 8000
type: LoadBalancer
---
# k8s/hpa.yaml
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: api-hpa
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: api-service
minReplicas: 3
maxReplicas: 10
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 70
根据 REQ 生成部署脚本
devops-flow generate-deployment-scripts \
--req docs/07_REQ/REQ-NN.md \
--spec docs/09_SPEC/SPEC-NN.yaml \
--output scripts/
生成的 shell 脚本结构:
scripts/
├── setup.sh # Initial environment setup
├── install.sh # Application installation
├── deploy.sh # Main deployment orchestration
├── rollback.sh # Rollback to previous version
├── health-check.sh # Health verification
└── cleanup.sh # Cleanup old versions
脚本生成逻辑:
- 解析 REQ 第 9.5.3 节中的脚本要求
- 解析 SPEC 部署部分中的技术细节
- 应用脚本标准(Bash 4.0+、错误处理、日志记录)
- 根据 REQ @adr 标签引用云服务提供商
- 使用 REQ 9.5.2 中特定于环境的配置
生成的脚本示例(setup.sh):
#!/bin/bash
set -euo pipefail
# Setup environment for deployment
LOG_FILE="logs/deployment_$(date +%Y%m%d_%H%M%S).log"
mkdir -p logs
log() {
echo "[$(date +%Y-%m-%d %H:%M:%S)] $*" | tee -a "$LOG_FILE"
}
log "Starting environment setup..."
# Install dependencies
if [ ! -f .tool-versions ]; then
log "Installing Python dependencies..."
pip install -r requirements.txt
fi
# Configure environment variables
if [ -f .env.deployment ]; then
log "Loading deployment environment variables..."
export $(cat .env.deployment | grep -v '^#' | xargs)
fi
log "Environment setup complete"
exit 0
生成的脚本示例(deploy.sh):
#!/bin/bash
set -euo pipefail
# Main deployment orchestration script
LOG_FILE="logs/deployment_$(date +%Y%m%d_%H%M%S).log"
ENVIRONMENT="${1:-staging}"
log() {
echo "[$(date +%Y-%m-%d %H:%M:%S)] $*" | tee -a "$LOG_FILE"
}
# Step 1: Setup
log "Running setup..."
./scripts/setup.sh
# Step 2: Install
log "Installing application..."
./scripts/install.sh --env "$ENVIRONMENT"
# Step 3: Deploy
log "Deploying application..."
if [ "$ENVIRONMENT" = "production" ]; then
./scripts/deploy-prod.sh
else
./scripts/deploy-staging.sh
fi
# Step 4: Health check
log "Running health check..."
./scripts/health-check.sh --env "$ENVIRONMENT"
if [ $? -eq 0 ]; then
log "Deployment successful"
else
log "Deployment failed, initiating rollback..."
./scripts/rollback.sh --env "$ENVIRONMENT"
exit 1
fi
生成的脚本示例(health-check.sh):
#!/bin/bash
set -euo pipefail
# Health verification script
HEALTH_URL="${1:-http://localhost:8000/health/live}"
TIMEOUT=60
RETRIES=3
log() {
echo "[$(date +%Y-%m-%d %H:%M:%S)] $*"
}
log "Starting health check..."
for i in $(seq 1 $RETRIES); do
log "Attempt $i of $RETRIES..."
RESPONSE=$(curl -s -o /dev/null -w "%{http_code}" --max-time $TIMEOUT "$HEALTH_URL")
if [ "$RESPONSE" = "200" ]; then
log "Health check passed"
exit 0
fi
log "Health check failed, sleeping before retry..."
sleep 5
done
log "Health check failed after $RETRIES attempts"
exit 1
从 REQ 生成 Ansible Playbook
devops-flow generate-ansible-playbooks \
--req docs/07_REQ/REQ-NN.md \
--spec docs/09_SPEC/SPEC-NN.yaml \
--output ansible/
生成的 Ansible playbook 结构:
ansible/
├── provision_infra.yml # Infrastructure provisioning
├── configure_instances.yml # Instance configuration
├── deploy_app.yml # Application deployment
├── configure_monitoring.yml # Monitoring setup
├── configure_security.yml # Security hardening
└── backup_restore.yml # Backup/restore procedures
Playbook 生成逻辑:
- 解析 REQ 第 9.5.4 节中的 playbook 要求
- 解析第 9.5.1 节中的基础设施配置
- 遵循 Ansible 标准(2.9+、模块化角色、幂等性)
- 参考 REQ @adr 标签中的云服务提供商
- 使用 REQ 9.5.2 中的环境特定变量
生成的 playbook 示例(provision_infra.yml):
---
- name: Provision Infrastructure
hosts: localhost
gather_facts: no
vars_files:
- "environments/{{ target_env }}.yml"
tasks:
- name: Create VPC
ec2_vpc_net:
name: "{{ vpc_name }}"
cidr_block: "{{ vpc_cidr }}"
region: "{{ aws_region }}"
tags:
Project: "{{ project_name }}"
Environment: "{{ target_env }}"
ManagedBy: "Ansible"
- name: Create security groups
ec2_security_group:
name: "{{ security_group_name }}"
description: "Security group for {{ application_name }}"
vpc_id: "{{ vpc.vpc_id }}"
rules:
- proto: tcp
from_port: 80
to_port: 80
cidr_ip: 0.0.0.0/0
- proto: tcp
from_port: 443
to_port: 443
cidr_ip: 0.0.0.0/0
region: "{{ aws_region }}"
tags:
Project: "{{ project_name }}"
Environment: "{{ target_env }}"
- name: Create RDS instance
rds:
db_name: "{{ db_name }}"
engine: postgres
engine_version: "{{ db_version }}"
instance_type: "{{ db_instance_class }}"
allocated_storage: "{{ db_storage_gb }}"
username: "{{ db_username }}"
password: "{{ db_password }}"
vpc_security_group_ids:
- "{{ security_group.group_id }}"
subnet_group_name: "{{ db_subnet_group }}"
backup_retention_period: "{{ backup_retention_days }}"
multi_az: true
region: "{{ aws_region }}"
tags:
Project: "{{ project_name }}"
Environment: "{{ target_env }}"
ManagedBy: "Ansible"
生成的 playbook 示例(deploy_app.yml):
---
- name: Deploy Application
hosts: app_servers
gather_facts: yes
become: yes
vars_files:
- "environments/{{ target_env }}.yml"
tasks:
- name: Ensure application directory exists
file:
path: "{{ app_directory }}"
state: directory
mode: '0755'
owner: "{{ app_user }}"
group: "{{ app_group }}"
- name: Copy application code
synchronize:
src: "{{ app_source_directory }}/"
dest: "{{ app_directory }}/"
delete: yes
recursive: yes
- name: Install Python dependencies
pip:
requirements: "{{ app_directory }}/requirements.txt"
virtualenv: "{{ app_venv }}"
state: present
- name: Configure application
template:
src: "templates/{{ target_env }}_config.yml"
dest: "{{ app_directory }}/config.yml"
owner: "{{ app_user }}"
group: "{{ app_group }}"
mode: '0640'
- name: Restart application service
systemd:
name: "{{ app_service_name }}"
state: restarted
daemon_reload: yes
notify: Run Health Check
- name: Wait for application to be ready
wait_for:
port: 8000
host: "{{ inventory_hostname }}"
timeout: 300
handlers:
- name: Run Health Check
uri:
url: "http://localhost:8000/health/ready"
method: GET
status_code: 200
register: health_check
基础设施模板
AWS 基础设施(Terraform)
# main.tf
terraform {
required_version = ">= 1.0"
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 5.0"
}
}
backend "s3" {
bucket = "terraform-state-bucket"
key = "infrastructure/terraform.tfstate"
region = "us-east-1"
}
}
provider "aws" {
region = var.aws_region
default_tags {
tags = {
Project = var.project_name
Environment = var.environment
ManagedBy = "Terraform"
}
}
}
# VPC Module
module "vpc" {
source = "./modules/vpc"
vpc_cidr = var.vpc_cidr
availability_zones = var.availability_zones
public_subnet_cidrs = var.public_subnet_cidrs
private_subnet_cidrs = var.private_subnet_cidrs
}
# ECS Cluster
resource "aws_ecs_cluster" "main" {
name = "${var.project_name}-${var.environment}-cluster"
setting {
name = "containerInsights"
value = "enabled"
}
}
# Application Load Balancer
resource "aws_lb" "main" {
name = "${var.project_name}-${var.environment}-alb"
internal = false
load_balancer_type = "application"
security_groups = [aws_security_group.alb.id]
subnets = module.vpc.public_subnet_ids
enable_deletion_protection = var.environment == "production"
}
# RDS Database
resource "aws_db_instance" "main" {
identifier = "${var.project_name}-${var.environment}-db"
engine = "postgres"
engine_version = "15.3"
instance_class = var.db_instance_class
allocated_storage = var.db_allocated_storage
max_allocated_storage = var.db_max_allocated_storage
storage_encrypted = true
db_name = var.db_name
username = var.db_username
password = random_password.db_password.result
vpc_security_group_ids = [aws_security_group.db.id]
db_subnet_group_name = aws_db_subnet_group.main.name
backup_retention_period = var.environment == "production" ? 30 : 7
skip_final_snapshot = var.environment != "production"
tags = {
Name = "${var.project_name}-${var.environment}-db"
}
}
Docker 配置
# Dockerfile
FROM python:3.11-slim as base
WORKDIR /app
# Install system dependencies
RUN apt-get update && apt-get install -y \
gcc \
libpq-dev \
&& rm -rf /var/lib/apt/lists/*
# Copy requirements
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Copy application code
COPY . .
# Create non-root user
RUN useradd -m -u 1000 appuser && chown -R appuser:appuser /app
USER appuser
# Expose port
EXPOSE 8000
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=40s --retries=3 \
CMD python -c "import requests; requests.get('http://localhost:8000/health')"
# Run application
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
# Multi-stage build for smaller image
FROM base as production
ENV ENVIRONMENT=production
RUN pip install --no-cache-dir gunicorn
CMD ["gunicorn", "main:app", "-w", "4", "-k", "uvicorn.workers.UvicornWorker", "--bind", "0.0.0.0:8000"]
Docker Compose(本地开发)
# docker-compose.yml
version: '3.8'
services:
api:
build:
context: .
dockerfile: Dockerfile
target: base
ports:
- "8000:8000"
environment:
- DATABASE_URL=postgresql://user:password@db:5432/appdb
- REDIS_URL=redis://redis:6379/0
- ENVIRONMENT=development
volumes:
- .:/app
depends_on:
db:
condition: service_healthy
redis:
condition: service_started
command: uvicorn main:app --host 0.0.0.0 --port 8000 --reload
db:
image: postgres:15
environment:
POSTGRES_USER: user
POSTGRES_PASSWORD: password
POSTGRES_DB: appdb
ports:
- "5432:5432"
volumes:
- postgres_data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U user"]
interval: 10s
timeout: 5s
retries: 5
redis:
image: redis:7-alpine
ports:
- "6379:6379"
volumes:
- redis_data:/data
nginx:
image: nginx:alpine
ports:
- "80:80"
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf:ro
depends_on:
- api
volumes:
postgres_data:
redis_data:
部署策略
蓝绿部署
#!/bin/bash
# deploy-blue-green.sh
set -e
BLUE_ENV="production-blue"
GREEN_ENV="production-green"
CURRENT_ENV=$(get_active_environment)
if [ "$CURRENT_ENV" == "$BLUE_ENV" ]; then
TARGET_ENV="$GREEN_ENV"
OLD_ENV="$BLUE_ENV"
else
TARGET_ENV="$BLUE_ENV"
OLD_ENV="$GREEN_ENV"
fi
echo "Deploying to $TARGET_ENV (current: $OLD_ENV)"
# Deploy to target environment
deploy_to_environment "$TARGET_ENV"
# Run smoke tests
if ! run_smoke_tests "$TARGET_ENV"; then
echo "Smoke tests failed, rolling back"
exit 1
fi
# Switch traffic
switch_load_balancer "$TARGET_ENV"
# Monitor for 5 minutes
monitor_environment "$TARGET_ENV" 300
# If all good, keep old environment for quick rollback
echo "Deployment successful. Old environment $OLD_ENV kept for rollback."
金丝雀部署
# k8s/canary-deployment.yaml
apiVersion: v1
kind: Service
metadata:
name: api-service
spec:
selector:
app: api
ports:
- port: 80
targetPort: 8000
---
# Stable version (90% traffic)
apiVersion: apps/v1
kind: Deployment
metadata:
name: api-stable
spec:
replicas: 9
selector:
matchLabels:
app: api
version: stable
template:
metadata:
labels:
app: api
version: stable
spec:
containers:
- name: api
image: registry.example.com/api:v1.0.0
---
# Canary version (10% traffic)
apiVersion: apps/v1
kind: Deployment
metadata:
name: api-canary
spec:
replicas: 1
selector:
matchLabels:
app: api
version: canary
template:
metadata:
labels:
app: api
version: canary
spec:
containers:
- name: api
image: registry.example.com/api:v1.1.0
监控与可观测性
Prometheus 配置
# prometheus.yml
global:
scrape_interval: 15s
evaluation_interval: 15s
scrape_configs:
- job_name: 'api-service'
kubernetes_sd_configs:
- role: pod
relabel_configs:
- source_labels: [__meta_kubernetes_pod_label_app]
action: keep
regex: api
- job_name: 'node-exporter'
static_configs:
- targets: ['node-exporter:9100']
alerting:
alertmanagers:
- static_configs:
- targets: ['alertmanager:9093']
rule_files:
- /etc/prometheus/alerts/*.yml
告警规则
# alerts/api-alerts.yml
groups:
- name: api-alerts
interval: 30s
rules:
- alert: HighErrorRate
expr: rate(http_requests_total{status=~"5.."}[5m]) > 0.05
for: 5m
labels:
severity: critical
annotations:
summary: "High error rate detected"
description: "{{ $labels.instance }} has error rate {{ $value }}"
- alert: HighLatency
expr: histogram_quantile(0.95, http_request_duration_seconds_bucket) > 1
for: 10m
labels:
severity: warning
annotations:
summary: "High latency detected"
description: "95th percentile latency is {{ $value }}s"
- alert: PodDown
expr: up{job="api-service"} == 0
for: 2m
labels:
severity: critical
annotations:
summary: "Pod is down"
description: "{{ $labels.instance }} has been down for 2 minutes"
安全配置
网络安全
# security-groups.tf
# ALB Security Group
resource "aws_security_group" "alb" {
name_prefix = "${var.project_name}-alb-"
vpc_id = module.vpc.vpc_id
ingress {
from_port = 443
to_port = 443
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
description = "HTTPS from internet"
}
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
}
# Application Security Group
resource "aws_security_group" "app" {
name_prefix = "${var.project_name}-app-"
vpc_id = module.vpc.vpc_id
ingress {
from_port = 8000
to_port = 8000
protocol = "tcp"
security_groups = [aws_security_group.alb.id]
description = "From ALB"
}
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
}
# Database Security Group
resource "aws_security_group" "db" {
name_prefix = "${var.project_name}-db-"
vpc_id = module.vpc.vpc_id
ingress {
from_port = 5432
to_port = 5432
protocol = "tcp"
security_groups = [aws_security_group.app.id]
description = "From application"
}
}
工具访问
所需工具:
Read:读取 SPEC 文档和 ADRWrite:生成基础设施和流水线文件Bash:执行 Terraform、Docker、kubectl 命令Grep:搜索配置模式
所需软件:
- Terraform / OpenTofu
- Docker / Podman
- kubectl / helm
- aws-cli / gcloud / az-cli
- Ansible(可选)
集成点
与 doc-flow 集成
- 从 SPEC 文档中提取基础设施要求
- 验证基础设施代码是否符合 ADR
- 生成部署文档
与 security-audit 集成
- 对基础设施代码进行安全扫描
- 评估容器漏洞
- 验证合规性
与 test-automation 集成
- 与 CI/CD 集成,实现自动化测试
- 部署冒烟测试
- 基础设施验证测试
与 analytics-flow 集成
- 部署指标和趋势
- 基础设施成本跟踪
- 集成性能监控
最佳实践
- 基础设施即代码:在 Git 中对所有基础设施进行版本控制
- 不可变基础设施:替换而非修改
- 环境一致性:确保开发、预发布和生产环境一致
- 密钥管理:切勿提交密钥
- 从第一天起就进行监控:内置可观测性
- 自动回滚:快速恢复故障
- 成本优化:为资源添加标签,监控支出
- 默认安全:遵循最小权限原则,使用加密
- 文档:为常见操作编写运行手册
- 灾难恢复:定期测试备份
成功标准
- 无需手动预配基础设施
- 部署时间 < 15 分钟
- 回滚时间 < 5 分钟
- 部署期间零停机
- 自动检测基础设施偏差
- 安全合规率达到 100%
- 成本偏差 < 预算的 10%
说明
- 生成的配置在用于生产环境前需要经过审核
- 必须单独配置云服务提供商凭据
- 状态管理(Terraform)需要配置后端
- 多区域部署需要额外配置
- 可通过
terraform plan估算成本
评论
支持 Markdown