gpt4 book ai didi

templates - Kubernetes-helm:为多个应用程序使用一个模板

转载 作者:行者123 更新时间:2023-12-02 12:02:56 25 4
gpt4 key购买 nike

这是我目前拥有的:

带基本helm create来了 values.yaml文件和 template带有 deployment.yaml 的文件夹.Deployment文件已被改编为管理 docker 镜像中的 spring-boot 应用程序。

现在values.yaml包含类似的东西

myApp:
repository: myApp.mycompany.com/demo/my-app-customers
tag: stable

deployment.yaml包含
spec:
template:
spec:
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.myApp.repository }}:{{ .Values.myApp.tag }}"

假设我必须管理另一个 spring-boot 应用程序,非常接近“我的应用程序客户”。我以为我只需要在 values.yaml 中添加另一行, 像那样:
mySecondApp:
repository: myApp.mycompany.com/demo/my-app-others
tag: stable

但这不适用于 deployment.yaml因为它使用 .Values.myApp.repository .这意味着我需要创建另一个文件 deployment-others.yaml使用 .Values.mySecondApp.repository部署第二个应用程序。因此不可能为不同的应用程序使用相同的模板。
  • 我是对的还是我错过了什么?
  • 是否有另一种方法可以做到这一点,或者我是否需要复制过去类似的部署(和其他)文件并为每个应用程序设置一个模板文件?
  • 最佳答案

    如果部署资源几乎相同,您可以将 Helm 图表视为抽象并使用 --set 指定值。旗帜。

    helm install --set repository=myApp.mycompany.com/demo/my-first-app --name my-first-app /path/to/helm/chart my-first-app
    helm install --set repository=myApp.mycompany.com/demo/my-second-app --name my-second-app /path/to/helm/chart my-second-app

    关于templates - Kubernetes-helm:为多个应用程序使用一个模板,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58325907/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com