Skip to content
返回部署

使用 Spinnaker 部署

面向多云部署的持续交付平台,支持高级部署策略。

CI/CD高级

为什么

Spinnaker 抽象了 AWS、GCP、Azure 和 Kubernetes 的云部署,内置 canary、蓝绿和滚动策略。DORA 2024 DevOps 状态报告显示精英团队部署频率比低绩效团队高 973 倍。

带自动化测试的 CI/CD 管道将变更失败率降至 5-15%,而手动部署为 40-60%。

何时使用

需要复杂部署策略和流水线编排的多云企业部署。贡献者少于 5 人的仓库避免复杂管道编排 — pre-commit 钩子 + GitHub Actions 足够。

除非需要 GPU 或 VPN 访问,否则跳过自托管 runner。

如何做

# 安装 Spinnaker via Halyard hal config provider kubernetes enable hal config provider kubernetes account add my-k8s --context-version 1.28 --kubeconfig-file ~/.kube/config hal config provider aws account add my-aws --access-key-id $AWS_KEY --secret-access-key $AWS_SECRET hal config deploy edit --type distributed hal deploy apply # Define a 管道 in JSON or via Deck UI # 管道 阶段s: Bake → 部署 → Manual Judgment → Canary → 启用 Traffic 4. 验证部署 — curl -I https://your-app.example.com 5. 监控日志 — 前 5 分钟检查错误 6. 需要时回滚 — 回退到上一版本

示例

# Spinnaker 管道 JSON (excerpt) { "name": "deploy-to-prod", "stages": [ { "type": "bake", "name": "Build Image", "refId": "1" }, { "type": "deploy", "name": "Deploy to Cluster", "refId": "2", "requisiteStageRefIds": ["1"], "clusters": [{ "account": "my-k8s", "application": "myapp" }] }, { "type": "canary", "name": "Canary Analysis", "refId": "3", "requisiteStageRefIds": ["2"] } ] }

常见问题

  • ⚠Halyard 配置错误 — 运行 hal deploy connect 验证
  • ⚠Canary 指标未流入 — 检查 Kayenta 与 Prometheus/Datadog 集成
  • ⚠环境间配置漂移 — 使用基础设施即代码(Terraform/Pulumi)保持 dev/staging/prod 一致

最佳实践

  • ✓用托管流水线模板 — 标准化部署模式
  • ✓集成 Kayenta 做自动 canary 分析 — 减少人工判断
  • ✓设置健康检查和优雅关闭 — 处理 SIGTERM 以在退出前排空进行中的请求

常见问题解答