Helm v3 cannot find my charts in private repo - kubernetes

I have a private helm repo using apache, after migrating to helm3 I cannot install/search charts anymore.
Using helm v3
helm repo list
NAME URL
mas http://localhost:8080/charts/
helm search repo mas/devops-openshift
No results found
Using helm 2.*
helm search -r mas/devops-openshift
NAME CHART VERSION APP VERSION DESCRIPTION
mas/devops-openshift 7.0.0 Devops (OpenShift)
Same happens when using "helm install" command, it cannot find the charts.
I guess it could be something related to the helm repo index file. Maybe helmv3 is expecting a different structure? But same happen when generating index file from helmv3.

Thanks all for the answers but I've found the issue.
My repository were using development version of the charts so I had something like this 1.0.0-pre.dev (Semantic Versioning 2.0.0).
By default helm 3 does not look at non production charts.
You have to set the flag -devel. something like:
helm search repo mas/devops-openshift --devel

While migrating from helm 2 to helm 3 remove private repo and add it after migration, then run helm repo update to refresh repository file.
If the chart is available locally, run helm repo index <DIR> --url <your_repo_url> to create new index.yaml for this repository.
Running helm env will show you the directory where the repository.yamlis located so check if the file is generated correctly.

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 tell Helm which repo & chart is going to install?

I'm following Helm's document here to install a package, a.k.a. a helm chart:
$ helm install happy-panda stable/mariadb
It's really convenient to have a ready-to-use package. But in case of a package doesn't belong to stable repo, for example appmesh-grafana then I have to do more than this:
$ helm repo add aws https://aws.github.io/eks-charts
$ helm install aws/appmesh-grafana --version 0.1.0
Therefore, it forces me surf around the internet to find repo url, package name, etc. I don't want to do it every single time!
Is there any way to specify the repo and chart to install using Chart.yaml? I prefer Chart.yaml than shell script.
The short answer is no, if a chart is not in the official repo, then you always need to add the repository first before installing the chart.
However, starting from the Helm 3, you can look for the chart directly in the Helm Hub. In your case, if you wanted to find appmesh-grafana, you can execute the following command.
$ helm search hub appmesh-grafana
URL CHART VERSION APP VERSION DESCRIPTION
https://hub.helm.sh/charts/aws/appmesh-grafana 0.1.0 6.4.3 App Mesh Grafana Helm chart for Kubernetes
But then, yes, you need to open the link, find the address, and anyway execute $ helm repo add aws https://aws.github.io/eks-charts.

K8s: how to install charts from the Helm Hub

Disclaimer: I'm new to Kubernetes and Helm.
I am trying to install a Helm chart using the brand new Helm Hub and for the life of me I can't figure out how this is supposed to work.
A new version of Helm (3.0) was released only a few months ago with significant changes, one of them is that it doesn't come with any repositories configured. Helm released the Helm Hub which is supposed to be a centralized service to find charts.
I am trying to install a CloudBees Jenkins chart. This is what I get when I search the hub:
[me#localhost tmp]$ helm search hub cloudbees -o yaml
- app_version: 2.222.1.1
description: The Continuous Delivery Solution for Enterprises
url: https://hub.helm.sh/charts/cloudbees/cloudbees-core
version: 3.12.0+80c17a044bc4
- app_version: 9.2.0.139827
description: A Helm chart for CloudBees Flow
url: https://hub.helm.sh/charts/cloudbees/cloudbees-flow
version: 1.1.1
- app_version: 9.2.0.139827
description: A Helm chart for CloudBees Flow Agent
url: https://hub.helm.sh/charts/cloudbees/cloudbees-flow-agent
version: 1.1.1
- app_version: 2.204.3.7
description: CloudBees Jenkins Distribution provides development teams with a highly
dependable, secure, Jenkins environment curated from the most recent supported
Jenkins release. The distribution comes with a recommended catalog of tested plugins
available through the CloudBees Assurance Program.
url: https://hub.helm.sh/charts/cloudbees/cloudbees-jenkins-distribution
version: 2.204.307
- app_version: 2.0.2
description: Helm chart for sidecar injector webhook deployment
url: https://hub.helm.sh/charts/cloudbees/cloudbees-sidecar-injector
version: 2.0.2
So it looks like the chart I am looking for is available: cloudbees-jenkins-distribution.
However, I can't find any way to install from the hub or to add a repository based on the hub output. Some of the things I've tried:
[me#localhost tmp]$ helm repo update
Hang tight while we grab the latest from your chart repositories...
...Successfully got an update from the "incubator" chart repository
...Successfully got an update from the "gitlab" chart repository
...Successfully got an update from the "stable" chart repository
Update Complete. ⎈ Happy Helming!⎈
[me#localhost tmp]$ helm install myJenkins cloudbees-jenkins-distribution
Error: failed to download "cloudbees-jenkins-distribution" (hint: running `helm repo update` may help)
[me#localhost tmp]$ helm repo add cbRepo https://hub.helm.sh/charts/cloudbees
Error: looks like "https://hub.helm.sh/charts/cloudbees" is not a valid chart repository or cannot be reached: error converting YAML to JSON: yaml: line 8: mapping values are not allowed in this context
[me#localhost tmp]$ helm repo add cbRepo https://hub.helm.sh/charts/cloudbees/cloudbees-jenkins-distribution
Error: looks like "https://hub.helm.sh/charts/cloudbees/cloudbees-jenkins-distribution" is not a valid chart repository or cannot be reached: error converting YAML to JSON: yaml: line 8: mapping values are not allowed in this context
The documentation really doesn't say much about how I'm supposed to go from the Helm Hub to an installed chart. What am I missing here?
Helm Hub is NOT like a repo that you can add and install from it helm charts. It doesn't expose valid repos urls either. That's why you're getting the error message like below:
Error: looks like "https://hub.helm.sh/charts/cloudbees" is not a valid chart repository ...
when you're trying to run helm repo add on https://hub.helm.sh based urls.
I know it may seem pretty confusing but it just works like that, by its very design. Please refer to this discussion on Github. Specifically this comment explains it a bit more and I hope it also answers your question:
hub.helm.sh is not the helm repo, so it will not work the you trying,
it is only meant to view and search for charts. check in there for
chart repository and it that way, then you will be able to install the
charts.
Unfortunatelly the official helm documentation doesn't explain it well enough. It mentions only:
helm search hub searches the Helm Hub, which comprises helm charts
from dozens of different repositories.
But it shows "no explanation how to get from helm search repo which shows hub.helm.sh to helm repo add which magically shows the a new url to use." - as one user wrote in the thread mentioned above.
Despite that Helm hub doesn't have a convenient way to get a repository url, it has a github repo that contains all vendors repository in one file.
We can use that fact to create a workaround, that you can improve using automation tools like bash,awk, sed, perl, python, etc.
Let's imagine we want to get the helm chart url using helm v3 and command line tools only.
(helm3 is just a symlink for helm v3.1.2)
Let's get the repository name for jenkins distribution for cloudbees vendor
$ helm3 search hub jenkins --max-col-width 1000 | grep cloudbees | tr "\t" "\n"
https://hub.helm.sh/charts/cloudbees/cloudbees-core
3.12.0+80c17a044bc4
2.222.1.1
The Continuous Delivery Solution for Enterprises
https://hub.helm.sh/charts/cloudbees/cloudbees-jenkins-distribution
2.204.307
2.204.3.7
CloudBees Jenkins Distribution provides development teams with a highly dependable, secure, Jenkins environment curated from the most recent supported Jenkins
release. The distribution comes with a recommended catalog of tested plugins available through the CloudBees Assurance Program.
As we can see the chart page on Helm hub is
# https://hub.helm.sh/charts/cloudbees/cloudbees-jenkins-distribution
# ^^^^^^^^^
so we can assume that repository name is also cloudbees
Let's find the url for cloudbees helm repository
$ curl -s https://raw.githubusercontent.com/helm/hub/master/config/repo-values.yaml | grep cloudbees
- name: cloudbees
url: https://charts.cloudbees.com/public/cloudbees
Now we can add this repository using helm repo command:
$ helm3 repo add cloudbees https://charts.cloudbees.com/public/cloudbees
"cloudbees" has been added to your repositories
Don't forget to update:
$ helm3 repo update
Hang tight while we grab the latest from your chart repositories...
...Successfully got an update from the "cloudbees" chart repository
Update Complete. ⎈ Happy Helming!⎈
To find the chart name let's repeat search in repo
$ helm3 search repo jenkins
NAME CHART VERSION APP VERSION DESCRIPTION
cloudbees/cloudbees-jenkins-distribution 2.204.307 2.204.3.7 CloudBees Jenkins Distribution provides develop...
cloudbees/cloudbees-core 3.12.0+80c17a044bc4 2.222.1.1 The Continuous Delivery Solution for Enterprises
And finally we can install the chart:
$ helm3 install cloudbees/cloudbees-jenkins-distribution --version 2.204.307
Happy Helming3 ! :)
True, helm search hub cloudbees does not return the url of the repo.
What you can do from the result of helm search hub cloudbees is helm install $urlFromBefore:
$ helm search hub cloudbees
- app_version: 2.222.1.1
description: The Continuous Delivery Solution for Enterprises
url: https://hub.helm.sh/charts/cloudbees/cloudbees-core
...
$ helm install cloudbees https://hub.helm.sh/charts/cloudbees/cloudbees-core
from helm/helm#7419
To get the repo url, you can do the search on https://hub.helm.sh or
do a work around when you want the repo url from console:
$ curl https://hub.helm.sh/api/chartsvc/v1/charts/search?q=rancher | json_pp
The repo url is in key url in repo (data[...].attributes.repo.url).
(json_pp is optional. It pretty prints json, which helps me to read it.)
Now continue with
# variables names show the place in json output from above
helm repo add $data_attributes_repo_name $data_attributes_repo_url
helm repo update
helm install $data_attributes_repo_name/$data_attributes_name

How to add helm repo from an existing github project?

I have an existing github project. I want to create/add a helm folder to the project to store the helm yaml files. I want to reference this github project/folder to act like a helm repo in my local/dev environment. I know I can add the charts to my local/default helm repo. The use case is if another developer checks out the code in github and he needs to work on the charts then he can run helm install directly from the working folder. The helm.sh website has instructions of adding a gh-pages branch but I am wondering if I can avoid it.
Can I use an existing github project and it via the helm repo add command?
Unfortunately, I wasn't able to find a way to publish helm charts via GitHub using private repositories. On a theoretical level, it might work using GitHub token and 2nd (raw URLs method), but I haven't tried it. Since you're using docker registry anyway, it might be worth trying using OCI (docker) registry to store the charts.
If that doesn't work, or you have public repos, it is possible to either use GitHub Pages, or use GitHub raw URLs. Both of the solutions require public repository.
To use GitHub pages:
Setup github pages to publish docs folder as github pages (you can use a different name, just substitue later)
Package the helm repo as .tgz (using helm package): helm package charts/mychart -d docs/. Substitute charts/mychart with a path to a chart root folder
Include an index.yaml -- an index file for the repository helm repo index ./docs --url https://<YOUR_ORG_OR_USERNAME>.github.io/<REPO_NAME>
Now you can add the repo: helm repo add <INTERNAL_NAME> https://<YOUR_ORG_OR_USERNAME>.github.io/<REPO_NAME>
To use Raw URLs:
Place index.yaml and chart TGZs into a folder called docs, just like above
Now you can add a repo: helm repo add <INTERNAL_NAME> https://raw.githubusercontent.com/<YOUR_ORG_OR_USERNAME>/<REPO_NAME>/<BRANCH_USUALLY_MASTER>/docs
Firstly make sure that you have have fully functional helm repository. The tricky part is to access it as if it was simple HTTP server hosting raw files. Fortunately Github provides such feature using raw.githubusercontent.com. In order for helm to be able to pull files from such repository you need to provide it with Github username and token (Personal Access Token):
> helm repo add - username <your_github_username> - password <your_github_token> my-github-helm-repo 'https://raw.githubusercontent.com/my_organization/my-github-helm-repo/master/'
> helm repo update
> helm repo list
NAME URL
stable https://kubernetes-charts.storage.googleapis.com
local http://127.0.0.1:8879/charts
my-github-helmrepo https://raw.githubusercontent.com/my_organization/my-github-helm-repo/master/
> helm search my-app
NAME CHART VERSION APP VERSION DESCRIPTION
my-github-helmrepo/my-app-chart 0.1.0 1.0 A Helm chart for Kubernetes
These are steps for adding new packages to existing repository
If you want to add new package to existing repository simply:
1. Place new package in your local repository root
2. Execute: helm repo index .. This will detect new file/folder and make updates.
3. Commit and push your new package
4. Finally execute command: helm repo update
Security ascpect
It is important to realize where does helm actually store your Github token. It is stored as plain text in ~/.helm/repository/repositories.yaml. In this case it will be good to generate token with as few permissions as possible.
Take a look here: hosting helm private repository.

Helm export YAML files locally (just use templating engine, do not send to Kubernetes)

I want to export already templated Helm Charts as YAML files. I can not use Tiller on my Kubernetes Cluster at the moment, but still want to make use of Helm Charts. Basically, I want Helm to export the YAML that gets send to the Kubernetes API with values that have been templated by Helm. After that, I will upload the YAML files to my Kubernetes cluster.
I tried to run .\helm.exe install --debug --dry-run incubator\kafka but I get the error Error: Unauthorized.
Note that I run Helm on Windows (version helm-v2.9.1-windows-amd64).
We need logs to check the Unauthorized issue.
But you can easily generate templates locally:
helm template mychart
Render chart templates locally and display the output.
This does not require Tiller. However, any values that would normally
be looked up or retrieved in-cluster will be faked locally.
Additionally, none of the server-side testing of chart validity (e.g.
whether an API is supported) is done.
More info: https://helm.sh/docs/helm/helm_template/
Amrit Bera's solution will only work with local helm chart, per the details of your question you want it to work with remote helm chart, that's a feature that will be added to Helm v3 (Work in Progress currently).
RehanSaeed posted the following workaround (https://github.com/helm/helm/issues/4527)
Basically:
mkdir yamls
helm fetch --untar --untardir . 'stable/redis' #makes a directory called redis
helm template --output-dir './yamls' './redis' #redis dir (local helm chart), export to yamls dir
The good thing about this is you can mix this technique with weaveworks flux for git ops + this gives you another option for using Helm v2 without tiller, in addition to the Tiller Plugin (which lets you run tiller locally, but doesn't work smoothly).
Straight from the helm install --help
To check the generated manifests of a release without installing the chart,
the '--debug' and '--dry-run' flags can be combined. This will still require a
round-trip to the Tiller server.
If you want to see only the resolved YAML you can use
helm template .
I prefer to see it on a file
helm template . > solved.yaml
This is not the answer for the question but this post on stackoverflow
is the first one which was displayed in searchengines when i was
searching for a solution of my problem and solved it by myself reading
the Helm CLI docs. I post it here anyway because maybe someone else is
searching for the same usecase as i did.
For already installed Helm charts on a Kubernetes cluster you can use the following command to export/download all information for a named release:
helm get all <release-name>
or
helm get all <release-name> > installed-kubernetes-resources.yaml
If you only want e.g. the manifests or values instead of all, just replace the all command appropriately (get more details by using helm get --help):
Usage:
helm get [command]
Available Commands:
all download all information for a named release
hooks download all hooks for a named release
manifest download the manifest for a named release
notes download the notes for a named release
values download the values file for a named release
If you want to export the information for a named release with a distinct revision you can use the flag --revision int in your get command (helm get all --help). To list all possible revisions of your named release just use the command helm history <release-name>.
My Helm CLI version:
version.BuildInfo{Version:"v3.5.0", GitCommit:"32c22239423b3b4ba6706d450bd044baffdcf9e6", GitTreeState:"clean", GoVersion:"go1.15.6"}