<?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 gaurd on Medium]]></title>
        <description><![CDATA[Stories by gaurd on Medium]]></description>
        <link>https://medium.com/@gauravd999?source=rss-265f31cfed30------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Stories by gaurd on Medium</title>
            <link>https://medium.com/@gauravd999?source=rss-265f31cfed30------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 08:51:59 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@gauravd999/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[Deploy Simple Python application locally with Kubernetes (MiniKube)]]></title>
            <link>https://medium.com/@gauravd999/deploy-simple-python-application-locally-with-kubernetes-minikube-a2f8861f78cc?source=rss-265f31cfed30------2</link>
            <guid isPermaLink="false">https://medium.com/p/a2f8861f78cc</guid>
            <category><![CDATA[deployment]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[minikube]]></category>
            <category><![CDATA[kubernetes]]></category>
            <dc:creator><![CDATA[gaurd]]></dc:creator>
            <pubDate>Fri, 23 May 2025 12:02:33 GMT</pubDate>
            <atom:updated>2025-05-23T12:13:15.715Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kRkYyOirPq-PvqZyH1g-QA.avif" /></figure><p>I recently started learning Kubernetes, again! Having tried my hand previously at learning it, I somehow got derailed and couldn’t learn much about it.</p><p>But now, being in a situation where I must learn it, I invested all my time into it learning the fundamentals first and alongside implement basic concepts practically using Minikube in local system.</p><p>Here in this article I have discussed step-by-step process of deploying a simple python application using Docker and Kubernetes.</p><p>I am assuming that you are familiar with fundamentals of Kubernetes like pods, containers, ReplicaSets, Deployment and services. If not, then you can use this <a href="https://kubebyexample.com/learning-paths/kubernetes-fundamentals/environment-variables-and-configmaps#">link</a> to read more about them and then come back here for a practical implementation.</p><h3>Setup</h3><ol><li>Minikube</li><li>Docker Desktop</li><li>Git client</li></ol><h3>Sample Python application</h3><p>You can clone a sample python application from Github. The sample python application uses FastAPI framework which exposes a simple html web page with following output:</p><pre>{<br>  &quot;message&quot;: &quot;Hello World&quot;<br>}</pre><p>Lets start by cloning the application:</p><pre>git clone https://github.com/estebanx64/python-docker-example &amp;&amp; cd python-docker-example</pre><p>Please make sure that you are in “python-docker-example” directory.</p><p>The first step in deploying your application to Kubernetes is to containerise the application. I am using Docker to containerise the application. You will be able to containerise and run application locally using docker by following the steps mentioned below in the article. You can also follow the Docker Documentation <a href="https://docs.docker.com/guides/python/containerize/"><strong>link</strong></a> to gain a deep understanding of the containerisation process.</p><p>To containerise your application using Docker, run docker init to create necessary Docker files. After running docker init, you will be asked to answer a few question related to your application like platform you are using, python version, port etc. Refer to the <a href="https://docs.docker.com/guides/python/containerize/#initialize-docker-assets"><strong>link</strong></a> for help with answering the questions.</p><p>After you have answered the questions, the docker init process will get completed. You will be able to see the following files created in your current directory.</p><ol><li>Dockerfile</li><li>compose.yaml</li><li>.dockerignore</li><li>.gitignore</li></ol><p>You can open the created Dockerfile to see a series of instructions(commands) that Docker runs to build an image. To create a Docker image for your sample python application, run</p><pre>docker build -t sample_application .</pre><p>The breakdown of the command is as follows:</p><ol><li>docker build: Command to build an image from Dockerfile.</li><li>-t sample_application : Attach a tag name “sample_application” to your docker image. You can keep any name as you wish.</li><li>. : Dot means to use the current directory as build context (where the Dockerfile and code are).</li></ol><p>You can verify the docker image creation using docker imagescommand. You should see something like:</p><pre>REPOSITORY          TAG       IMAGE ID       CREATED          SIZE<br>sample_application  latest    abcd1234abcd   56 seconds ago   252MB</pre><p>Docker image is ready now. Your application is ready to run in your local machine. Run the docker image using:</p><pre>docker run -it --rm -p 8000:8000 sample_application<br><br>The output will be:<br><br>INFO:     Started server process [7]<br>INFO:     Waiting for application startup.<br>INFO:     Application startup complete.<br>INFO:     Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit)</pre><p>This will start your python application. You can open the mentioned link in your web browser to see your application running.</p><p>Great! Job well done. You have your python application containerised and running through docker.</p><h3>Run Python Application using Kubernetes with Minikube</h3><p>I am sure you have Minikube installed in your system. In this section I will give you a walk-through on how to run your application on Kubernetes using Minikube on your local machine.</p><p>We start first by creating a deployment.yaml file. This file tells Kubernetes on how to deploy and manage your application’s containers including which image to use, how many pods to run and which setting to apply. Since this is your first application deployment with Kubernetes, we will keep our deployment.yaml file very basic and simple. Here is a sample deployment.yaml file for you:</p><pre>apiVersion: apps/v1<br>kind: Deployment<br>metadata:<br>  name: sample-application-deploy<br>spec:<br>  replicas: 1<br>  selector:<br>    matchLabels:<br>      app: sample-application-deploy<br>  template:<br>    metadata:<br>      labels:<br>        app: sample-application-deploy<br>    spec:<br>      containers:<br>        - name: sample-application<br>          image: sample_deployment:latest<br>          imagePullPolicy: Never<br>          ports:<br>            - containerPort: 8000</pre><p>The key components in the file are as follows:</p><ol><li><strong>kind: </strong>Since this is a Deployment resource object type in Kubernetes.</li><li><strong>replicas</strong>: The number of pods you want to run. For our application single node is enough.</li><li><strong>selector: </strong>Specifies how the file will find which pods to manage.</li><li><strong>template: </strong>Pod template that specifies container, image and configuration.</li></ol><p>For deploying your sample application, you need to focus on the container component where the image name, port and container name is mentioned.</p><p>containerPort: 8000: This is the port your Python application (Uvicorn) <strong>listens to, inside the container</strong>.</p><p>I want you to focus on image configuration. <strong>The image name mentioned in the file is not the same image name as that we created earlier in previous section</strong>. Lets take a step back and see why.</p><p>If you recall from previous section of this article, we built a docker image using the command:</p><pre>docker build -t sample_deployment .</pre><p>This image was created in docker in your local machine.</p><p>Now what is the problem here, you might ask. Since you are using your local machine with Docker and Minikube both installed in it, then why can’t you use the docker image built using the above command.</p><p><strong>The problem is Minikube runs Kubernetes in its own environment so it doesn’t see docker images running in your local machine by default.</strong></p><p>So, when you apply deployment.yaml with the follwing config:</p><pre>image: sample_deployment:latest<br>imagePullPolicy: Never</pre><p>Kubernetes will fail to find the image because you don’t have the mentioned “sample_deployment” docker image in Minikube environment.</p><p>The solution for this problem is to specify in your terminal to use Minikube’s docker environment instead of Docker environment of your local machine. To use Minikube’e Docker environment, run the command:</p><pre>eval $(minikube docker-env)</pre><p>Now, if you run docker images command, you will see all the existing images inside Minikube’s docker environment but you will find that image “sample_deployment” is not there. So, you have to create it in this environment using:</p><pre>docker build -t sample_deployment .</pre><p>If you run docker images again, you will see the “sample_deployment” image in the output.</p><p>Also, please make sure that in “deployment.yaml” file, inside containers, you set the following value:</p><pre>imagePullPolicy: Never</pre><p>This config will make sure that Kubernetes tries to locate your image for container locally and not on Docker hub. You can also set the value as “IfNotPresent”.</p><p>Your “deployment.yaml” is ready!</p><p>We have to create another file “service.yaml”.</p><blockquote>A “service.yaml” file defines how to expose the application inside Kubernetes so it can be accessed by other services or users — either from inside the cluster or from outside(like a web server).</blockquote><p>Here is the “service.yaml” file:</p><pre>apiVersion: v1<br>kind: Service<br>metadata:<br>  name: sample-application-deploy<br>spec:<br>  type: NodePort<br>  selector:<br>    app: sample-application-deploy<br>  ports:<br>    - port: 8080<br>      targetPort: 8000</pre><ol><li><strong>kind: </strong>Specifying that this is a<strong> </strong>Service type file.</li><li><strong>port: 8080</strong> : This is the port exposed by the Kubernetes service which can be used by other pods internally.</li><li><strong>targetPort: 8000</strong>: This is the port on which your app is actually listening from inside the Pod. (In Dockerfile, you have used 8000 as the port where you application is listening through Uvicorn)</li></ol><p>Our deployment and service YAML files are ready. These 2 files are enough to run your python application as a web service. We will now apply both YAML files using:</p><pre>kubectl apply -f deployment.yaml<br>kubectl apply -f service.yaml</pre><p>After, “deployment.yaml” is applied you can check the created pod using:</p><pre>kubectl get pods</pre><p>After, “service.yaml” is applied you can see the create service using:</p><pre>kubectl get service</pre><p>Finally, to access your application via Kubernetes through Minikube, run the command:</p><pre>minikube service first-docker-application --url</pre><p>Minikube will give you a URL like <a href="http://127.0.0.1:50216/">http://127.0.0.1:50216</a>. You can open the link in a browser and see your application is accessible as a web service: run and managed using Kubernetes.</p><p>You can notice that the port of the URL which you are using to access you web service is 50216 which is not mentioned explicitly in any of your YAML files.</p><p><strong>Where did the port 50216 come from?</strong></p><p>If you see the “service.yaml”, Kubernetes service type is mentioned as NodePort. Technically this means that Kubernetes service is exposed on Minikube VM which runs in a virtual environment. That VM uses a different IP, and the exposed port is <strong>randomized</strong> in the NodePort range (usually between 30000–32767), <strong>not 8080</strong>.</p><p>You can say that 50216 is external port and 8080 is the internal port. Within the Kubernetes cluster, if there are multiple nodes, they can access your application’s pod using 8080 port.</p><p>After you are done with your experiment and you have a functional web service using Kubernetes, you can shut down the service using:</p><pre>kubectl delete -f deployment.yaml<br>kubectl delete -f service.yaml</pre><p>Also, if you remember, we set our docker environment to Minikube’s docker environment. To unset it, use:</p><pre>eval ${minikube docker-env -u}</pre><p>I hope you were able to learn and deploy a simple python application using Kubernetes with Minikube locally in your system.</p><p>The next step is to use Helm charts to deploy your application in Kubernetes. Helm charts make it much more easier managing deployments in Kubernetes. We will walk through a detailed hands-on process in the next article.</p><p>Till then, keep learning!</p><h4>References:</h4><ol><li><a href="https://docs.docker.com/guides/python/containerize/">https://docs.docker.com/guides/python/containerize/</a></li><li><a href="https://kubebyexample.com/learning-paths/kubernetes-fundamentals">https://kubebyexample.com/learning-paths/kubernetes-fundamentals</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a2f8861f78cc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Life hacks writings on Medium vs actually practising them]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@gauravd999/life-hacks-writings-on-medium-vs-actually-practising-them-efb2670a2cd8?source=rss-265f31cfed30------2"><img src="https://cdn-images-1.medium.com/max/1232/1*eG6sTN5DAcvNakNzfReCUg.png" width="1232"></a></p><p class="medium-feed-snippet">Do you really practice that you write or believe in?</p><p class="medium-feed-link"><a href="https://medium.com/@gauravd999/life-hacks-writings-on-medium-vs-actually-practising-them-efb2670a2cd8?source=rss-265f31cfed30------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@gauravd999/life-hacks-writings-on-medium-vs-actually-practising-them-efb2670a2cd8?source=rss-265f31cfed30------2</link>
            <guid isPermaLink="false">https://medium.com/p/efb2670a2cd8</guid>
            <category><![CDATA[belief]]></category>
            <category><![CDATA[life-lessons]]></category>
            <category><![CDATA[writing-on-medium]]></category>
            <category><![CDATA[philosophy-of-life]]></category>
            <category><![CDATA[medium]]></category>
            <dc:creator><![CDATA[gaurd]]></dc:creator>
            <pubDate>Mon, 20 Jan 2025 17:01:39 GMT</pubDate>
            <atom:updated>2025-01-20T17:01:39.818Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Rohit-Virat Dilemma in test line up]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@gauravd999/rohit-virat-dilemma-in-test-line-up-4b9d5874eb1a?source=rss-265f31cfed30------2"><img src="https://cdn-images-1.medium.com/max/1200/1*WYUCNNKzCPOh6EXStkbeJw.jpeg" width="1200"></a></p><p class="medium-feed-snippet">Whether Virat and Rohit should continue in red ball cricket or not.</p><p class="medium-feed-link"><a href="https://medium.com/@gauravd999/rohit-virat-dilemma-in-test-line-up-4b9d5874eb1a?source=rss-265f31cfed30------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@gauravd999/rohit-virat-dilemma-in-test-line-up-4b9d5874eb1a?source=rss-265f31cfed30------2</link>
            <guid isPermaLink="false">https://medium.com/p/4b9d5874eb1a</guid>
            <category><![CDATA[rohit-sharma]]></category>
            <category><![CDATA[indian-cricket-team]]></category>
            <category><![CDATA[cricket]]></category>
            <category><![CDATA[virat-kohli]]></category>
            <category><![CDATA[border-gavaskar-trophy]]></category>
            <dc:creator><![CDATA[gaurd]]></dc:creator>
            <pubDate>Sun, 12 Jan 2025 09:07:43 GMT</pubDate>
            <atom:updated>2025-01-12T09:07:43.154Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Mental Accounting]]></title>
            <link>https://medium.com/@gauravd999/mental-accounting-2bb1552992fd?source=rss-265f31cfed30------2</link>
            <guid isPermaLink="false">https://medium.com/p/2bb1552992fd</guid>
            <category><![CDATA[self-awareness]]></category>
            <category><![CDATA[self-help-books]]></category>
            <dc:creator><![CDATA[gaurd]]></dc:creator>
            <pubDate>Sat, 11 Jan 2025 13:26:00 GMT</pubDate>
            <atom:updated>2025-01-16T03:04:50.063Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TJ0YRXW8EhzpT5jqlxKtzg.jpeg" /></figure><p>“Bzzz, Bzzz, Bzzz!” Phone alarm buzzes at 6 AM around Rohit and he turns it off. He gets out of his bed and starts with his daily routine of walking, workout, meditation and then read for a while. He has been following the same routine for few weeks now. He has been reading quite a lot of self-help books in recent times. He lives in Bangalore, the silicon valley of India. He works at an IT firm as a Software Engineer.</p><p>His firm relocated to another locality. It would be his first day today in the new office. He gets ready quickly to leave for office.</p><p>His wife hands him packed lunch box and he gently kisses her on forehead before leaving. He takes the stairs down from his apartment on the 2nd floor. He puts on his helmet, hops on his motor bike and takes off for office through the streets of Bangalore. It’s a 15 KM ride to his office.</p><p>Since it’s his first day he takes guidance from Google Maps for navigation. In Bangalore, metro line is under construction, so, majority of roads on his route are congested. He reaches the office in an hour. The next day he takes the same route without navigation help. In the following days he decides to take different subways, roads skipping congested fly over bridges to reach office as soon as possible. For 2 weeks, every route that he travelled, took around 55–60 mins. He was agitated every day after travelling because of the traffic congestion, rash drivers overtaking and cutting the line and delays because of people driving on the wrong sides.</p><p>One day when he was struck in traffic, a thought ran through his mind that he read in a book (The art of the good life by Rolf Dobelli ) about mental accounting followed by many other mental tools written in the book. He realised that in order to reach office daily, he must stick to a route and all the things frustrating him are the realities he must accept. Once he accepted all of the realities, the daily route to office was no longer agitating. Also, the agitation was taking a toll on his health while affecting his work as well. He finally put the mental tools he had been reading, to practice. And it worked like a charm.</p><p>Rohit read a lot of self-help books for years. Until that moment of realisation, those books proved to be just words about people acting in a way to accomplish something or improve themselves. After that moment, he became self-aware of facing situations where he can apply the mental tools or practices written in self help books. His decision making and ability to handle emotions certainly got better.</p><p>What are the lessons from reading that you put to daily use?</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2bb1552992fd" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>