How to add external helm as part of my helm? - kubernetes

My helm depends on another helm from public repository. I've installed it manually and put the command to documentation. But I'd like to do it automatically.
Is there some way to set such dependencies?

You may take a look on helm chart dependencies with requirements.yaml
And as an example - Kafka helm chart with zookeeper dependency.

Related

Difference between helm repo add vs helm install

I have delved into the documentations of helm and still it is unclear what is the difference between the two. Here's what I understand so far
helm install -> install a helm chart
helm repo add -> add a repo from the internet
You can see Helm as a templating tool, which reads files from the templates directory, fills them with values from values.yaml, and deploys them into the Kubernetes cluster. These is all done by the helm install command. So, Helm install takes your chart and deploys it into the Kubernetes cluster.
One of the feature of Helm is helm package, which packages your chart into a single *.tgz file and then you can store it in the Helm registry. A lot of Helm charts are stored that way, you can look, e.g., into Artifact Hub. If you find a chart you'd like to install from the Helm registry, you can add that remote repo into your local Helm registry using helm repo add. Then, helm repo update downloads a Helm chart to your local registry. Downloading a repo just downloads the Helm chart into your local registry, but it does not deploy anything into the Kubernetes cluster. To do that, you need to use helm install.

How to Helm upgrade only subchart

I have multiple subcharts under one helm chart. I install those using the command
helm install my-app . --values values.dev.yaml
It is working fine. All subcharts are part of a one release. Now I have requirements that other member will be starting working those individual subcharts and want to upgrade their subchart without deleting/upgrading the entire application's subchats and in the same release
so when for upgrading one one say frontend subchart from it. I tried
helm upgrade my-app ./charts/frontend --values values.dev.yaml.
It will terminate all the other pods and will keep only pod for this subchart frontend running. Is there any way to upgrade only subcharts of the application without touching the other subcharts?
Just run helm upgrade on the top-level chart normally
rm requirements.lock
helm dependency update
helm upgrade my-app . -f values.dev.yaml
This will "redeploy" the entire chart, including all of its subcharts, but Helm knows to not resubmit unchanged objects to Kubernetes, and Kubernetes knows to not take action when an unmodified object is submitted.
Helm subcharts have some limitations; in addition to what you describe here about not being able to separately manage subcharts' versions, they will also flatten recursive dependencies together (if A depends on B depends on Redis, and A depends on C depends on Redis, B and C will share a single Redis installation and could conflict). If you need to separately manage the versions, consider installing the charts as separate top-level releases.
If your sub-charts are 3rd party dependencies (i.e. you are combining some charts together in a single chart), you can update the external charts by updating Helm dependencies:
Once in the Helm chart dir, where Chart.yaml lives, run
$ helm dependency update
To make sure you get the latest dependency, update Helm repos first:
$ helm repo update && helm dependency update
This will download the latest dependent charts (or the latest allowed, depending on your Chart.yaml config.
Please Note that helm dependency update will download txz files. If no action is taken (i.e. ignore them in git), they could end up version-controlled in your git repo.

List helm dependencies of an installed chart

Helm offers the option of listing dependencies for a chart when browsing through its files.
So if I am above the folder of my-chart, I can perform
▶ helm dependency list my-chart
NAME VERSION REPOSITORY STATUS
common 0.12.6 file://../common/ ok
How can I get the dependencies for the INSTALLED chart, i.e. by retrieving this info from the actualy deployed version? (i.e. the one running on my cluster)
No, you can retrieve this information only using documentation you provided. You should:
Download the chart with $ helm pull repo/name --untar (skip this if you already have it)
Go inside the chart directory
Invoke command: $ helm dependency list my-chart
Alternatively you can inspect requirements.yaml for helm2 or Chart.yaml for helm3, but you will find there only transitive dependencies :
All applications, maybe with the exception of the most trivial,
usually depend on other runtime components, such as web servers,
caches, databases, etc. Helm supports modularization via a dependency
mechanism, which allows to formally specify, manage and deploy
dependencies as part of a Helm release. A Helm chart may declare
dependencies, which are other Helm charts published in external
repositories, conveniently packaged by people who presumably know the
respective components well. The simples possible example is a chart A
-- the dependent - that declared its reliance on a chart B - the dependency - by specifying chart B's “coordinates” (name, version and
repository URL) as part of its own metadata. The exact way in which
the dependencies are declared has evolved across Helm releases. For
Helm 2 charts, the dependencies are declared in a dedicated
requirements.yaml file, while for Helm 3 chart, the dependencies are
declared as part of the chart manifest Chart.yaml. However, the way
the dependencies are processed during installation has remained the
same.
Good article: Helm Dependencies

Install PostgreSQL on Kubernetes with Helm 3

I have a few microservices and one of them needs to use postreSQL. I configure this microservice using Helm 3.I have two different values.yaml per environments such as values.stage.yaml and values.prod.yaml.So my confusion is,
Should I independentyl install the PostreSQL? What I mean, in my scr code I have helm chart call helm/app. Should I create one more chart for PostreSQL? How can I configure the PostreSQL per environments.
2.In future, if one more microservice would like to use the same PostreSQL, what should I do to provide this feature.
Your chart should declare postgresql as a dependency, in Helm 3 in its Chart.yaml file. (In Helm 2 there was a separate requirements.yaml file.) You will need to run helm dep up (helm dependency update) before deploying your chart, but then when you run helm install it will install both your application and its database dependency.
So your Chart.yaml can look roughly like
apiVersion: v2
name: app
...
dependencies:
- name: postgresql
version: '^8'
repository: #stable
(In Helm 3 you also need to helm repo add the stable Helm charts repository.)
You can configure the database per environment in the same way you configure the rest of your application. Database settings would be nested under the subchart's name; at the command line you might --set postgresql.postgresqlPassword=..., and in a YAML file you'd put database settings under a postgresql: key.
If you have a second service that needs PostgreSQL, it should declare a dependency in the same way and install its own independent copy of the database. With database installation isolated inside containers this isn't considered particularly heavy-weight. If your two services need to communicate, they should do it via a network (often HTTP) connection and not by sharing a database.
By default, Helm picks values.yaml of root directory of the chart.
To install same Helm Chart with different values, you can do something like,
helm install . -f values.stage.yaml

How to edit the Configurations of a Helm Chart?

Hi everyone,
I have deployed a Kubernetes cluster based on kubeadm and for the purpose of performing HorizontalPodAutoscaling based on the Custom Metrics, I have deployed prometheus-adpater through Helm.
Now, i want to edit the configuration for prometheus-adpater and because i am new to Helm, i don't know how to do this. So could you guid me how to edit the deployed helm charts?
I guess helm upgrade is that are you looking for.
This command upgrades a release to a specified version of a chart and/or updates chart values.
So if you have deployed prometheus-adapter, you can use command helm fetch
Download a chart from a repository and (optionally) unpack it in local directory
You will have all yamls, you can edit them and upgrade your current deployed chart via helm upgrade
I found an example, which should explain it to you more precisely.
You're trying to customize an installed chart. Please use this guide Customizing the Chart Before Installing.
The key parts:
There are two ways to pass configuration data during install:
--values (or -f): Specify a YAML file with overrides. This can be specified multiple times and the rightmost file will take precedence
--set name=value: Specify overrides on the command line
There are a couple more ways to customize a Helm Chart values:
You may create a file with defined config and then helm install my-app [chart] -f /path/to/myconfig.yaml
As an example for a config file, please refer, for example, to redis one.
The second one is to check for the files the helm repo add or helm repo update create. You may check with helm env the variable HELM_REPOSITORY_CACHE that shows where those files are.
Untar the chart and look for the values config file or even go to the Kubernetes manifests /templates for a more in-depth customization. Then, install the chart.