Intro to Spinnaker – 帆板介绍

最后修改: 2018年 12月 17日

中文/混合/英文(键盘快捷键:t)

1. Overview

1.概述

In this tutorial, we’re going to look at Spinnaker, an open-source continuous delivery platform built by Netflix. We can use it to deploy our applications across multiple cloud providers.

在本教程中,我们将了解Spinnaker,这是一个由Netflix构建的开源连续交付平台。我们可以使用它来在多个云提供商之间部署我们的应用程序。

The system is built on top of Spring Boot and supports many cloud providers.

该系统建立在Spring Boot之上,支持许多云供应商。

We’ll see how it works and for which cases we can use it.

我们将看到它是如何工作的,以及在哪些情况下我们可以使用它。

2. Background

2. 背景

Let’s have a look at the history of software development. First, we had the Waterfall with infrequent releases.

让我们看一下软件开发的历史。首先,我们有瀑布式的不定期发布。

After that, we started working Agile and delivered features every sprint. However, we still didn’t deploy to production every sprint. Unfortunately, the users still couldn’t use the new features, which were lying on a shelf.

在那之后,我们开始了敏捷工作,并在每个冲刺阶段交付功能。然而,我们仍然没有在每个冲刺阶段部署到生产中。不幸的是,用户仍然无法使用新的功能,这些功能被搁置在架子上。

There were some reasons for not deploying regularly. One of them was the fact that deployment steps were often manually executed and prone to human errors.

没有定期部署是有一些原因的。其中一个原因是,部署步骤往往是手动执行的,容易出现人为错误。

In addition, some people thought that deploying more often meant more risk for potential problems. Nowadays, we mostly agree that deploying small changes means less risk for big mistakes. Even so, if there is a mistake, we can quickly locate it in the small change and release a new version that resolves the issue.

此外,有些人认为,更频繁的部署意味着潜在问题的风险更大。如今,我们大多同意,部署小改动意味着大错误的风险更小。即便如此,如果有错误,我们也能迅速在小改动中找到它,并发布一个解决该问题的新版本。

3. Spinnaker

3.帆板

With Spinnaker, we can use continuous delivery or continuous deployment to release our application on production automatically. Continuous delivery means that everything is prepared for a production release.

通过Spinnaker,我们可以使用持续交付或持续部署来自动在生产中发布我们的应用程序。持续交付意味着为生产发布做好一切准备。

However, the release is approved manually before the application is deployed on production. Continuous deployment means there is no manual intervention. All steps are executed, including the deployment to production. We just push our application code to a version control system and that’s it.

然而,在应用程序被部署到生产中之前,发布是由人工批准的。持续部署意味着没有人工干预。所有步骤都被执行,包括部署到生产中。我们只是将我们的应用程序代码推送到一个版本控制系统,仅此而已。

From pushing our code to version control until the deployment to production, we can execute lots of steps. We can build our code, unit test the code, deploy it on a test environment and execute functional tests. We use a so-called pipeline to configure all those steps.

从把我们的代码推送到版本控制直到部署到生产,我们可以执行很多步骤。我们可以构建我们的代码,对代码进行单元测试,将其部署在测试环境中并执行功能测试。我们使用一个所谓的管道来配置所有这些步骤。

With Spinnaker, we can create such a pipeline and deploy our application on most cloud providers.

通过Spinnaker,我们可以创建这样一个管道,并将我们的应用程序部署在大多数云供应商上。

4. Components

4.组成部分

Spinnaker basically consists of two parts: an abstraction layer on top of various cloud providers and a tool for continuous delivery.

Spinnaker基本上由两部分组成:一个在各种云供应商之上的抽象层和一个持续交付的工具。

4.1. Traditional Cloud Deployments

4.1.传统的云计算部署

When we look at cloud providers, they all offer more or less the same services. Those services include things as instances, serverless, and container support.

当我们审视云计算供应商时,他们都提供了或多或少相同的服务。这些服务包括实例、无服务器和容器支持等内容。

However, the configuration of those services greatly varies between the providers. That makes it harder to switch between providers. It takes some time to move to another cloud provider and learn all the details, which means we basically have vendor lock-in with our cloud provider.

然而,这些服务的配置在不同的供应商之间有很大差异。这使得在供应商之间切换变得更加困难。转移到另一个云供应商并学习所有的细节需要一些时间,这意味着我们基本上对我们的云供应商有供应商锁定。

Netflix wanted to have the possibility to easily switch between cloud providers, rather than be dependent on just one. That’s why they built an abstraction layer on top of the cloud providers.

Netflix希望有可能在云供应商之间轻松切换,而不是只依赖一个。这就是为什么他们在云供应商之上建立了一个抽象层。

4.2. Abstraction Layer

4.2.抽象层

When we use Spinnaker, it’s the same on all cloud providers. We can use it on Amazon Web Services, Microsoft Azure, Google Cloud Platform, OpenStack, Google App Engine, or Kubernetes. This allows us to move to another cloud provider if the prices are more competitive.

当我们使用Spinnaker时,它在所有云提供商上都是一样的。我们可以在Amazon Web Services、Microsoft Azure、Google Cloud Platform、OpenStack、Google App Engine或Kubernetes上使用它。这使得我们可以在价格更具竞争力的情况下转移到另一个云供应商。

Even more, we can choose to deploy to multiple providers at the same time. That way we can run our application on two or more providers for extra redundancy.

甚至更多,我们可以选择同时部署到多个提供商。这样,我们可以在两个或更多的提供商上运行我们的应用程序,以获得额外的冗余度。

Another benefit of the abstraction layer is that it focuses on the applications instead of the resources. Normally, cloud providers show us the resources that we currently use. However, we have to figure out ourselves what application is using which resources.

抽象层的另一个好处是,它关注的是应用而不是资源。通常情况下,云提供商会向我们展示我们当前使用的资源。然而,我们必须自己弄清楚哪些应用程序正在使用哪些资源。

But resources aren’t interesting for us. We want to run our application without spending time keeping track of resources. Spinnaker has an application-centric view. So, when we look at it, we first see the application, and then we see the resources used by the application.

但资源对我们来说并不有趣。我们想运行我们的应用程序,而不需要花时间去跟踪资源。Spinnaker有一个以应用为中心的视图。因此,当我们看它的时候,我们首先看到的是应用程序,然后是应用程序使用的资源。

4.3. Continuous Delivery

4.3.持续交付

On top of the abstraction layer, Netflix built a continuous delivery platform. This platform allows us to deploy our application on one or more cloud providers. It looks a bit like Jenkins, but it offers nicer integration with the cloud providers and requires less configuration.

在抽象层之上,Netflix构建了一个持续交付平台。该平台允许我们在一个或多个云提供商上部署我们的应用程序。它看起来有点像Jenkins,但它提供了与云提供商更好的集成,并且需要更少的配置。

We can trigger the continuous delivery pipeline from Jenkins, an uploaded Docker image, or a git push, for example. After that, we can simply create an image or a container with our application and start it on production.

例如,我们可以从Jenkins、上传的Docker镜像或git推送中触发持续交付管道。之后,我们可以简单地用我们的应用程序创建一个镜像或一个容器,并在生产中启动它。

However, there are many more options available such as automated tests and manual approvals before deploying on production.

然而,还有更多的选择,如自动测试和在生产中部署前的手动批准。

We can even decide what strategy we want to follow when deploying a new version of an existing application. As such, it’s possible to simply replace the old version with the new version. However, a better strategy would be to run them side by side first. That way we can automatically or manually check if the new version works and, if so, remove the old version.

我们甚至可以决定在部署一个现有应用程序的新版本时,我们要遵循什么策略。因此,可以简单地用新版本替换旧版本。然而,一个更好的策略是先将它们并排运行。这样,我们就可以自动或手动检查新版本是否可以运行,如果可以,就删除旧版本。

5. The Netflix Cloud Model

5.Netflix的云模式

Every application consists of one or more server groups. The same version of the application runs on all instances in the server group. The following naming convention is used: <application-name>-<(optional) stack>-<(optional detail)>-<version-number>. The (optional) stack field is used to specify if the server group is for test, production or other purposes. The optional detail field is used for extra information.

每个应用程序由一个或多个服务器组组成。同一版本的应用程序在服务器组的所有实例上运行。使用以下命名惯例。<应用程序名称>-<(可选)堆栈>-<(可选细节)>-<版本号>。堆栈字段用于指定服务器组是否用于测试、生产或其他目的。可选的细节字段用于提供额外的信息。

Finally, we have the concept of a cluster that contains one or more server groups with the same name, stack, and detail. However, most of the time each server group in the cluster runs a different version of the application. Failing instances will be replaced by a new instance.

最后,我们有一个集群的概念,它包含一个或多个具有相同名称、堆栈和细节的服务器组。然而,大多数时候,集群中的每个服务器组都运行不同版本的应用程序。失败的实例将被一个新的实例所取代。

It’s also possible to automatically add instances to a server group to accommodate the increased load.

还可以自动向服务器组添加实例,以适应增加的负载。

6. Deployment Strategy

6.部署战略

When we deploy a new version of an application, the ‘red/black’ strategy is normally chosen. First, a new server group containing the new version of the application is deployed to the cluster. After the application deployment, a check is performed to verify if the new server group is healthy.

当我们部署一个新版本的应用程序时,通常会选择 “红/黑 “策略。首先,一个包含新版本应用程序的新服务器组被部署到集群上。在应用程序部署后,将进行检查以验证新的服务器组是否健康。

Now, the server group is enabled and available to our customers. Finally, the old server group is disabled.

现在,该服务器组已经启用,可供我们的客户使用。最后,旧的服务器组被禁用。

In this scenario, it’s easy to roll back if something goes wrong with the new application server. We can simply enable the server group with the old version again and make it available to our customers.

在这种情况下,如果新的应用服务器出现问题,我们很容易回滚。我们可以简单地再次启用旧版本的服务器组,并将其提供给我们的客户。

7. Why Spinnaker

7.为什么要使用Spinnaker

With Spinnaker, we can focus on our application instead of the cloud resources that we use. This makes it easier to deploy and maintain our applications.

通过Spinnaker,我们可以专注于我们的应用程序,而不是我们使用的云资源。这使得我们更容易部署和维护我们的应用程序。

Additionally, Spinnaker makes it possible to run on multiple cloud providers at the same time. Moreover, we can easily switch to other cloud providers depending on their pricing strategy and available features.

此外,Spinnaker使我们有可能同时在多个云供应商上运行。此外,我们可以很容易地切换到其他云供应商,这取决于他们的定价策略和可用功能。

8. Conclusion

8.结语

Spinnaker builds on the experience of Netflix. We can use their knowledge and work in the same way with minimal effort. Based on these tools, we can easily implement a deployment pipeline to deploy our applications to production.

Spinnaker建立在Netflix的经验之上。我们可以利用他们的知识,以同样的方式工作,而且工作量很小。基于这些工具,我们可以轻松实现部署管道,将我们的应用程序部署到生产中。

To learn more about Spinnaker, download the free Continuous Delivery with Spinnaker ebook.

要了解有关Spinnaker的更多信息,请下载免费的使用Spinnaker连续交付电子书。