<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Shovan Maity on Medium]]></title>
        <description><![CDATA[Stories by Shovan Maity on Medium]]></description>
        <link>https://medium.com/@shovanmaity?source=rss-d92b457e399a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*0CElWIDRuSdHS_V-67JACg.jpeg</url>
            <title>Stories by Shovan Maity on Medium</title>
            <link>https://medium.com/@shovanmaity?source=rss-d92b457e399a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 15:33:47 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@shovanmaity/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[use private git repository as go mod dependency]]></title>
            <link>https://shovanmaity.medium.com/use-private-git-repository-as-go-mod-dependency-7f9d380f9567?source=rss-d92b457e399a------2</link>
            <guid isPermaLink="false">https://medium.com/p/7f9d380f9567</guid>
            <category><![CDATA[go]]></category>
            <category><![CDATA[golang]]></category>
            <dc:creator><![CDATA[Shovan Maity]]></dc:creator>
            <pubDate>Tue, 16 Mar 2021 04:05:51 GMT</pubDate>
            <atom:updated>2021-03-16T04:05:51.656Z</atom:updated>
            <content:encoded><![CDATA[<p>The go <a href="https://github.com/golang/go/wiki/Modules">modules</a> is inbuilt dependency management tool for golang and from go 1.14 it is in GA. In this article, we will discuss how we can use a private git repository as a go module. Go uses 3 sites at the time of downloading new dependency. This works well with public go modules for private go modules we need to make some changes that we will go through in this article.</p><blockquote>The Go team is providing the following services run by Google: a module mirror for accelerating Go module downloads, an index for discovering new modules, and a global go.sum database for authenticating module content.</blockquote><ul><li><a href="https://proxy.golang.org/">https://proxy.golang.org</a></li><li><a href="https://index.golang.org/">https://index.golang.org</a></li><li><a href="https://sum.golang.org/">https://sum.golang.org</a></li></ul><p>To make it working with private repo we need to make 2 changes.</p><ul><li><strong>Bypass go proxy</strong></li></ul><p>Go provides an environment variable called <strong>GOPRIVATE</strong> which allows us to provide a comma-separated list of glob patterns of private modules.</p><ul><li><strong>Provide credentials to download go modules</strong></li></ul><p>We need to create a personal access token or app token for your user in <a href="https://github.com/settings/tokens">github</a> or <a href="https://gitlab.com/-/profile/personal_access_tokens">gitlab</a> or <a href="https://bitbucket.org/account/settings/app-passwords">bitbucket</a>.</p><figure><img alt="Create personal access token in github" src="https://cdn-images-1.medium.com/max/1024/0*-pJNIN_22Rat0YW6" /></figure><figure><img alt="Create personal access token in gitlab" src="https://cdn-images-1.medium.com/max/1024/0*4cF6Af3MAG7W7yFg" /></figure><figure><img alt="Create personal access token in bitbucket" src="https://cdn-images-1.medium.com/max/1024/0*GUIcIyaLC1D0Tgq1" /></figure><p><strong>Local environment</strong></p><p>We can add a make target like this and by running <em>make vendor</em> we will be able to download private modules.</p><pre>.PHONY: vendor<br>vendor:<br> @GO111MODULE=on \<br> GOPRIVATE=bitbucket.org/shovanmaity/go-pvt-module,github.com/shovanmaity/go-pvt-module,gitlab.com/shovanmaity/go-pvt-module \<br> GIT_TERMINAL_PROMPT=1 \<br> go mod tidy</pre><pre> @GO111MODULE=on \<br> GOPRIVATE=bitbucket.org/shovanmaity/go-pvt-module,github.com/shovanmaity/go-pvt-module,gitlab.com/shovanmaity/go-pvt-module \<br> GIT_TERMINAL_PROMPT=1 \<br> go mod download</pre><pre> @GO111MODULE=on \<br> GOPRIVATE=bitbucket.org/shovanmaity/go-pvt-module,github.com/shovanmaity/go-pvt-module,gitlab.com/shovanmaity/go-pvt-module \<br> GIT_TERMINAL_PROMPT=1 \<br> go mod vendor</pre><p>If we have ssh key setup in our local environment then we can run these commands</p><pre>git config — global \<br> url.”git@github.com”.insteadOf \<br> “https://github.com&quot;<br>git config — global \<br> url.”git@gitlab.com”.insteadOf \<br> “https://gitlab.com&quot;<br>git config — global \<br> url.”git@bitbucket.org”.insteadOf \<br> “https://bitbucket.org&quot;</pre><p>We can export the access key in local gitconfig(~/.gitconfig). Here X_TOKEN will works with both password and personal access token. But it is not recommended.</p><pre>git config — global \<br> url.”https://${GITHUB_USERNAME}:${GITHUB_TOKEN}@github.com&quot;.insteadOf \<br> “https://github.com&quot;</pre><pre>git config — global \<br> url.”https://${GITLAB_USERNAME}:${GITLAB_TOKEN}@gitlab.com&quot;.insteadOf \<br> “https://gitlab.com&quot;</pre><pre>git config — global \<br> url.”https://${BITBUCKET_USERNAME}:${BITBUCKET_TOKEN}@bitbucket.org&quot;.insteadOf \<br> “https://bitbucket.org&quot;</pre><p><strong>Docker environment</strong><br>In the docker environment we need to define some environment variables and pass it build time. Here is one example docker file.</p><pre>ARG GITHUB_USERNAME<br>ARG GITHUB_TOKEN<br>ARG GITLAB_USERNAME<br>ARG GITLAB_TOKEN<br>ARG BITBUCKET_USERNAME<br>ARG BITBUCKET_TOKEN<br>RUN git config — global \<br> url.”https://${GITHUB_USERNAME}:${GITHUB_TOKEN}@github.com&quot;.insteadOf \<br> “https://github.com&quot;<br>RUN git config — global \<br> url.”https://${GITLAB_USERNAME}:${GITLAB_TOKEN}@gitlab.com&quot;.insteadOf \<br> “https://gitlab.com&quot;<br>RUN git config — global \<br> url.”https://${BITBUCKET_USERNAME}:${BITBUCKET_TOKEN}@bitbucket.org&quot;.insteadOf \<br> “https://bitbucket.org&quot;</pre><p>Here is one make target to call docker build.</p><pre>.PHONY: image<br>.DEFAULT_GOAL := image<br>image:<br> docker build -t test-private-go-mod:ci \<br> — build-arg GITHUB_USERNAME=$(GITHUB_USERNAME) \<br> — build-arg GITHUB_TOKEN=$(GITHUB_TOKEN) \<br> — build-arg GITLAB_USERNAME=$(GITLAB_USERNAME) \<br> — build-arg GITLAB_TOKEN=$(GITLAB_TOKEN) \<br> — build-arg BITBUCKET_USERNAME=$(BITBUCKET_USERNAME) \<br> — build-arg BITBUCKET_TOKEN=$(BITBUCKET_TOKEN) \<br> -f Dockerfile .<br> docker image prune -f — filter label=type=build-container</pre><p>We can export these secret values in ci vm. In local build we can call make target like -</p><pre>shovan@probot:~$ <em>GITHUB_USERNAME=shovanmaity GITHUB_TOKEN=*** GITLAB_USERNAME=shovanmaity GITLAB_TOKEN=*** BITBUCKET_USERNAME=shovanmaity BITBUCKET_TOKEN=*** make</em></pre><p>This source code is available in <a href="https://github.com/shovanmaity/go-mod/tree/main/private-repo">this github repo</a> and build log is available <a href="https://github.com/shovanmaity/go-mod/actions?query=workflow%3A%22private+go+mod%22">here</a>.</p><pre>Step 14/15 : RUN make vendor<br> — -&gt; Running in 7ed5b19a7be1<br>go: downloading github.com/***/go-pvt-module v0.0.1<br>go: downloading gitlab.com/***/go-pvt-module v0.0.1<br>go: downloading bitbucket.org/***/go-pvt-module v0.0.1<br>Removing intermediate container 7ed5b19a7be1<br> — -&gt; 0883b1325195<br>Step 15/15 : RUN go run main.go<br> — -&gt; Running in 6d993d5f35f3<br> — — — — — — — — — — — — — — -<br>I am bitbucket private repo.<br>I am github private repo.<br>I am gitlab private repo.<br> — — — — — — — — — — — — — — -</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7f9d380f9567" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Write Kubernetes controller in any language]]></title>
            <link>https://shovanmaity.medium.com/write-kubernetes-controller-in-any-language-68b625b66321?source=rss-d92b457e399a------2</link>
            <guid isPermaLink="false">https://medium.com/p/68b625b66321</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[kubernetes-controller]]></category>
            <dc:creator><![CDATA[Shovan Maity]]></dc:creator>
            <pubDate>Sun, 19 Apr 2020 18:46:36 GMT</pubDate>
            <atom:updated>2020-04-20T09:28:26.204Z</atom:updated>
            <content:encoded><![CDATA[<h3>Write Kubernetes controller in any programming language</h3><p>Metacontroller is one way to write a Kubernetes controller in any language. It is a Kubernetes controller administration that runs in cluster scope and manages your controllers. It works like the pub-sub model. For your every controller you need to write a controller spec. Once you apply that spec your controller is subscribed to the metacontroller. According to controller spec, the metacontroller triggers sync and finalize hooks.</p><p>You can write your controller logic in any language. Once you subscribe to metacontroller, it makes POST requests with the current state. Your controller needs to respond with the desired state. The metacontroller server then executes a control loop on behalf of your controller and calls sync and finalize hook functions whenever necessary.</p><p>Metacontroller provides you APIs to write the specification for your controllers. You can create two types of controllers - CompositeController or DecoratorController .</p><p>While exploring metacontroller I used different examples to understand CompositeController andDecoratorController APIs. This <a href="https://github.com/shovanmaity/metacontroller-by-example">repo</a> contains these examples. It also contains sample controllers in different languages and steps to run those controllers in the local setup.</p><p>Metacontroller is not under active development. One of the <a href="https://github.com/AmitKumarDas/metac">fork</a> of <a href="https://github.com/GoogleCloudPlatform/metacontroller">metacontroller</a> contains some extra features. It exposes one more controller API GenericController and if you are using golang to build your controller then you can use metacontroller as a library in your controller. There is an <a href="https://github.com/GoogleCloudPlatform/metacontroller/issues/184">initiative</a> going on to add it to the kubernetes-sigs project.</p><p>Useful links -</p><ul><li><a href="https://github.com/shovanmaity/metacontroller-by-example">https://github.com/shovanmaity/metacontroller-by-example</a></li><li><a href="https://metacontroller.app/faq/">https://metacontroller.app</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=68b625b66321" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Multi-node k3s using Raspberry-Pi]]></title>
            <link>https://shovanmaity.medium.com/multi-node-k3s-using-raspberry-pi-8a1076065277?source=rss-d92b457e399a------2</link>
            <guid isPermaLink="false">https://medium.com/p/8a1076065277</guid>
            <category><![CDATA[k3]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[raspberry-pi]]></category>
            <dc:creator><![CDATA[Shovan Maity]]></dc:creator>
            <pubDate>Wed, 15 Apr 2020 14:24:06 GMT</pubDate>
            <atom:updated>2020-04-15T17:28:30.174Z</atom:updated>
            <content:encoded><![CDATA[<p>I’m excited about k3s. I was running k3s in my local setup for a long time. Recently I set up a multi-node Kubernetes using Raspberry Pi and k3s. This blog contains the steps for that.</p><p><strong>Boot Raspberry Pi</strong></p><ul><li><em>Download the </em><a href="https://www.raspberrypi.org/downloads/raspbian"><em>Raspbian</em></a><em> image and flash the image to the SD card using </em><a href="https://www.balena.io/etcher"><em>Etcher</em></a><em>.</em></li><li><em>Once the flash is complete, enable ssh in the Pi. To do this, create a file named </em><em>ssh in the root of the boot directory.</em></li><li><em>To configure the Pi to connect to a WiFi network, create a file called </em><em>wpa_supplicant.conf in the root of the boot directory with the below contents.<br>NOTE:- You need to replace some of the values in the configuration. Here is one example </em><a href="https://github.com/shovanmaity/k3s-with-pi/blob/master/config/wpa_supplicant.conf"><em>file</em></a><em>.</em></li></ul><pre>country=IN<br>update_config=1<br>ctrl_interface=/var/run/wpa_supplicant<br>network={<br>  scan_ssid=1<br>  ssid=”pify”<br>  psk=”test@pify”<br>}</pre><ul><li><em>Eject the SD card and insert it into the Pi. Power up the Pi and wait for a minute to boot.</em></li><li><em>From your local machine, use </em><em>Nmap to scan your local network. If you don’t have, install it using </em><em>sudo apt-get install nmap. Using </em>sudo nmap -sn 192.168.1.0/24<em> you will be able to find the IP of your Pi.<br>NOTE:- CIDR can be different for your network.</em></li><li><em>Once you find the IP address of your Pi, ssh into it as </em><em>pi user with the default password </em><em>raspberry.</em></li></ul><p><strong>Configure Kubernetes master</strong></p><ul><li><em>SSH into one Pi and change the hostname </em><em>/etc/hostname. After edit it will be like below (You can provide a different hostname) -</em></li></ul><pre>pi@raspberrypi:~ $ cat /etc/hostname <br>pi-master</pre><ul><li><em>Apply the same changes in </em><em>/etc/hosts file. After edit it will be like below -</em></li></ul><pre>pi@pi-master:~ $ cat /etc/hosts<br>127.0.0.1   localhost<br>::1         localhost ip6-localhost ip6-loopback<br>ff02::1     ip6-allnodes<br>ff02::2     ip6-allrouters<br><br>127.0.1.1   pi-master</pre><ul><li><em>Reboot the Pi and ssh again.</em></li><li><em>Install k3s using the below command. I am installing k3s without </em><em>traefik and </em><em>servicelb . If you want </em><em>traefik and </em><em>servicelb then don’t execute the 1st command.</em></li></ul><pre>export INSTALL_K3S_EXEC=&quot;--no-deploy servicelb --no-deploy traefik&quot;<br>curl -sfL https://get.k3s.io | sh -</pre><ul><li><em>Verify the k3s service using </em><em>sudo systemctl status k3s --no-pager .</em></li><li><em>Verify the node by using </em><em>sudo k3s kubectl get node.</em></li></ul><pre>pi@pi-master:~ $ sudo k3s kubectl get node<br>NAME        STATUS   ROLES    AGE   VERSION<br>pi-master   Ready    master   25s   v1.17.4+k3s1</pre><ul><li><em>Get the node token by using </em><em>sudo cat /var/lib/rancher/k3s/server/node-token . This is required if you want to create a multi-node cluster.</em></li><li><em>Kubeconfig present in</em><em>/etc/rancher/k3s/k3s.yaml file in the Pi. Copy it in your local machine. Update the server IP with the IP of the Pi. Then access the cluster using this kubeconfig.</em></li></ul><pre>apiVersion: v1<br> clusters:<br> - cluster:<br>     server: https://127.0.0.1:6443</pre><p>Change this to bellow.</p><pre>apiVersion: v1<br> clusters:<br> - cluster:<br>     server: https://192.168.1.34:6443</pre><p><strong>Configure Kubernetes worker</strong></p><p>This is required only if you want to create a multi-node Kubernetes cluster. You need to boot another Pi and follow the below steps. You can add as many worker nodes as you want. Only the hostname will be different.</p><ul><li><em>SSH into one Pi and change the hostname </em><em>/etc/hostname. After edit it will be like below (You can provide a different hostname) -</em></li></ul><pre>pi@raspberrypi:~ $ cat /etc/hostname <br>pi-worker-0</pre><ul><li><em>Apply the same changes in </em><em>/etc/hosts file also add a domain name for master IP. If the IP of master got changed you need to update </em><em>/etc/hosts file only. After edit it will be like below -</em></li></ul><pre>pi@pi-master:~ $ cat /etc/hosts<br>127.0.0.1     localhost<br>::1           localhost ip6-localhost ip6-loopback<br>ff02::1       ip6-allnodes<br>ff02::2       ip6-allrouters<br><br>127.0.1.1     pi-worker-0<br>192.168.1.34  pi-master</pre><ul><li><em>Reboot the Pi and ssh again.</em></li><li><em>Install k3s agent.</em></li></ul><pre>export K3S_URL=&quot;https://pi-master:6443&quot;<br>export K3S_TOKEN=&quot;&lt;<em>node token</em>&gt;&quot;<br>curl -sfL https://get.k3s.io | sh -</pre><ul><li><em>Verify the k3s-agent service using </em><em>sudo systemctl status k3s-agent --no-pager .</em></li><li><em>From the master node verify the nodes using </em><em>sudo k3s kubectl get node .</em></li></ul><p>Check this GitHub <a href="https://github.com/shovanmaity/k3s-with-pi">repo</a> for more details.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8a1076065277" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>