Kubernetes 微服务版本控制
Kubernetes Microservice Versioning
我是 Kubernetes 的新手,只是从一个示例项目开始学习所有内容。我目前 运行 一个需要 MongoDB 作为数据库的 .NET 微服务。微服务被打包到一个 Docker 图像中,我创建了一个 Helm 图表来正确部署我的微服务和所需的 MongoDB.
现在我考虑了版本控制并发现了这种方法的一个大问题:我不能只安装多个版本的 helm chart 来支持 运行 同一微服务的多个版本,因为这样每个微服务有自己的数据库,这显然不是我想要的。
这是否意味着我必须为我的微服务创建两个 helm 图表?那么一张包含我的 .NET 服务的 api
图表和一张包含 MongoDB 的 db
图表?这样我就可以部署一次 MongoDB 并让我的 .NET 服务的多个版本指向这个单一实例。但是,这样我就没有每个微服务有一个 Helm 图表,而是有多个,我猜这会增加部署开销。
这是怎么做到的?还是我缺少什么?非常欢迎所有指向正确方向的线索!
我建议每项服务一张图表。 helm 依赖项运行良好的地方是您拥有 embeds/hides 特定单个其他部分的服务。正如@christopher 所说,如果您的 .NET 服务和 MongoDB 具有不同的生命周期,则不应将它们打包在同一个 helm chart 中。
使用 Helm 的最基本方法是使用一个包含单个应用程序的图表。单个图表将包含您的应用程序所需的所有资源,例如部署、服务等。
Chart versions and appVersions
The version of the chart itself (version field in Chart.yaml). The
version of the application contained in the chart (appVersion field in
Chart.yaml). These are unrelated and can be bumped up in any manner
that you see fit. You can sync them together or have them increase
independently. There is no right or wrong practice here as long as you
stick into one.
这里很重要的一点是,您需要在您的团队中采用关于“图表更改”意味着什么的政策。
Helm 不强制更改图表版本。您可以部署与前一个版本相同的不同图表。因此,如果这是您想做的事情,您需要确保所有团队都在同一页面上进行版本控制实践。
从好的方面来说,此工作流允许您单独对图表和应用程序进行版本控制,对于拥有单独管理图表与应用程序源代码的团队的公司来说非常灵活。
但是,您也可以创建一个与其他图表具有依赖关系的图表,称为伞状图表。
They are completely external using the requirements.yaml
file. Using this strategy is optional and can
work well in several organizations. Again, there is no definitive
answer on right and wrong here, it depends on your team process.
In other words, a collection of software elements that each have their
own individual charts but, for whatever reason (e.g. design choices,
ease of deployability, versioning complexities), must be installed or
upgraded as a since atomic unit
An umbrella chart references the version of the Helm chart itself and
not the underlying version of the container image. This means that any
change to the image version will result in chart modifications to the
individual component charts.
选择选项时要考虑的因素
有两个维度需要考虑:
- 团队结构:您必须问自己这样的问题:您是否有负责每项服务的小型自治团队?你有开发人员吗
了解 DevOps?
- 依赖性和可重复性:您必须问自己这样的问题:每个服务的依赖性有何不同?改变一个有什么风险
服务会断另一个?你如何重现a的条件
具体发展?
在有用的文章中阅读更多内容:helm-managing-microservices。
关于微服务的版本控制以实现向后兼容性,一般建议参见 , in general Semantic Versioning。
在更广泛的意义上 - 应该有一个商定的 phase-out 主要版本的路线图,传达给 API 消费者(连同 SLA)。这就是为什么跟踪谁使用您的 API 很重要。看看这个有用的 article about versioning management.
查看用于跟踪微服务版本的示例工具 - DeployHub。
我是 Kubernetes 的新手,只是从一个示例项目开始学习所有内容。我目前 运行 一个需要 MongoDB 作为数据库的 .NET 微服务。微服务被打包到一个 Docker 图像中,我创建了一个 Helm 图表来正确部署我的微服务和所需的 MongoDB.
现在我考虑了版本控制并发现了这种方法的一个大问题:我不能只安装多个版本的 helm chart 来支持 运行 同一微服务的多个版本,因为这样每个微服务有自己的数据库,这显然不是我想要的。
这是否意味着我必须为我的微服务创建两个 helm 图表?那么一张包含我的 .NET 服务的 api
图表和一张包含 MongoDB 的 db
图表?这样我就可以部署一次 MongoDB 并让我的 .NET 服务的多个版本指向这个单一实例。但是,这样我就没有每个微服务有一个 Helm 图表,而是有多个,我猜这会增加部署开销。
这是怎么做到的?还是我缺少什么?非常欢迎所有指向正确方向的线索!
我建议每项服务一张图表。 helm 依赖项运行良好的地方是您拥有 embeds/hides 特定单个其他部分的服务。正如@christopher 所说,如果您的 .NET 服务和 MongoDB 具有不同的生命周期,则不应将它们打包在同一个 helm chart 中。
使用 Helm 的最基本方法是使用一个包含单个应用程序的图表。单个图表将包含您的应用程序所需的所有资源,例如部署、服务等。
Chart versions and appVersions
The version of the chart itself (version field in Chart.yaml). The version of the application contained in the chart (appVersion field in Chart.yaml). These are unrelated and can be bumped up in any manner that you see fit. You can sync them together or have them increase independently. There is no right or wrong practice here as long as you stick into one.
这里很重要的一点是,您需要在您的团队中采用关于“图表更改”意味着什么的政策。
Helm 不强制更改图表版本。您可以部署与前一个版本相同的不同图表。因此,如果这是您想做的事情,您需要确保所有团队都在同一页面上进行版本控制实践。
从好的方面来说,此工作流允许您单独对图表和应用程序进行版本控制,对于拥有单独管理图表与应用程序源代码的团队的公司来说非常灵活。
但是,您也可以创建一个与其他图表具有依赖关系的图表,称为伞状图表。
They are completely external using the
requirements.yaml
file. Using this strategy is optional and can work well in several organizations. Again, there is no definitive answer on right and wrong here, it depends on your team process.
In other words, a collection of software elements that each have their own individual charts but, for whatever reason (e.g. design choices, ease of deployability, versioning complexities), must be installed or upgraded as a since atomic unit
An umbrella chart references the version of the Helm chart itself and not the underlying version of the container image. This means that any change to the image version will result in chart modifications to the individual component charts.
选择选项时要考虑的因素
有两个维度需要考虑:
- 团队结构:您必须问自己这样的问题:您是否有负责每项服务的小型自治团队?你有开发人员吗 了解 DevOps?
- 依赖性和可重复性:您必须问自己这样的问题:每个服务的依赖性有何不同?改变一个有什么风险 服务会断另一个?你如何重现a的条件 具体发展?
在有用的文章中阅读更多内容:helm-managing-microservices。
关于微服务的版本控制以实现向后兼容性,一般建议参见
在更广泛的意义上 - 应该有一个商定的 phase-out 主要版本的路线图,传达给 API 消费者(连同 SLA)。这就是为什么跟踪谁使用您的 API 很重要。看看这个有用的 article about versioning management.
查看用于跟踪微服务版本的示例工具 - DeployHub。