如何跳过在 helm 中部署模板以及是否可以在 Chart.yaml 中使用自定义属性

问题描述 投票:0回答:2

我的图表定义如下

 my-charts/
  |_  app1
       |
       |_Chart.yaml
       |_ values-dev.yaml
       |_ values.yaml
       |_ .helmignore
       |_ template/
             |_ app1-microservice1-deployment.yaml  (k8s deployment definition)
             |_ app1-microservice1-service-defintion.yaml   (k8s service definition)
             |_ app1-microservice2-deployment.yaml
             |_ app1-microservice2-service-defintion.yaml

假设我是否只想部署模板

  • app1-microservice1-deployment.yaml
  • app1-microservice1-service-defintion.yaml

有什么办法可以实现吗?

  • 如果我将
    .helmignore
    与其他
    app1-microservice2*.yaml
    文件一起使用,
    helm install/upgrade
    会忽略部署这些文件吗?
  • 该领域是否有任何最佳实践。

此外,在 helm3 中

Chart.yaml
任何自定义字段/属性都可以根据文档包含在
annotation
中。

apiVersion: v2
description: application description
name: app1-microservices
version: 1.0.1

# Is the below possible in helm3
projectNames: microservice1,microservice2
imageRepo:
   microservice1: app1/microservice1
   microservice2: app1/microservice2

如果在 Chart.yaml 中包含自定义属性会发生什么。

我正在探索 helm,如果问题不够清楚,请道歉。

kubernetes-helm
2个回答
2
投票

您需要在

.helmignore
文件中添加以下行。

templates/wapp1-microservice2-*

然后 helm 应该处理剩下的事情。


0
投票
  • 在 helm3 Chart.yaml 中,任何自定义字段/属性都可以包含在每个文档的注释中。
    • 文档中指定以外的任何值。
    • 当 helm 渲染时,下面的效果很好,但是这个projectNames不能被像
      .Chart.projectNames
      这样的模板使用。
apiVersion: v2
name: example2
description: A Helm chart for Kubernetes

type: application

version: 0.1.0

appVersion: "1.16.0"

projectNames: ["app1","app2"]

为了跳过在 helm 中渲染的特定部署,我们可以使用 {{- if .Values.enabledForRelease }}... 来包装 template.yaml

© www.soinside.com 2019 - 2024. All rights reserved.