2 具有共享 Redis 依赖项的 Helm Charts [英] 2 Helm Charts with shared Redis dependency

查看:59
本文介绍了2 具有共享 Redis 依赖项的 Helm Charts的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前,我有 2 个 Helm Charts - Chart A 和 Chart B.Chart A 和 Chart B 对 Redis 实例具有相同的依赖关系,如 Chart.yaml 文件中所定义:

Currently, I have 2 Helm Charts - Chart A, and Chart B. Both Chart A and Chart B have the same dependency on a Redis instance, as defined in the Chart.yaml file:

dependencies:
- name: redis
  version: 1.1.21
  repository: https://kubernetes-charts.storage.googleapis.com/

由于连续应用 2 个图表导致 2 个 Redis 实例,因此我也覆盖了 Redis 的名称,例如:

I have also overwritten Redis's name since applying the 2 Charts consecutively results in 2 Redis instances, as such:

redis:
  fullnameOverride: "redis"

当我尝试安装图表 A 和图表 B 时,出现以下错误:

When I try to install Chart A and then Chart B I get the following error:

错误:呈现的清单包含已存在的资源.无法继续安装:现有资源冲突:种类:PersistentVolumeClaim,命名空间:默认,名称:redis

我的印象是,如果已经存在,两个具有相同依赖项的图表会使用相同的实例?

I was left with the impression that 2 charts with identical dependencies would use the same instance if it's already present?

推荐答案

当您使用 Helm 安装 chart 时,它通常希望每个 release 都有自己独立的 Kubernetes 对象集.在您展示的基本示例中,我希望看到 Kubernetes Service 对象的名称类似于

When you install a chart using Helm, it generally expects each release to have its own self-contained set of Kubernetes objects. In the basic example you show, I'd expect to see Kubernetes Service objects named something like

release-a-application-a
release-a-redis
release-b-application-b
release-b-redis

有一个通用约定,对象以{{ .Release.Name }}开头,因此两个Redises是分开的.

There is a general convention that objects are named starting with {{ .Release.Name }}, so the two Redises are separate.

这实际上是预期的设置.构建微服务的一个典型规则是每个服务都包含自己独立的存储,并且服务之间从不共享存储.此 Helm 模式支持这一点,并且进行此设置并没有真正的缺点.

This is actually an expected setup. A typical rule of building microservices is that each service contains its own isolated storage, and that services never share storage with each other. This Helm pattern supports that, and there's not really a disadvantage to having this setup.

如果你真的希望两个图表共享一个Redis安装,你可以写一个伞形"图表,它自己不做任何事情,而是依赖于两个应用图表.该图表将有一个 Chart.yaml 文件和(在 Helm 2 中)一个 requirements.yaml 文件,该文件引用了另外两个图表,但不是一个 templates 自己的目录.这将导致 Helm 得出结论,单个 Redis 可以支持这两个应用程序,并且您最终会得到类似

If you really want the two charts to share a single Redis installation, you can write an "umbrella" chart that doesn't do anything on its own but depends on the two application charts. The chart would have a Chart.yaml file and (in Helm 2) a requirements.yaml file that references the two other charts, but not a templates directory of its own. That would cause Helm to conclude that a single Redis could support both applications, and you'd wind up with something like

umbrella-application-a
umbrella-application-b
umbrella-redis

(根据我的经验,你通常想要这个——你确实希望每个应用程序有一个单独的 Redis——因此尝试使用伞形图来管理多个安装不会效果不是特别好.)

(In my experience you usually don't want this – you do want a separate Redis per application – and so trying to manage multiple installations using an umbrella chart doesn't work especially well.)

这篇关于2 具有共享 Redis 依赖项的 Helm Charts的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆