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.
Related
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
I have all our applications in Kubernetes Helm charts using:
# values.yaml
default:
IMAGE_REPO: myorg
IMAGE_NAME: api
IMAGE_TAG: latest
I understand that in order for Helm to know it has to re-deploy the pods (i.e. pull down the latest image) I have to change the the IMAGE_TAG. My question is how is this managed? Do I manually update the values.yaml file every deploy, git commit, git pull on the master, and then run helm upgrade api --values values.yaml ./?
Or is it better to just leave values.yaml on latest and update via the command line directly like:
helm upgrade api --values values.yaml ./ --set IMAGE_TAG=ab31f452
Use git (99% of the time)
For a production deployment or anywhere that needs tracking I would want it in git and pushed from there. The helm chart will also evolve over time with your app so this also means you get checkpoints of working app versions with the helm chart.
For development or snapshot environments that don't need to be reproduced, I sometimes might go with the less formal method of helm pushing out new image tags as needed. More so if you have something like Jenkins or any job runner that tracks when and how things happen.
This is very dependent on the environment the app runs in. It can range from applications that require an audit trail all the way from a dev, through testing to production deployment where it has to be in git, over to the other end of the spectrum of throw stuff at production by hand (where you end up wanting it in git).
I understand that in order for Helm to know it has to re-deploy the pods (i.e. pull down the latest image) I have to change the the IMAGE_TAG
This isn't entirely correct, kubernetes will reschedule pods when the resource spec changes. You could change an annotation or label on the pod spec and pods would be replaced. Then imagePullPolicy: Always can be set in the pod spec.
Still, don't use that to rely on :latest. It will bite you one day.
The recommended image tag for production environment is immutable tags. So that we can easily get to know which version is running on the k8s cluster. Also you have to run the command like this because the image tag is nested vales.
helm upgrade api --values values.yaml ./ --set **default.IMAGE_TAG**=ab31f452
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
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.
I have a helm chart i need to package using the command helm package https://helm.sh/docs/helm/#helm-package but issue is i need to replace values.yaml file with extra config file depending on what environment
normally i reference this extra config file with
for QA
helm install -f myvalues-qa.yaml -f override-qa.yaml --set foo=bar-qa --set foo=newbar-qa ./redis
for PROD
helm install -f myvalues-prod.yaml -f override-prod.yaml --set foo=bar-prod --set foo=newbar-prod ./redis
but now since i want to package this redis helm charts, how do i package it so that i can switch which config files or extra vars depending the environment?
Here is what i tried
helm package -f myvalues-qa.yaml ./redis
Error: unknown shorthand flag: 'f' in -f .
What is best way to approach this?
When packaging a Helm chart it isn't possible to customize values. That's because of a helm chart is a generic definition of an app, reusable for one environment to another, which is customized at installing via values.
Apart from that, I understand that you need a way to store the definition of a release (including the helm chart and the values) for every specific environment. There are plenty of tools that let you define a release in a declarative way, here are some:
Helmfile
Landscaper
Reckoner
So, you have a packaged chart where you store the generic app and another file(s) where you store the definitions of the releases of this chart.