Add Chart To Repository
In this tutorial, we are going to discuss how to add a chart to the ChartMuseum repository. We already discussed how to host our repository using ChartMuseum, local storage, and add the repository by pointing to the URL. Once the repository is ready, I will be in a position to add charts to it.
Start ChartMuseum
Let’s go ahead and start the ChartMuseum. I’m going to start the chart museum in port 8080.
I’m mentioning the storage as local, and the directory where it will store the information is within a directory called chartstorage.
ashok@cluster-node:~$ 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 will create charts and add that particular chart or push that particular chart into the 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 specific repository. So I will create a repository called mychartmuseumrepo and point to this particular URL and the port. (Already, we did this in the previous tutorial).
So the repo will get added. Now I can list whether it is available as a part of the list helm repo list.
ashok@waytoeasylearn:~$ 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 the push plugin.
So I’m introducing a new terminology plugin as a part of the 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 make a chart.
ashok@waytoeasylearn:~$ mkdir helm_repo_demo
ashok@waytoeasylearn:~$ cd helm_repo_demo/
ashok@waytoeasylearn:~/helm_repo_demo$ helm create repotest
Creating repotest
ashok@waytoeasylearn:~/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 have some sample templates. Let me not worry about these templates.
This is a Nginx deployment. Now I’m going to modify the chart.yaml. Let me update the description.
ashok@waytoeasylearn:~/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 chart.yaml will be used by the ChartMuseum to maintain what version it is and what is the description and other information.
Now, I will use this specific directory, 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.
ashok@waytoeasylearn:~/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 push command. Now I’m going to use the curl command, curl, and I’m going to pass the data as binary. What file I’m going to pass, repotest-0.1.0, the same file available in this directory, and the location where the Chart Museum repository is running port/api/charts.
ashok@waytoeasylearn:~/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.
ashok@cluster-node:~/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 will it do? It’s going to connect all the repositories and check there is any new chart. If it is available, it will pull the latest version of the chart and keep it within itself.
So this is how things happen. So I will have n number of charts created to 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 repo list, it will list the name of the repo and in what server it is pointing it. So, in this case, it’s pointing to the 192.168.1.50 server running in port 8080.
Suppose I had added one chart to the repository; that particular chart will get refreshed into this specific 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 all the charts available locally in this particular repository.
ashok@waytoeasylearn:~$ helm search repo mychartmuseumrepo
No results found
There is nothing found. Now, let me go ahead and do the update.
ashok@hydlpt340:~/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 If there are any new charts available, and if it is available, it will refresh itself and get the latest charts.
Now, let me go ahead and search the repo as a part of the repository that we have mapped.
ashok@hydlpt340:~/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.