does helm have feature of print? - kubernetes

As we knew, helm charts are made by templates with variables and reference values from values.yml. I'd like to review the final heml chart, but there is no print or output feature.
For example, in serverless framework, I can run sls print to get the final serverless.yml
But I can't find the similar command in heml, such as
helm print <chart_name> -f values.yml

Make use of --debug and --dry-run option.
helm install ./mychart --debug --dry-run
Quoting statement from this official doc.
When you want to test the template rendering, but not actually install
anything, you can use helm install ./mychart --debug --dry-run. This
will send the chart to the Tiller server, which will render the
templates. But instead of installing the chart, it will return the
rendered template to you so you can see the output.
There is another way to do this without need of connection to tiller.
helm template ./mychart
Hope this helps.
Update:
Printing rendered contents of one of the stable chart (in my case airflow stable chart) would look like:
Using --debug and --dry-run option
helm install --namespace "airflow" --name "airflow" stable/airflow --debug --dry-run -f values.yaml
Using helm template
helm fetch stable/airflow
tar -xvf airflow-4.0.8.tgz
helm template --namespace "airflow" --name "airflow" ./airflow -f airflow/values.yaml

updates
Somehow, directly run helm template ./mychart doesn't work any more with below error.
For example,
$ git clone git#github.com:helm/charts.git
$ cd charts/stable/datadog
$ helm template .
Error: found in Chart.yaml, but missing in charts/ directory: kube-state-metrics
There are two new files in this folders
requirements.yaml
requirements.lock
they both mentioned a repository called https://kubernetes-charts.storage.googleapis.com/
So we need add it in helm
helm repo add common https://kubernetes-charts-incubator.storage.googleapis.com/
helm dependency update
helm template .
Now everything works as normal.
For your reference, my current helm version is v3.2.1.

Related

Helm looks in a different repository then the one I specify with a --repo flag

If I perform the following command it looks in "https://github.com/grafana/" instead of the one I specified - "https://grafana.github.io/helm-charts"
Here is what I run and the results:
helm3 upgrade --install grafana grafana --dry-run --repo https://grafana.github.io/helm-charts --wait
Release "grafana" does not exist. Installing it now.
Error: failed to download "https://github.com/grafana/helm-charts/releases/download/grafana-6.16.14/grafana-6.16.14.tgz"
Why is it looking in "github.com/grafana" instead of where I told it to look with the repo flag - "grafana.github.io"?
My co worker runs the same command and it works.
I list the repositories and grafana is not there so I would assume that would force this to work?
helm3 repo list
NAME URL
stable https://charts.helm.sh/stable
local http://127.0.0.1:8879/charts
eks https://aws.github.io/eks-charts
bitnami https://charts.bitnami.com/bitnami
cluster-autoscaler https://kubernetes.github.io/autoscaler
kube-dns-autoscaler https://kubernetes-sigs.github.io/cluster-proportional-autoscaler
cluster-proportional-autoscaler https://kubernetes-sigs.github.io/cluster-proportional-autoscaler
external-dns https://charts.bitnami.com/bitnami
kube2iam https://jtblin.github.io/kube2iam/
kubernetes-dashboard https://kubernetes.github.io/dashboard/
incubator https://charts.helm.sh/incubator
My coworker has the same repo list output as above.
The below commands will work in my system however I want to know why for me it will not work when I use the --repo flag as in the above example (all of our code has that flag in it and they do not want to change it) :
helm3 repo add grafana https://grafana.github.io/helm-charts
"grafana" has been added to your repositories
kconfig_et helm3 upgrade --install grafana grafana/grafana --dry-run --wait
I executed your Helm command but with --debug flag to get this error:
helm upgrade --install grafana grafana --dry-run --repo https://grafana.github.io/helm-charts --wait --debug
history.go:56: [debug] getting history for release grafana
Release "grafana" does not exist. Installing it now.
install.go:178: [debug] Original chart version: ""
Error: no cached repo found. (try 'helm repo update')
Then I simply executed helm repo update as suggested. I then retried the same helm upgrade command and it successfully installed the chart.
You coworker did not encounter the error because at some point he/she has executed helm repo update at least once. (Mine was a freshly installed Helm)
I solved it - I added "--debug" to the command and saw this -
Error: no cached repo found. (try 'helm repo update'): open /Users/mysystem/Library/Caches/helm/repository/local-index.yaml: no such file or directory
I next copied the one in .helm over to the location in the debug message -
cp ~/.helm/repository/local/index.yaml /Users/mysystem/Library/Caches/helm/repository/local-index.yaml
All worked after this!

How to set customized release name in helmchart

After creating package in Helm , I am facing difficulty in setting customized chart name I tried below commands
> helm install --name example ./mychart --set service.type=NodePort
> helm install happy-panda stable/mariadb
Also, tried commands from helm man page
> helm install -help
> --name-template string specify template used to name the release
Before setting your custom release name you've to check your Helm version . Above commands mentioned in question didn't worked in below Helm version
root#docker-slave:/home/mec/src/vmmanager/docker/vmmanager_chart# helm version
Client: &version.Version{SemVer:"v2.9.1", GitCommit:"20adb27c7c5868466912eebdf6664e7390ebe710", GitTreeState:"clean"}
Server: &version.Version{SemVer:"v2.9.1", GitCommit:"20adb27c7c5868466912eebdf6664e7390ebe710", GitTreeState:"clean"}
For Helm 2 version.
helm install --name your_customized_name chart_name
Like , helm install --name vmchart vmmanager_chart
For Helm 3 version,
helm install [--namespace ] # Per-default you need
to provide a release name
For detailed description you can refer below link.
https://lzone.de/cheat-sheet/Helm

helm install "unknown flag: --output"

helm install myChart-0.0.1.tgz --output json results in Error: unknown flag: --output
I use helm version v2.14.3. According to the docs https://helm.sh/docs/helm/#helm-install this should work. Other flags seem to work fine. E.g. helm install myChart-0.0.1.tgz --namespace test-ns --set random.variable="debug" --name mychart
The documentation also states the schema helm install [CHART] [flags],
while its examples suggest the schema helm install [flags] [CHART] in my tests both seem to work but non accepts the output flag.
The output flag was added with commit a52d6de9e17fc4dda4928f0029362e9be075aa24 which is only present in the release-2.15 branch. The documentation is generated from master, so it already has the option, but your version does not yet.
Your current version doesn't support the --output flag, to use it upgrade your helm version to v2.15.0.
From: V2.15.0 Changelog
Introduced --output to helm repo list, helm search, and helm install

Helm install unknown flag --name

When I try to install a chart with helm:
helm install stable/nginx-ingress --name my-nginx
I get the error:
Error: unknown flag: --name
But I see the above command format in many documentations.
Version:
version.BuildInfo{Version:"v3.0.0-beta.3",
GitCommit:"5cb923eecbe80d1ad76399aee234717c11931d9a",
GitTreeState:"clean", GoVersion:"go1.12.9"}
Platform: Windows 10 64
What could be the reason?
In Helm v3, the release name is now mandatory as part of the commmand, see helm install --help:
Usage:
helm install [NAME] [CHART] [flags]
Your command should be:
helm install my-nginx stable/nginx-ingress
Furthermore, Helm will not auto-generate names for releases anymore. If you want the "old behavior", you can use the --generate-name flag. e.g:
helm install --generate-name stable/nginx-ingress
The v3 docs are available at https://v3.helm.sh/docs/, but as it is a beta version, the docs will not be accurate for a while. It's better to rely on the CLI --help, that is auto-generated by Go/Cobra.
The --name flag is no more in version 3.
It should be
helm install my-nginx stable/nginx-ingress
Syntax:
help install [name] [chart]
I don't think the helm3 does support "--name" argument. As per the helm3 doc, the command to install a package and expected output is given down below:
$ helm install happy-panda bitnami/wordpress
NAME: happy-panda
LAST DEPLOYED: Tue Jan 26 10:27:17 2021
NAMESPACE: default
STATUS: deployed
REVISION: 1
NOTES:
** Please be patient while the chart is being deployed **
Here "happy-panda" is the name of the release and "bitnami/wordpress" is the name of the chart. Also you can generate name for the release by using
--generate-name flag.
As others have mentioned, there is no --name flag in version 3 of Helm. Also, Helm v3 comes without stable repository setup by default. The best way to discover a chart by searching the Artifact Hub. Once you find the repo, which hosts the chart you are looking for, you need to add the repo as:
helm repo add nginx-stable https://helm.nginx.com/stable
And then you can install chart
helm install my-nginx nginx-stable/nginx-ingress
As name was made compulsory in helm3,
if we do helm repo --help,
help install [name] [chart]
If the chart was not present,
use helm repo add <name> <url>
then use helm install

Helm Cannot Read Chart.yaml

I am trying to deploy Apache Nifi on Kubernetes using helm but when I execute this command:
helm install --name test-nifi --namespace nifi ./apache-nifi-helm
I immediately get an error saying:
Error: cannot read Chart.Yaml in directory "/home/mydir/test/apache-nifi"
And I have checked the directory and it certainly contains the Chart.Yaml file. I have cloned it from a GitHub Repo.
Am I making a mistake somewhere? Any help is greatly appreciated.
You can
Clone repo:
$ git clone git#github.com:markap14/apache-nifi-helm.git
Run helm:
$ helm install --name test-nifi --namespace ${YOU_NAMESPACE} ./apache-nifi-helm/charts/zookeeper-0.4.2.tgz --tiller-namespace ${YOU_NAMESPACE}
I've also been getting the
"cannot read Chart.Yaml in directory XYZ" error
from helm install in spite of the presence of a Chart.yaml file in the directory.
In the end it was other configuration problems (I had template in the 'charts' folder).
Hooray for the friendly error message!