<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: ashvin</title>
    <description>The latest articles on Forem by ashvin (@ashvin).</description>
    <link>https://forem.com/ashvin</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F700914%2Fb3f8c9f6-0e92-437f-aa7e-b8a42481b75f.jpg</url>
      <title>Forem: ashvin</title>
      <link>https://forem.com/ashvin</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/ashvin"/>
    <language>en</language>
    <item>
      <title>Using Helm Charts with Configurator - A versioning &amp; sync service for Kubernetes ConfigMaps</title>
      <dc:creator>ashvin</dc:creator>
      <pubDate>Wed, 08 Sep 2021 09:50:50 +0000</pubDate>
      <link>https://forem.com/ashvin/using-helm-charts-with-configurator-a-versioning-sync-service-for-kubernetes-configmaps-1non</link>
      <guid>https://forem.com/ashvin/using-helm-charts-with-configurator-a-versioning-sync-service-for-kubernetes-configmaps-1non</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuzrzpjj3aa6gbuct259v.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuzrzpjj3aa6gbuct259v.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Configurator&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Configurator is an opensource project that version controls and keeps Kubernetes ConfigMaps and Secrets in sync with the deployments. Configurator uses CRDs to create &lt;em&gt;CustomConfigMaps&lt;/em&gt; and &lt;em&gt;CustomSecrets&lt;/em&gt; that in turn creates ConfigMaps and Secrets with a postfix. As and when a change is detected in a &lt;em&gt;CustomConfigMap&lt;/em&gt; or a &lt;em&gt;CustomSecret&lt;/em&gt;, 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.&lt;/p&gt;

&lt;p&gt;This blog will focus on the following motives:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Installing Configurator using the helm chart.&lt;/li&gt;
&lt;li&gt;Customizing Configurator helm chart based on requirements.&lt;/li&gt;
&lt;li&gt;Contributing back to the Configurator project.
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;System Requirements&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;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 &amp;gt; v3 &amp;amp; Kube version v1.20.8. Follow the documentation from the link to install helm: &lt;a href="https://helm.sh/docs/helm/helm_version/" rel="noopener noreferrer"&gt;https://helm.sh/docs/helm/helm_version/&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;helm version
version.BuildInfo&lt;span class="o"&gt;{&lt;/span&gt;Version:&lt;span class="s2"&gt;"v3.0.2"&lt;/span&gt;, GitCommit:&lt;span class="s2"&gt;"19e47ee3283ae98139d98460de796c1be1e3975f"&lt;/span&gt;, GitTreeState:&lt;span class="s2"&gt;"clean"&lt;/span&gt;, GoVersion:&lt;span class="s2"&gt;"go1.13.5"&lt;/span&gt;&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Installing Configurator using helm chart&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;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.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl create namespace configurator
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add the configurator helm repository, by executing the following command :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;helm repo add gopaddle_configurator https://gopaddle-io.github.io/configurator/helm/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once the command is executed, verify the repository by running the command below. You must see the configurator_helm repo in the list.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;helm repo list
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The output must be similar to this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;NAME                      URL                                           
hashicorp                 https://helm.releases.hashicorp.com              
gopaddle_configurator     https://gopaddle-io.github.io/configurator/helm/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once you've verified the repo, install the helm chart with the following command: &lt;em&gt;helm install  &lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;helm &lt;span class="nb"&gt;install &lt;/span&gt;release1.0.0 gopaddle_configurator/configurator
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;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.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl get pods &lt;span class="nt"&gt;-n&lt;/span&gt; configurator
kubectl get crds &lt;span class="nt"&gt;-n&lt;/span&gt; configurator
kubectl get serviceaccounts &lt;span class="nt"&gt;-n&lt;/span&gt; configurator
kubectl get clusterrolebindings &lt;span class="nt"&gt;-n&lt;/span&gt; configurator
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Configurator is now ready for use. Here is a reference blog on how to use configurator with the deployments : &lt;a href="https://blog.gopaddle.io/2021/04/01/strange-things-you-never-knew-about-kubernetes-configmaps-on-day-one/" rel="noopener noreferrer"&gt;https://blog.gopaddle.io/2021/04/01/strange-things-you-never-knew-about-kubernetes-configmaps-on-day-one/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Customizing Configurator helm chart based on requirements&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;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.&lt;br&gt;
Make sure you've cloned the Configurator GitHub project before proceeding with the next steps. &lt;/p&gt;

&lt;p&gt;To clone the project, run the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git clone https://github.com/gopaddle-io/configurator.git
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;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.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;tar&lt;/span&gt; &lt;span class="nt"&gt;-zxvf&lt;/span&gt; &amp;lt;path to .tgz file&amp;gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will extract the contents of the chart in a folder. &lt;br&gt;
Once you extract, the helm chart's file system tree will look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;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
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The crds directory contains the custom resource definition files - &lt;em&gt;crd-customConfigMap.yaml&lt;/em&gt; &amp;amp; &lt;em&gt;crd-customSecret.yaml&lt;/em&gt;. 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 &lt;em&gt;Chart.yaml&lt;/em&gt; file contains information about the helm, like the chart's name, description, type etc.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Default values for my_chart.&lt;/span&gt;
&lt;span class="c"&gt;# This is a YAML-formatted file.&lt;/span&gt;
&lt;span class="c"&gt;# Declare variables to be passed into your templates.&lt;/span&gt;

replicaCount: 1
replicas: 1
namespace: configurator
image: gopaddle/configurator:latest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can edit the &lt;em&gt;values.yaml&lt;/em&gt; 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 &lt;em&gt;values.yaml&lt;/em&gt; 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 : &lt;br&gt;
&lt;em&gt;helm install  &lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;helm &lt;span class="nb"&gt;install &lt;/span&gt;release1.0.0 configurator
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will install the helm chart inside the cluster with the new configurations. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Contributing back to the configurator project&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To contribute the helm changes back to the Configurator project, you need to package the helm chart with the following command :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;helm package &amp;lt;path to helm chart&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;p&gt;You can take a look at this open-source project @ &lt;a href="https://github.com/gopaddle-io/configurator.git" rel="noopener noreferrer"&gt;https://github.com/gopaddle-io/configurator.git&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;For any queries on how to use or how to contribute to the project, you can reach us on our discord server - &lt;a href="https://discord.gg/dr24Z4BmP8" rel="noopener noreferrer"&gt;https://discord.gg/dr24Z4BmP8&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Image courtesy - &lt;a href="https://www.freepik.com/vectors/technology" rel="noopener noreferrer"&gt;https://www.freepik.com/vectors/technology&lt;/a&gt; Technology vector created by stories - &lt;a href="http://www.freepik.com" rel="noopener noreferrer"&gt;www.freepik.com&lt;/a&gt;&lt;/p&gt;

</description>
      <category>kubernetes</category>
      <category>devops</category>
      <category>docker</category>
      <category>opensource</category>
    </item>
  </channel>
</rss>
