Add Chart To Repository


Add Chart To Repository

In this tutorial, we are going to discuss about how to add chart to ChartMuseum repository. We already discussed about how to host our own repository using ChartMuseum, using the local storage and add repository by pointing to the URL.

Once the repository is ready, I will be in a position to add charts into it.

Start ChartMuseum

Let’s go ahead and start the ChartMuseum. I’m going to start the chart museum in the port 8080.

I’m mentioning the storage as local and the directory where it is going to store the information is within a directory called chartstorage.

[email protected]:~$ chartmuseum --debug --port=8080 --storage="local" --storage-local-rootdir="./chartstorage"
2021-05-21T01:09:44.400Z    DEBUG   Fetching chart list from storage    {"repo": ""}
2021-05-21T01:09:44.400Z    DEBUG   No change detected between cache and storage    {"repo": ""}
2021-05-21T01:09:44.400Z    INFO    Starting ChartMuseum    {"port": 8080}

So this will start listening in port 8080. It will create the required directory if it doesn’t exist and get things done.

Now I’m going to add this particular repository as a part of my repolist that I have. So in a quick summary if I have to refresh what we are going to do I am going to create charts and add that particular chart or push that particular chart into the repository.

Add Chart To Repository

The process of adding and pushing we do that using index. Now, I’m going to add this particular repo by pointing to this particular repository. So I’m going to create a repository called mychartmuseumrepo and point to this specific url and the port. (Already we did this in previous tutorial).

SO the repo will get added. Now I can go ahead and list whether it is available as a part of the list helm repo list.

[email protected]:~$ helm repo list
NAME                    URL                          
stable                  https://charts.helm.sh/stable
mychartmuseumrepo       http://192.168.1.50:8080

Yes, it is available.

Example demo

Now I’m going to create a new chart and add it as a part of this particular repository. There are multiple ways I can package it or I can directly mention the chart directory and use push plugin.

So I’m introducing a new terminology plugin as a part of helm, I can have multiple plugins. We will have a separate discussion, but I’ll quickly demonstrate how to install the plugin and add it. First let us see the easiest option.

Let me create a directory. Let me get into the directory. Within this, I’m going to create a chart.

[email protected]:~$ mkdir helm_repo_demo

[email protected]:~$ cd helm_repo_demo/

[email protected]:~/helm_repo_demo$ helm create repotest
Creating repotest

[email protected]:~/helm_repo_demo$ ls
repotest

And within repotest, it’s going to have sample charts and the configuration about chart.yaml, values.yaml and as a part of templates I will be having some sample templates. Let me not worry about these templates.

This is a nginx deployment. Now I’m going to modify the chart.yaml. This is a nginx deployment. Now I’m going to modify the chart.yaml. Let me update the description.

[email protected]:~/helm_repo_demo/repotest$ cat Chart.yaml 
apiVersion: v2
name: repotest
description: Repo demo in helm using ChartMuseum
# A chart can be either an 'application' or a 'library' chart.
................
................
................
................

The content within the chart.yaml will be used by the ChartMuseum to maintain what version it is and what is the description and other information’s.

Now, I’m going to use this specific directory and package the charts within it and push it into the repository. Let me go ahead and create a package out of this repotest, for that I will be using the command package

[email protected]:~/helm_repo_demo$ helm package repotest
Successfully packaged chart and saved it to: /home/ashok/helm_repo_demo/repotest-0.1.0.tgz

It’s nothing but it’s going to create a zipped content that is a tar file and it’s going to append the version that we had mentioned as a part of charts.yaml file.

Now, I can add this particular chart as a part of the repository using curl or using push command. Now I’m going to use the curl command, curl and I’m going to pass the data as binary and what file I’m going to pass, that is repotest-0.1.0 the same file that are available in this particular directory and the location where the Chart Museum repository is running port/api/charts.

[email protected]:~/helm_repo_demo$ curl --data-binary "@repotest-0.1.0.tgz" http://192.168.1.50:8080/api/charts
{"saved":true}

So it’s going to give the response back saved as true.

Check charts in ChartMuseum repository

Now I can get into that server location. And see the chart storage.

[email protected]:~/chartstorage$ ls
repotest-0.1.0.tgz

So the repotest-0.1.0.tgz that we had added that would have got added into that particular storage repository.

So the repository is nothing but it’s just like a web server hosting the zipped content of the charts and an index.yaml file.

The index.yaml file will get generated automatically when we are doing the update.

Update Repo

Now I’m going to update all the repositories. So what it will do? It’s going to connect all the repositories and check is there any new chart If it is available, it is going to pull the new version of the chart and keep it within itself.

So this is how things happens. So I’m going to have n number of charts created add it as a part of the repository. And in any machine I can go ahead and do add the repo. So if I add the repo when I am doing the list of repo, it’s going to list what is the name of the repo and in what server it is pointing it to. So in this case, it’s pointing to 192.168.1.50 server running in the port 8080.

If I had added one chart to repository, that particular chart will get refreshed into this particular list when I’m doing the update. This is very similar to the APT update or yum update that we do as a part of the operating system.

So before doing the update let me go ahead and search what are all the charts available locally in this particular repository.

[email protected]:~$ helm search repo mychartmuseumrepo
No results found

There are nothing found. Now, let me go ahead and do the update.

[email protected]:~/helm_repo_demo$ helm repo update
Hang tight while we grab the latest from your chart repositories…
…Successfully got an update from the "mychartmuseumrepo" chart repository
…Successfully got an update from the "stable" chart repository
Update Complete. ⎈Happy Helming!⎈

So it’s going to connect to the server and check Is there any new charts available and if it is available, it is going to refresh itself and get the new charts.

Now, let me go ahead and search the repo as a part of the repository that we have mapped.

[email protected]:~/helm_repo_demo$ helm search repo mychartmuseumrepo
NAME                            CHART VERSION   APP VERSION     DESCRIPTION                        
mychartmuseumrepo/repotest      0.1.0           1.16.0          Repo demo in helm using ChartMuseum

And I do have the chart name, the description that we had added it is available.

Add Chart To Repository


Scroll to top