DEV Community

ashvin
ashvin

Posted on

Using Helm Charts with Configurator - A versioning & sync service for Kubernetes ConfigMaps

Alt Text

Configurator

Configurator is an opensource project that version controls and keeps Kubernetes ConfigMaps and Secrets in sync with the deployments. Configurator uses CRDs to create CustomConfigMaps and CustomSecrets that in turn creates ConfigMaps and Secrets with a postfix. As and when a change is detected in a CustomConfigMap or a CustomSecret, Configurator automatically generates a new ConfigMap with a new postfix. This acts as a version controlling system for ConfigMaps. A change in a ConfigMap not only creates a new ConfigMap version but also rolls out a new deployment version across all the deployments using the ConfigMap. This enables both rolling update and rollback of ConfigMaps in sync with the deployment versions.

This blog will focus on the following motives:

  1. Installing Configurator using the helm chart.
  2. Customizing Configurator helm chart based on requirements.
  3. Contributing back to the Configurator project.

System Requirements

Make sure that you have installed helm in your machine and you are connected to a Kubernetes cluster. The chart is qualified for helm version > v3 & Kube version v1.20.8. Follow the documentation from the link to install helm: https://helm.sh/docs/helm/helm_version/

helm version
version.BuildInfo{Version:"v3.0.2", GitCommit:"19e47ee3283ae98139d98460de796c1be1e3975f", GitTreeState:"clean", GoVersion:"go1.13.5"}
Enter fullscreen mode Exit fullscreen mode

Installing Configurator using helm chart

Follow the below steps to directly deploy the Configurator helm package. Make sure that a namespace 'configurator' already exists in your cluster. If not, create a namespace with the following command.

kubectl create namespace configurator
Enter fullscreen mode Exit fullscreen mode

Add the configurator helm repository, by executing the following command :

helm repo add gopaddle_configurator https://gopaddle-io.github.io/configurator/helm/
Enter fullscreen mode Exit fullscreen mode

Once the command is executed, verify the repository by running the command below. You must see the configurator_helm repo in the list.

helm repo list
Enter fullscreen mode Exit fullscreen mode

The output must be similar to this:

NAME                      URL                                           
hashicorp                 https://helm.releases.hashicorp.com              
gopaddle_configurator     https://gopaddle-io.github.io/configurator/helm/
Enter fullscreen mode Exit fullscreen mode

Once you've verified the repo, install the helm chart with the following command: helm install

helm install release1.0.0 gopaddle_configurator/configurator
Enter fullscreen mode Exit fullscreen mode

This installs the Configurator CRDs and the controller in the 'configurator' namespace. After you install the helm chart, verify by listing the resources in the corresponding namespace using the following commands.

kubectl get pods -n configurator
kubectl get crds -n configurator
kubectl get serviceaccounts -n configurator
kubectl get clusterrolebindings -n configurator
Enter fullscreen mode Exit fullscreen mode

Configurator is now ready for use. Here is a reference blog on how to use configurator with the deployments : https://blog.gopaddle.io/2021/04/01/strange-things-you-never-knew-about-kubernetes-configmaps-on-day-one/

Customizing Configurator helm chart based on requirements

Sometimes, you may wish to change the Configurator image name, Docker repository, image tag or even include other service charts along with Configurator. Modifying the Configurator helm is pretty straightforward.
Make sure you've cloned the Configurator GitHub project before proceeding with the next steps.

To clone the project, run the following command:

git clone https://github.com/gopaddle-io/configurator.git
Enter fullscreen mode Exit fullscreen mode

The helm package needs to be unpacked to modify the helm chart. The zip file will be present at the path configurator/helm in the Configurator project. Choose this option when you want to modify the helm chart configuration. Unzip the file with the following command.

tar -zxvf <path to .tgz file> 
Enter fullscreen mode Exit fullscreen mode

This will extract the contents of the chart in a folder.
Once you extract, the helm chart's file system tree will look like this:

configurator
├── charts
├── Chart.yaml
├── crds
│   ├── crd-customConfigMap.yaml
│   └── crd-customSecret.yaml
├── templates
│   ├── configurator-clusterrolebinding.yaml
│   ├── configurator-clusterrole.yaml
│   ├── configurator-deployment.yaml
│   ├── configurator-serviceaccount.yaml
│   └── tests
└── values.yaml
Enter fullscreen mode Exit fullscreen mode

The crds directory contains the custom resource definition files - crd-customConfigMap.yaml & crd-customSecret.yaml. The templates directory contains the resource's yaml files, in our case, it contains the roles and role bindings and the configurator service definitions. The charts directory is empty by default. This folder can be used to add your application charts that use Configurator Custom Resource. The Chart.yaml file contains information about the helm, like the chart's name, description, type etc.

# Default values for my_chart.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.

replicaCount: 1
replicas: 1
namespace: configurator
image: gopaddle/configurator:latest
Enter fullscreen mode Exit fullscreen mode

You can edit the values.yaml file to your requirements like changing the namespace, replica_count or the image name, docker repository or the image tag. Make sure that the namespace used in the values.yaml exists in the cluster before you do a helm install. Once the necessary configuration is done, execute the following command to install the charts into your cluster :
helm install

helm install release1.0.0 configurator
Enter fullscreen mode Exit fullscreen mode

This will install the helm chart inside the cluster with the new configurations.

Contributing back to the configurator project

To contribute the helm changes back to the Configurator project, you need to package the helm chart with the following command :

helm package <path to helm chart>
Enter fullscreen mode Exit fullscreen mode

This command will package the charts to a .tgz file. After packaging the helm, you need to give a pull request for code review & merge.

You can take a look at this open-source project @ https://github.com/gopaddle-io/configurator.git.

For any queries on how to use or how to contribute to the project, you can reach us on our discord server - https://discord.gg/dr24Z4BmP8

Image courtesy - https://www.freepik.com/vectors/technology Technology vector created by stories - www.freepik.com

Discussion (0)