Helm conditionally install subchart

走远了吗. 提交于 2019-12-12 14:50:04

问题


Is there a way to conditionally install a helm subchart based on global values.yaml? I've all my internal services and components as subcharts, and one of them is a messagequeue chart. In my dev and test environment (local k8s), I use RabbitMQ, and in staging and Prod (AKS), I use Azure Service Bus. Based on the namespace/values.yaml, I want to install rabbitmq or not.

P.S - I've created all the components as subcharts so that they are all part of a single release.


回答1:


I've found out the answer:

In requirements.yaml, add:

dependencies:
- name: api
  condition: api.enabled
- name: messagequeue
  condition: messagequeue.enabled

and in values.yaml, add

api:
  enabled: true    
messagequeue:
  enabled: false

Now during installation, pass the values to enabled or disable the messagequeue as follows:

helm install --dry-run --debug website\ --set messagequeue.enabled=true

or

helm install --dry-run --debug website\ --set messagequeue.enabled=false



回答2:


I would propose this (ugly) workaround as answer borrowed from @sgandon: https://github.com/helm/helm/issues/3742#issuecomment-383095917

dependencies: - name: mobi-postgresql version: 1.0.1 repository: "@mobi" alias: postgresql - name: oraclepdb version: 0.0.1 repository: "file://subcharts/oraclepdb" condition: oraclepdb.enabled

Then you can use the practice Chart dependencies to manage subcharts as dependencies via helm dep update and helm dep build.

It's not beautiful as long as this bug is not fixed.



来源:https://stackoverflow.com/questions/54032974/helm-conditionally-install-subchart

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!