Introduction of Spinnaker

spin-logo-800x400.jpg?w=2924

Why Spinnaker?

在開始使用 Spinnaker 之前, 先來了解一下它是什麼東西, 為什麼要使用它, 以及它能為我們整合開發上帶來什麼好處.

Netflix 推出這個開源的 project 用來做為 Continuous Integration (CI) 之後的發佈動作 (Continuous Delivery, CD) 最後一哩路. 而 Spinnaker 在 Github 上面對自己的定位:

Spinnaker is an open source, multi-cloud continuous delivery platform for releasing software changes with high velocity and confidence.

其中最關鍵一句話: 可以快速部署到多種不同雲的部署平台. 可以從下圖看到 Spinnaker 概括的開發週期.

spinnaker.png
Spinnaker Adapted Development Cycle

Spinnaker 真正最大的用武之地正在 Github 的 CI (像是 Jenkins, etc.) 結束後的快速部署.

Core Feature Sets

目前 Spinnaker 主要提供 2 種不同的 core feature sets.

  • Application Management (應用管理)
  • Application Deployment (應用部署)

以下則針對這兩個不同的特色來稍微介紹一下.

Application Management (應用管理)

在 Spinnaker 的服務中有三個主要的角色:

  • Application (應用)

    • 簡單來說, 你發佈在 server 上的 - 不管是 Application type, e.g. 某個線上應用, 或者是微服務群 (MicroServices), 都可以對應到 Spinnaker 的 Application 這個概念上. 一個 Application 會包含多個 Cluster (群組). 通常 Application 上面會包含防火牆或者負載平衡. 基本上就是你所發佈 Service 的運行環境集合.
  • Cluster (群組)

    • 這邊的 Cluster 是指一群 Server Group 的集合, 跟 K8s 上面的所指的 Cluster 不同.
  • Server Group

    • 這邊的 Server Group 指的是由 VM image, Docker image, 或者 pod 等 source location 所產生的 instance 群組, 包含相關的設定檔案.

可以從底下相關的 diagram 更清楚地暸解全貌:
clusters.png
Application, Cluster, and Server Group

其中流量透過負載平衡器經過防火牆進入各種不同 Server Group.

Application Deployment (應用部署)

當我們使用 Spinnaker 進行應用部署的時候, 每個階段(stage)可以有各種不同的操作, 可以看一下底下的 Pipeline:

pipelines.png
Spinnaker Pipeline

使用 pipeline 的時機點可以非常彈性, 可透過手動啟用 pipeline 或者 透過自動化設定 Event 的方式來啟動一個 pipeline, 像是你 CI server (Jenkins) 完成工作的時候, 送一個 event 到 Spinnaker 來啟動 Auto-deploy. 而 Pipeline 也可以跟常用的 Slack 整合, 你會看到以下的畫面:

spin46.png
Slack Integration

當然整合 Email/SMS 是最基本的功能, 詳細可以看看 Spinnaker 相關的設定. 這邊需要提一下 Stage:

A Stage in Spinnaker is an atomic building block for a pipeline, describing an action that the pipeline will perform. You can sequence stages in a Pipeline in any order, though some stage sequences may be more common than others. Spinnaker provides a number of stages such as Deploy, Resize, Disable, Manual Judgment, and many more. You can see the full list of stages and read about implementation details for each provider in the Reference section.

Stage 在 Pipeline 有著非常重要的地位, 基本上在整個 pipeline 過程中可以給予 Stage 不同的參數來做不同事情, 也可以任意改變 Stage 在 Pipeline 裡面的順序, 彈性相當大. 最後來看看佈署策略, 其實 Spinnaker 提供的部屬策略主要有這幾種:

Deployment Strategy

  • Highlander
  • Red/Black (紅黑策略, 又稱為藍綠策略)
  • Rolling Red/Black
  • Canary

看一下圖例可以更好地瞭解:

deployment-strategies.png
Deployment Strategy

詳細的部署策略可以看 [4], 更深入的介紹就留待下一篇了!

Reference

[1] https://medium.com/netflix-techblog/global-continuous-delivery-with-spinnaker-2a6896c23ba7
[2] https://programmaticponderings.com/tag/spinnaker/
[3] https://www.spinnaker.io/concepts/
[4] https://blog.armory.io/tag/spinnaker-training-series/