Getting Started With ChartMuseusm

1.Chart Repositories:

  • An HTTP server hosting index.yaml file along with chart packages. - Indented item
  • When charts are ready, can be uploaded to server and shared.
  • Multiple charts with dependency and version can be managed
  • Can be managed like source control system in a common location.
  • Can be hosted as part of:
    1. Google compute cloud bucket
    2. AWS S3 bucket
    3. Github pages
    4. Own webserver (chartmuseum)

2.Why ChartMuseum ?

  • Easily distribute your charts across different deployment pipelines or repositories.
  • It exposes API’s for chart manipulation.
  • Reduces maintenance as you can share charts or templates easily.
  • Requires almost no effort to set up over kubernetes.
  • Supports backend for multiple clouds e.g. AWS S3.

This Article will focus on local file system storage. To deploy it over cloud follow this link.

3.Chartmuseum Installation:

Please refer installation guide for your OS.

First we need to set up ChartMuseum and upload our chart to it. Let’s follow the steps below for setting it up.

  • Download the binary by using the link below or you can always download a specific release from their github
  • Make the binary executable by running chmod +x chartmuseum
  • Move the binary to your bin location
  • Verify that it is installed by running chartmuseum –version
curl -LO https://s3.amazonaws.com/chartmuseum/release/latest/bin/linux/amd64/chartmuseum
chmod +x ./chartmuseum
mv ./chartmuseum /usr/local/bin
chartmuseum --version
chartmuseum --help

Now that ChartMuseum is installed, we will configure a local storage backend for it.

  • Replace chart-dir and port in the following command and run it on a terminal
  • ChartMuseum will use chart-dir for its storage
chartmuseum --port=<port> --storage="local" --storage-local-rootdir="<chart-dir>"

Example:
  chartmuseum --debug --port=8080 --storage="local" --storage-local-rootdir="./chartstorage"
  • You will see ChartMuseum showing that it is starting on the specified port

4.Configuring ChartMuseum with Helm

In order for helm to fetch and install charts from ChartMuseum, you will first need to add ChartMuseum to helm as a repository. You can do that by following the steps below

  • Run helm repo add mychartmuseum http://localhost:8080
  • Here mychartmuseum will act as a repository name and http://localhost:8080 will be the url where chartmuseum is running
  • Now you can run helm repo update and it will fetch chart metadata from ChartMuseum as well
helm repo list
helm repo add mychartmuseum http://localhost:8080
helm repo list
helm search repo nginx
helm search repo mychartmuseum
helm search repo stable

5.Uploading your custom chart to ChartMuseum

Now that ChartMuseum is up and running on your specified port, let’s move on to uploading your custom chart. For our demo we’ll be using a custom nginx chart located here. If you want to follow along, simply clone the repository above and open up a terminal in that directory. The demo chart contains a directory named devopsmonk-webapp, inside which is its chart. Let’s follow the steps below to upload the chart to ChartMuseum.

  • Navigate to the cloned repository and go to devopsmonk-webapp directory
  • Run helm lint to verify that the chart has no compile time errors
  • Run helm package devopsmonk-webapp/ to package the chart into a file. The packaged name of the chart will be helm-webapp-0.1.0.tgz, where helm-webapp is the name of the chart and 0.1.0 is the chart version
  • Once we have the packaged chart, we can upload it to ChartMuseum by sending a post request via curl to CM (assuming CM is running on port 8080).
git clone https://github.com/devops-monk/helm-nginx-nodeport-chart.git
helm lint devopsmonk-webapp
helm package devopsmonk-webapp/
curl --data-binary "@helm-webapp-0.1.0.tgz" http://localhost:8080/api/charts
helm repo list
helm search repo mychartmuseum
helm repo update
helm search repo mychartmuseum

6.Maintain chart Version

Update the minor version in Chart.yaml file to “0.2.0” and upload chart to museum.

cd devopsmonk-webapp
sudo vi Chart.yaml
helm lint
cd ..
helm package devopsmonk-webapp/
curl --data-binary "@helm-webapp-0.2.0.tgz" http://localhost:8080/api/charts
helm repo update
helm search repo mychartmuseum
helm search repo -l mychartmuseum

7.Installing your Custom Chart

At this point you’ve accomplished the following things:

  • Install and Configure ChartMuseum
  • Add ChartMuseum as a Repository in Helm
  • Upload your custom chart to ChartMuseum

Now all you have to do is to install the custom chart via Helm. For that follow the steps below

  • Install your chart by running helm install demo-nginx mychartmuseum/helm-webapp and that’s it.
helm ls
helm install demo-nginx mychartmuseum/helm-webapp

You’ve successfully installed your custom chart on your kubernetes cluster. You just have to upload all your custom charts to ChartMuseum now and install them via helm.