sync-to-prod
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseSync to Production Skill
同步至生产环境Skill
This skill provides workflows for synchronizing Kubernetes kustomization configurations from staging to production environment in the simplex-gitops repository.
本Skill提供了在simplex-gitops仓库中将Kubernetes kustomization配置从预发布环境同步到生产环境的工作流。
⚠️ CRITICAL: Production Deployment Policy
⚠️ 重要:生产环境部署策略
生产环境部署必须手动执行,禁止自动同步。
The workflow is:
- ✅ Update kustomization.yaml (can be automated)
- ✅ Commit and push to GitLab (can be automated)
- ⛔ ArgoCD sync to production cluster - MUST BE MANUAL
After pushing changes, inform the user:
- Changes are pushed to the repository
- Production ArgoCD app will detect the changes but will NOT auto-sync
- User must manually trigger sync via ArgoCD UI or CLI when ready
bash
undefined生产环境部署必须手动执行,禁止自动同步。
工作流如下:
- ✅ 更新kustomization.yaml(可自动化)
- ✅ 提交并推送到GitLab(可自动化)
- ⛔ ArgoCD同步到生产集群 - 必须手动执行
推送变更后,需告知用户:
- 变更已推送到仓库
- 生产环境ArgoCD应用会检测到变更,但不会自动同步
- 用户准备就绪后,必须通过ArgoCD UI或CLI手动触发同步
bash
undefinedView pending changes (safe, read-only)
查看待同步变更(安全,只读)
argocd app get simplex-aws-prod
argocd app diff simplex-aws-prod
argocd app get simplex-aws-prod
argocd app diff simplex-aws-prod
Manual sync (ONLY when user explicitly requests)
手动同步(仅当用户明确要求时执行)
argocd app sync simplex-aws-prod
**NEVER run `argocd app sync simplex-aws-prod` automatically.**argocd app sync simplex-aws-prod
**绝对禁止自动运行`argocd app sync simplex-aws-prod`命令。**File Locations
文件位置
kubernetes/overlays/aws-staging/kustomization.yaml # Staging config
kubernetes/overlays/aws-prod/kustomization.yaml # Production configkubernetes/overlays/aws-staging/kustomization.yaml # 预发布环境配置
kubernetes/overlays/aws-prod/kustomization.yaml # 生产环境配置Quick Commands
快速命令
View Image Differences
查看镜像差异
bash
undefinedbash
undefinedUsing the sync script
使用同步脚本
python3 ~/.claude/skills/sync-to-prod/scripts/sync_images.py --diff
python3 ~/.claude/skills/sync-to-prod/scripts/sync_images.py --diff
Or using make target (if in kubernetes/ directory)
或使用make目标(需在kubernetes/目录下)
make compare-images
undefinedmake compare-images
undefinedSync Images
同步镜像
bash
undefinedbash
undefinedSync specific services
同步特定服务
python3 ~/.claude/skills/sync-to-prod/scripts/sync_images.py --images front,anotherme-agent
python3 ~/.claude/skills/sync-to-prod/scripts/sync_images.py --images front,anotherme-agent
Sync all images (dry-run first)
同步所有镜像(先执行试运行)
python3 ~/.claude/skills/sync-to-prod/scripts/sync_images.py --all --dry-run
python3 ~/.claude/skills/sync-to-prod/scripts/sync_images.py --all --dry-run
Sync all images (apply changes)
同步所有镜像(应用变更)
python3 ~/.claude/skills/sync-to-prod/scripts/sync_images.py --all
undefinedpython3 ~/.claude/skills/sync-to-prod/scripts/sync_images.py --all
undefinedSync Workflow
同步工作流
Step 1: Compare Environments
步骤1:对比环境配置
Run the diff command to see what's different between staging and production:
bash
python3 ~/.claude/skills/sync-to-prod/scripts/sync_images.py --diffThis shows:
- 🔄 DIFFERENT TAGS: Services with different versions
- ✅ SAME TAGS: Services already in sync
- ⚠️ STAGING ONLY: Services only in staging
- ⚠️ PROD ONLY: Services only in production
执行diff命令查看预发布与生产环境的配置差异:
bash
python3 ~/.claude/skills/sync-to-prod/scripts/sync_images.py --diff该命令会展示:
- 🔄 标签不同:版本不一致的服务
- ✅ 标签一致:已同步的服务
- ⚠️ 仅预发布环境存在:仅在预发布环境有的服务
- ⚠️ 仅生产环境存在:仅在生产环境有的服务
Step 2: Review and Select Services
步骤2:审核并选择要推广的服务
Decide which services to promote. Common patterns:
bash
undefined确定要推广的服务,常见操作示例:
bash
undefinedPromote a single critical service
推广单个核心服务
python3 ~/.claude/skills/sync-to-prod/scripts/sync_images.py --images front --dry-run
python3 ~/.claude/skills/sync-to-prod/scripts/sync_images.py --images front --dry-run
Promote frontend services
推广前端服务
python3 ~/.claude/skills/sync-to-prod/scripts/sync_images.py --images front,front-homepage --dry-run
python3 ~/.claude/skills/sync-to-prod/scripts/sync_images.py --images front,front-homepage --dry-run
Promote all AI services
推广所有AI服务
python3 ~/.claude/skills/sync-to-prod/scripts/sync_images.py --images anotherme-agent,anotherme-api,anotherme-search,anotherme-worker --dry-run
python3 ~/.claude/skills/sync-to-prod/scripts/sync_images.py --images anotherme-agent,anotherme-api,anotherme-search,anotherme-worker --dry-run
Promote everything
推广所有服务
python3 ~/.claude/skills/sync-to-prod/scripts/sync_images.py --all --dry-run
undefinedpython3 ~/.claude/skills/sync-to-prod/scripts/sync_images.py --all --dry-run
undefinedStep 3: Apply Changes
步骤3:应用变更
After reviewing dry-run output, apply the changes:
bash
python3 ~/.claude/skills/sync-to-prod/scripts/sync_images.py --images <services>审核试运行输出后,应用变更:
bash
python3 ~/.claude/skills/sync-to-prod/scripts/sync_images.py --images <services>Step 4: Commit and Push
步骤4:提交并推送
bash
cd /path/to/simplex-gitops
git add kubernetes/overlays/aws-prod/kustomization.yaml
git commit -m "chore: promote <services> to production"
git push重要:推送后 ArgoCD 会检测到变更,但不会自动同步到生产集群。
bash
cd /path/to/simplex-gitops
git add kubernetes/overlays/aws-prod/kustomization.yaml
git commit -m "chore: promote <services> to production"
git push重要:推送后 ArgoCD 会检测到变更,但不会自动同步到生产集群。
Step 5: Manual Production Sync (User Action Required)
步骤5:手动同步生产环境(需用户操作)
推送完成后,需要用户手动触发生产环境同步:
bash
undefined推送完成后,需要用户手动触发生产环境同步:
bash
undefined查看待同步的变更
查看待同步的变更
argocd app get simplex-aws-prod
argocd app diff simplex-aws-prod
argocd app get simplex-aws-prod
argocd app diff simplex-aws-prod
用户确认后手动同步
用户确认后手动同步
argocd app sync simplex-aws-prod
或通过 ArgoCD Web UI 手动点击 Sync 按钮:
- URL: http://192.168.10.117:31006
- 找到 `simplex-aws-prod` 应用
- 点击 "SYNC" 按钮argocd app sync simplex-aws-prod
或通过 ArgoCD Web UI 手动点击 Sync 按钮:
- URL: http://192.168.10.117:31006
- 找到 `simplex-aws-prod` 应用
- 点击 "SYNC" 按钮Configuration Sections That May Need Sync
可能需要同步的配置项
Beyond image tags, these sections may differ between environments:
除镜像标签外,以下配置项在环境间可能存在差异:
1. Image Tags (Primary Sync Target)
1. 镜像标签(主要同步目标)
Located in the section. This is what the sync script handles.
images:位于部分,这是同步脚本处理的内容。
images:2. ConfigMap Patches
2. ConfigMap 补丁
Files in directory may contain environment-specific values:
patches/| Patch File | Purpose | Sync Consideration |
|---|---|---|
| API config | Usually environment-specific, don't sync |
| Gateway config | Usually environment-specific |
| Agent config | May need selective sync |
| Agent secrets | Never sync, environment-specific |
| Search config | May need selective sync |
| Cron config | Usually environment-specific |
| Router config | Usually environment-specific |
| Frontend env vars | Usually environment-specific |
| Ingress rules | Never sync, different domains |
patches/| 补丁文件 | 用途 | 同步注意事项 |
|---|---|---|
| API配置 | 通常为环境特定,请勿同步 |
| 网关配置 | 通常为环境特定 |
| Agent配置 | 可能需要选择性同步 |
| Agent密钥 | 绝对禁止同步,为环境特定 |
| 搜索配置 | 可能需要选择性同步 |
| 定时任务配置 | 通常为环境特定 |
| 路由配置 | 通常为环境特定 |
| 前端环境变量 | 通常为环境特定 |
| 入口规则 | 绝对禁止同步,域名不同 |
3. Replica Counts
3. 副本数量
Staging often runs with fewer replicas. Production uses base defaults or higher. This is intentional and should NOT be synced.
预发布环境通常运行较少副本,生产环境使用基础默认值或更高副本数。这是有意设置的,请勿同步。
4. Node Pool Assignments
4. 节点池分配
- Staging: /
karpenter.sh/nodepool: stagingsingleton-staging - Production: /
karpenter.sh/nodepool: productionsingleton-production
These are environment-specific and should NOT be synced.
- 预发布环境:/
karpenter.sh/nodepool: stagingsingleton-staging - 生产环境:/
karpenter.sh/nodepool: productionsingleton-production
这些为环境特定配置,请勿同步。
5. Storage Classes
5. 存储类
Both environments use similar patterns but production uses while staging uses . Usually no sync needed.
gp3ebs-gp3-auto两个环境使用类似模式,但生产环境使用而预发布环境使用。通常无需同步。
gp3ebs-gp3-auto6. High Availability Settings
6. 高可用设置
Production has additional HA configurations:
- for cross-AZ distribution
topologySpreadConstraints - for graceful shutdown
terminationGracePeriodSeconds: 60
These are production-specific optimizations and should NOT be synced to staging.
生产环境有额外的高可用配置:
- 用于跨可用区分布
topologySpreadConstraints - 用于优雅停机
terminationGracePeriodSeconds: 60
这些是生产环境特定优化,请勿同步到预发布环境。
Manual Sync Patterns
手动同步模式
For configurations not handled by the script:
对于脚本未处理的配置:
Sync a Specific ConfigMap Patch
同步特定ConfigMap补丁
bash
undefinedbash
undefinedCompare
对比差异
diff kubernetes/overlays/aws-staging/patches/anotherme-agent-env-configmap.yaml
kubernetes/overlays/aws-prod/patches/anotherme-agent-env-configmap.yaml
kubernetes/overlays/aws-prod/patches/anotherme-agent-env-configmap.yaml
diff kubernetes/overlays/aws-staging/patches/anotherme-agent-env-configmap.yaml
kubernetes/overlays/aws-prod/patches/anotherme-agent-env-configmap.yaml
kubernetes/overlays/aws-prod/patches/anotherme-agent-env-configmap.yaml
Copy if needed (carefully review first!)
如需同步(请先仔细审核!)
cp kubernetes/overlays/aws-staging/patches/anotherme-agent-env-configmap.yaml
kubernetes/overlays/aws-prod/patches/anotherme-agent-env-configmap.yaml
kubernetes/overlays/aws-prod/patches/anotherme-agent-env-configmap.yaml
undefinedcp kubernetes/overlays/aws-staging/patches/anotherme-agent-env-configmap.yaml
kubernetes/overlays/aws-prod/patches/anotherme-agent-env-configmap.yaml
kubernetes/overlays/aws-prod/patches/anotherme-agent-env-configmap.yaml
undefinedSync New Resources
同步新资源
If staging has new resources (PV, PVC, etc.) that production needs:
- Check staging section for new entries
resources: - Copy the resource files to aws-prod
- Add to aws-prod resources section
kustomization.yaml - Adjust environment-specific values (namespace, labels, etc.)
如果预发布环境有生产环境需要的新资源(PV、PVC等):
- 检查预发布环境部分的新条目
resources: - 将资源文件复制到aws-prod目录
- 在aws-prod的的resources部分添加该资源
kustomization.yaml - 调整环境特定值(命名空间、标签等)
Verification After Sync
同步后的验证
Check ArgoCD Status (Read-Only, Safe)
检查ArgoCD状态(只读,安全)
bash
undefinedbash
undefined查看应用状态和待同步变更
查看应用状态和待同步变更
argocd app get simplex-aws-prod
argocd app diff simplex-aws-prod
undefinedargocd app get simplex-aws-prod
argocd app diff simplex-aws-prod
undefinedManual Sync (User Must Explicitly Request)
手动同步(需用户明确请求)
bash
undefinedbash
undefined⛔ 仅在用户明确要求时执行
⛔ 仅在用户明确要求时执行
argocd app sync simplex-aws-prod
undefinedargocd app sync simplex-aws-prod
undefinedCheck Deployed Versions
检查已部署版本
bash
undefinedbash
undefinedProduction namespace
生产环境命名空间
k1 get pods -n production -o jsonpath='{range .items[]}{.metadata.name}{"\t"}{.spec.containers[].image}{"\n"}{end}'
k1 get pods -n production -o jsonpath='{range .items[]}{.metadata.name}{"\t"}{.spec.containers[].image}{"\n"}{end}'
Staging namespace
预发布环境命名空间
k2 get pods -n staging -o jsonpath='{range .items[]}{.metadata.name}{"\t"}{.spec.containers[].image}{"\n"}{end}'
undefinedk2 get pods -n staging -o jsonpath='{range .items[]}{.metadata.name}{"\t"}{.spec.containers[].image}{"\n"}{end}'
undefinedValidate Manifests
验证清单
bash
kubectl kustomize kubernetes/overlays/aws-prod > /tmp/prod-manifests.yaml
kubectl kustomize kubernetes/overlays/aws-staging > /tmp/staging-manifests.yaml
diff /tmp/staging-manifests.yaml /tmp/prod-manifests.yamlbash
kubectl kustomize kubernetes/overlays/aws-prod > /tmp/prod-manifests.yaml
kubectl kustomize kubernetes/overlays/aws-staging > /tmp/staging-manifests.yaml
diff /tmp/staging-manifests.yaml /tmp/prod-manifests.yamlTroubleshooting
故障排除
Script Not Finding Repository
脚本无法找到仓库
Ensure you're in the simplex-gitops directory or set the path explicitly:
bash
cd /path/to/simplex-gitops
python3 ~/.claude/skills/sync-to-prod/scripts/sync_images.py --diff确保你处于simplex-gitops目录中,或显式设置路径:
bash
cd /path/to/simplex-gitops
python3 ~/.claude/skills/sync-to-prod/scripts/sync_images.py --diffImage Not Found in Staging
预发布环境中未找到镜像
The service may use a different image name format (Aliyun vs ECR). Check both formats in the kustomization files.
该服务可能使用不同的镜像名称格式(阿里云 vs ECR)。请检查kustomization文件中的两种格式。
ArgoCD Not Syncing
ArgoCD未同步
bash
undefinedbash
undefined查看应用状态(只读)
查看应用状态(只读)
argocd app get simplex-aws-prod --show-operation
argocd app get simplex-aws-prod --show-operation
刷新应用检测最新变更(只读,安全)
刷新应用以检测最新变更(只读,安全)
argocd app refresh simplex-aws-prod
argocd app refresh simplex-aws-prod
⛔ 手动同步 - 仅在用户明确要求时执行
⛔ 手动同步 - 仅在用户明确要求时执行
argocd app sync simplex-aws-prod
undefinedargocd app sync simplex-aws-prod
undefinedService Categories Reference
服务分类参考
| Category | Services |
|---|---|
| AI Core | |
| Frontend | |
| Backend | |
| Data | |
| Infrastructure | |
| 分类 | 服务 |
|---|---|
| AI核心 | |
| 前端 | |
| 后端 | |
| 数据 | |
| 基础设施 | |