Home

Awesome

Plugin to use github/gitlab/bitbucket as helm repo

This plugin makes it possible to use a private/public repository on github/gitlab/bitbucket as a helm repository also. You can keep the charts beside your code in the same repository.

Why this plugin

Using git repo itself as the helm repo is better in my opinion because

Helm allows adding http and https repositories. So public repositories are not a problem. But it does not have any authentication/authorisation feature for adding/accessing the charts in the repository yet. Adding a private repo is not straight forward. You have to create private access token (github/gitlab) and embed directly in the URI of the repo. Example: https://gitlab.com/username/repo/raw/master/kubernetes/helm-chart?private_token=2xMusKyEgA7BRw5TaJYA. The problems with this approach are:

You will have to make these compromises without this plugin. If you are able to, then there is no need of using the plugin otherwise this plugin solves these problems.

Creating the helm repository

Lets say that this is structure of your repository

.
├── Dockerfile
├── README.md
├── kubernetes
│   └── helm-chart
│       └── myapplication
│           ├── Chart.yaml
│           ├── templates
│           │   ├── NOTES.txt
│           │   ├── _helpers.tpl
│           │   ├── deployment.yaml
│           │   └── service.yaml
│           └── values.yaml
├── src
└── tests

Run the following commands to create repo index

cd ./kubernetes/helm-chart
helm package myapplication # generates myapplication.tgz
helm repo index --url=gitlab://username/project:master/kubernetes/helm-chart . # generates index.yaml

Notice the url flag for helm repo index command. This is key for this plugin to work. The structure of the URI should be provider://username/repository-name:branch/dir-containing-index.yaml

Commit the files generated by the helm commands and push to the repo. Now the repository is setup.

The provider in the url can be

Here are some examples of URI

Adding the helm repository

Before using the plugin, you need to setup your machine to access your private/public git repository without manual username-password input. Best is to setup ssh keys in github/gitlab

On same or another computer which has the above requirement fulfilled, install the plugin

helm plugin install https://github.com/diwakar-s-maurya/helm-git

Now add the repo,

helm repo add myhelmrepo gitlab://username/project:master/kubernetes/helm-chart
helm repo list

Now that you have added the repository, start using it as any other regular repository.

helm install myhelmrepo/myapplication