<?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: Sagar Jadhav</title>
    <description>The latest articles on Forem by Sagar Jadhav (@sagarjadhv23).</description>
    <link>https://forem.com/sagarjadhv23</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%2F350566%2Fcddbbf98-7660-4f3b-b669-32b6af7986d4.jpg</url>
      <title>Forem: Sagar Jadhav</title>
      <link>https://forem.com/sagarjadhv23</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/sagarjadhv23"/>
    <language>en</language>
    <item>
      <title>Deploy a Microservice in Kubernetes with zero lines of code</title>
      <dc:creator>Sagar Jadhav</dc:creator>
      <pubDate>Wed, 22 Sep 2021 05:26:51 +0000</pubDate>
      <link>https://forem.com/sagarjadhv23/deploy-a-microservice-in-kubernetes-with-zero-lines-of-code-2619</link>
      <guid>https://forem.com/sagarjadhv23/deploy-a-microservice-in-kubernetes-with-zero-lines-of-code-2619</guid>
      <description>&lt;p&gt;In general, To deploy a Microservice in Kubernetes you have to perform the following tasks:&lt;/p&gt;

&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%2Fraw.githubusercontent.com%2Fsagar-jadhav%2Fsagar-jadhav.github.io%2Fmaster%2Fstatic%2Fimg%2F_posts%2Fdeploy-microservice.JPG" 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%2Fraw.githubusercontent.com%2Fsagar-jadhav%2Fsagar-jadhav.github.io%2Fmaster%2Fstatic%2Fimg%2F_posts%2Fdeploy-microservice.JPG" alt="Import a Google Kubernetes Engine"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Build a Docker Image of a Microservice&lt;/li&gt;
&lt;li&gt;Push that Docker Image into an Image Registry&lt;/li&gt;
&lt;li&gt;Create a YAML's for different Kubernetes objects such as Deployment, Service, Secret, etc.&lt;/li&gt;
&lt;li&gt;Apply those YAMLs using the following command:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   kubectl apply -f &amp;lt;FILE_NAME&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;All the above tasks require you to write a lot of code. &lt;strong&gt;What If I do all this in a single command?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Yes, It is possible. Using &lt;a href="https://www.gopaddle.io/" rel="noopener noreferrer"&gt;gopaddle&lt;/a&gt; you can deploy a Microservice in Kubernetes without writing any extra code in just one command. &lt;/p&gt;

&lt;h3&gt;
  
  
  Let me show you How?
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Before you start deploying, finish the below prerequisites:
&lt;/h4&gt;

&lt;p&gt;I. Sign up for a free trial account in &lt;a href="https://gopaddle.io/" rel="noopener noreferrer"&gt;gopaddle&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;II. Import a Google Kubernetes Engine (GKE) into your gopaddle account.&lt;/p&gt;

&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%2Fraw.githubusercontent.com%2Fsagar-jadhav%2Fsagar-jadhav.github.io%2Fmaster%2Fstatic%2Fimg%2F_posts%2Fimport_cluster.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%2Fraw.githubusercontent.com%2Fsagar-jadhav%2Fsagar-jadhav.github.io%2Fmaster%2Fstatic%2Fimg%2F_posts%2Fimport_cluster.png" alt="Import a Google Kubernetes Engine"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;III. Add an Image Registry in your gopaddle account.&lt;/p&gt;

&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%2Fraw.githubusercontent.com%2Fsagar-jadhav%2Fsagar-jadhav.github.io%2Fmaster%2Fstatic%2Fimg%2F_posts%2Fadd_image_registry.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%2Fraw.githubusercontent.com%2Fsagar-jadhav%2Fsagar-jadhav.github.io%2Fmaster%2Fstatic%2Fimg%2F_posts%2Fadd_image_registry.png" alt="Add an Image Registry"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;IV. Add a source code repository in your gopaddle account that will have a source code of a Microservice that you want to deploy in Kubernetes. For this blog, I have used &lt;a href="https://github.com/developersthought/node-hello" rel="noopener noreferrer"&gt;node-hello&lt;/a&gt; repository.&lt;/p&gt;

&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%2Fraw.githubusercontent.com%2Fsagar-jadhav%2Fsagar-jadhav.github.io%2Fmaster%2Fstatic%2Fimg%2F_posts%2Fadd_code_repository.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%2Fraw.githubusercontent.com%2Fsagar-jadhav%2Fsagar-jadhav.github.io%2Fmaster%2Fstatic%2Fimg%2F_posts%2Fadd_code_repository.png" alt="Add a source code repository"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;V. Install &lt;code&gt;gpctl&lt;/code&gt; CLI using the below commands:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;wget https://gpctl.s3-ap-southeast-1.amazonaws.com/gpctl
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;chmod +x gpctl
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cp gpctl /usr/local/bin/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; Refer &lt;a href="https://portal.gopaddle.io/tutorials" rel="noopener noreferrer"&gt;Official Documentation&lt;/a&gt; for more details.&lt;/p&gt;

&lt;h4&gt;
  
  
  Gear up yourself to deploy a Microservice in Kubernetes
&lt;/h4&gt;

&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%2Fmedia.giphy.com%2Fmedia%2FWoiaGtXaOYwRqS2J3m%2Fgiphy.gif%3Fcid%3Decf05e47e4mh6bo9ec1wp7uag3hrkl9k6fjb5dk4ii82002f%26rid%3Dgiphy.gif%26ct%3Dg" 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%2Fmedia.giphy.com%2Fmedia%2FWoiaGtXaOYwRqS2J3m%2Fgiphy.gif%3Fcid%3Decf05e47e4mh6bo9ec1wp7uag3hrkl9k6fjb5dk4ii82002f%26rid%3Dgiphy.gif%26ct%3Dg" alt="Gear Up"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Follow the below steps along with me.&lt;/p&gt;

&lt;p&gt;I. Clone &lt;a href="https://github.com/developersthought/node-hello" rel="noopener noreferrer"&gt;node-hello&lt;/a&gt; git repository using the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git clone https://github.com/developersthought/node-hello.git
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;II. Go to the node-hello directory using the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cd &amp;lt;path_to_node_hello_repo&amp;gt;/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;III. Install dependencies using the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sh buildScript.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;IV. log in to gopaddle account using the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;gpctl login -emailID=&amp;lt;EMAIL&amp;gt; --password=&amp;lt;PASSWORD&amp;gt; --endPoint=https://portal.gopaddle.io
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;EMAIL: Email to connect to gopaddle account&lt;/li&gt;
&lt;li&gt;PASSWORD: Password to connect to gopaddle account&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;V. Deploy Microservice in Kubernetes using the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;gpctl init --startScript=./runScript.sh --buildScript=./buildScript.sh --buildImage=node:8
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above command will prompt you to select the Cluster, Registry, and Policy. Please select appropriately to proceed further.&lt;/p&gt;

&lt;p&gt;That's it !! with this, you have deployed a Microservice in Kubernetes without writing any deployment code.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Hope you like this blog and find it useful, If Yes then do consider &lt;a href="https://www.buymeacoffee.com/sagarjadhv23" rel="noopener noreferrer"&gt;buying me a coffee&lt;/a&gt;.&lt;/em&gt; &lt;/p&gt;

</description>
      <category>kubernetes</category>
      <category>microservices</category>
      <category>devops</category>
      <category>node</category>
    </item>
    <item>
      <title>Introduction to Docker Compose</title>
      <dc:creator>Sagar Jadhav</dc:creator>
      <pubDate>Sat, 07 Aug 2021 11:16:59 +0000</pubDate>
      <link>https://forem.com/sagarjadhv23/introduction-to-docker-compose-4mhf</link>
      <guid>https://forem.com/sagarjadhv23/introduction-to-docker-compose-4mhf</guid>
      <description>&lt;p&gt;➡️ If you are running a multi-container application using Docker and looking for a solution to easily manage the application without any hustle then do check out my new YouTube video on Docker Compose.&lt;/p&gt;

&lt;p&gt;➡️ I have covered the following in this video:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create a custom network with the driver of type bridge in Docker&lt;/li&gt;
&lt;li&gt;Run MySQL database in Docker Container&lt;/li&gt;
&lt;li&gt;Run PHPMyAdmin application in Docker Container&lt;/li&gt;
&lt;li&gt;Remove both MySQL &amp;amp; PHPMyAdmin Docker Container&lt;/li&gt;
&lt;li&gt;Remove custom network&lt;/li&gt;
&lt;li&gt;What is Docker Compose?&lt;/li&gt;
&lt;li&gt;What is Infrastructure As A code?&lt;/li&gt;
&lt;li&gt;Create a docker-compose.yaml&lt;/li&gt;
&lt;li&gt;Run MySQL database and PHPMyAdmin docker containers using Docker Compose&lt;/li&gt;
&lt;li&gt;Remove MySQL database and PHPMyAdmin docker containers using Docker Compose&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;➡️ You could &lt;a href="https://www.buymeacoffee.com/sagarjadhv23"&gt;buy me a coffee&lt;/a&gt; If you like the video and find it useful.&lt;/p&gt;

&lt;p&gt;➡️ You can refer docker-compose.yaml &lt;a href="https://github.com/developersthought/examples/tree/main/youtube"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/4pt8fl90dAE"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

</description>
      <category>docker</category>
      <category>devops</category>
      <category>opensource</category>
    </item>
    <item>
      <title>A quick guide on How to extend kubectl with plugins?</title>
      <dc:creator>Sagar Jadhav</dc:creator>
      <pubDate>Sat, 19 Jun 2021 05:31:33 +0000</pubDate>
      <link>https://forem.com/sagarjadhv23/a-quick-guide-on-how-to-extend-kubectl-with-plugins-2j2a</link>
      <guid>https://forem.com/sagarjadhv23/a-quick-guide-on-how-to-extend-kubectl-with-plugins-2j2a</guid>
      <description>&lt;ul&gt;
&lt;li&gt;kubectl&lt;/li&gt;
&lt;li&gt;What is a plugin?&lt;/li&gt;
&lt;li&gt;
Why write a plugin?

&lt;ul&gt;
&lt;li&gt;Restart a Pod&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;How to write a plugin?&lt;/li&gt;
&lt;li&gt;Demo&lt;/li&gt;
&lt;li&gt;Notes&lt;/li&gt;
&lt;li&gt;Show Your Support&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  kubectl
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;kubectl&lt;/code&gt; is a command-line interface (CLI) used to interact with the &lt;code&gt;Kubernetes&lt;/code&gt; cluster. With the help of kubectl you can perform the following operations on the Kubernetes cluster:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Deploy &amp;amp; Manage containerize application.&lt;/li&gt;
&lt;li&gt;Connect to multiple Kubernetes clusters.&lt;/li&gt;
&lt;li&gt;Get Kubernetes cluster information.&lt;/li&gt;
&lt;li&gt;Many more...&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Visit &lt;a href="https://kubernetes.io/docs/reference/kubectl/overview/"&gt;here&lt;/a&gt; for more detail on kubectl. &lt;/p&gt;

&lt;h3&gt;
  
  
  What is a plugin?
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;kubectl plugin is a standalone executable file used to enhance the functionality of kubectl with new subcommands.&lt;/li&gt;
&lt;li&gt;With plugins, you can add new features to kubectl as per your requirement.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Why write a plugin?
&lt;/h3&gt;

&lt;p&gt;To build a complex use case using existing kubectl commands. Let us understand this with the following use case:&lt;/p&gt;

&lt;h4&gt;
  
  
  Restart a Pod
&lt;/h4&gt;

&lt;p&gt;To restart a &lt;code&gt;Pod&lt;/code&gt; you can use the following methods:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Method 1:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Retrieve the Pod name using the following command:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl get pods
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Delete the Pod using the following command:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl delete pod &amp;lt;POD_NAME&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Method 2:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Retrieve the &lt;code&gt;Deployment&lt;/code&gt; name using the following command:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl get deployment
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Scale down the replica to zero using the following command:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl scale --replicas=0 deploy/&amp;lt;DEPLOYMENT_NAME&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Scale up the replica to one using the following command:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl scale --replicas=1 deploy/&amp;lt;DEPLOYMENT_NAME&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; Both the methods are valid only If Pod is created through Deployment.&lt;/p&gt;

&lt;p&gt;In both the methods to restart a Pod You have to execute multiple kubectl commands. But can you achieve the same using a single command? The answer is YES. Through plugins, you can wrap the above kubectl commands into a single command. For example, You can have a command like &lt;code&gt;kubectl restart pod nginx&lt;/code&gt; where &lt;code&gt;nginx&lt;/code&gt; is the name of the Deployment.&lt;/p&gt;

&lt;h3&gt;
  
  
  How to write a plugin?
&lt;/h3&gt;

&lt;p&gt;Let us understand the whole process step by step by writing a plugin for the &lt;strong&gt;Restart a Pod&lt;/strong&gt; use case.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create a file called &lt;code&gt;kubectl-restart-pod.sh&lt;/code&gt; by using the following command:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;touch kubectl-restart-pod.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Add the following content into the &lt;code&gt;kubectl-restart-pod.sh&lt;/code&gt; file:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#!/bin/bash

# Logging script execution start
echo "-------------------------"

DEPLOYMENT=$1
NAMESPACE=default

if [ ! -z $2 ]; then
 if [ $2 == "-n" ]; then
    NAMESPACE=$3
  fi
fi


# Logging name of the Deployment
echo "Deployment: $DEPLOYMENT"

# Logging name of the Namespace
echo "Namespace: $NAMESPACE"

# Retrieving Deployment
DEPLOYMENT_DETAILS={}

{
 DEPLOYMENT_DETAILS=$(kubectl get deploy $DEPLOYMENT -o json -n $NAMESPACE)
} || {
 echo "-------------------------"
 exit 1
}

# Retrieving the current replicas
CURRENT_REPLICAS=$(echo $DEPLOYMENT_DETAILS | jq .spec.replicas)

# Retrieving the labels
LABELS=$(echo $DEPLOYMENT_DETAILS | jq .spec.selector.matchLabels)
LABEL=$(echo $LABELS | jq -r 'to_entries|map("\(.key)=\(.value|tostring)")|.[0]')

# Scaling down the replicas
echo "Scaling down the replicas to 0"
kubectl scale --replicas=0 deploy/$DEPLOYMENT -n $NAMESPACE

while true; do

    PODS_COUNT=$(kubectl get po -l $LABEL -n $NAMESPACE -o json | jq '.items | length')

    if [ $PODS_COUNT == 0 ]; then
        break
    else
        printf "."
        sleep 5
    fi

done

# Scaling up the replicas
echo ""
echo "Scaling up replicas to $CURRENT_REPLICAS"
kubectl scale --replicas=$CURRENT_REPLICAS deploy/$DEPLOYMENT -n $NAMESPACE

while true; do

    INDEX=0
    RUNNING_COUNT=0
    PODS=$(kubectl get po -l $LABEL -n $NAMESPACE -o json | jq .items)

    while [ $INDEX -lt $CURRENT_REPLICAS ]; do
        PHASE=$(echo $PODS | jq -r --arg index $INDEX '.[$index | tonumber].status.phase')

        if [ $PHASE == "Running" ]; then
            RUNNING_COUNT=$((RUNNING_COUNT + 1))
        fi

        INDEX=$((INDEX + 1))
    done

    if [ $RUNNING_COUNT == $CURRENT_REPLICAS ]; then
        break
    else
        printf "."
        sleep 5
    fi

done

# Logging script execution end
echo ""
echo "-------------------------"

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Refer to source code &lt;a href="https://github.com/developersthought/examples/blob/main/blog/kubectl-plugin/kubectl-restart-pod.sh"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Make &lt;code&gt;kubectl-restart-pod.sh&lt;/code&gt; file executable by using the following command:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;chmod +x kubectl-restart-pod.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Move &lt;code&gt;kubectl-restart-pod.sh&lt;/code&gt; file to &lt;code&gt;/usr/local/bin&lt;/code&gt; directory by using following command:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mv kubectl-restart-pod.sh /usr/local/bin/kubectl-restart-pod
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Demo
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Install &lt;code&gt;jq&lt;/code&gt; on the workstation machine, where you can access the &lt;code&gt;Kubernetes&lt;/code&gt; cluster. Visit &lt;a href="https://stedolan.github.io/jq/"&gt;here&lt;/a&gt; for steps to install jq.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;List all the available plugins by using the following command:&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl plugin list
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;kubectl-restart-pod&lt;/code&gt; plugin should list in the output.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Create namespace &lt;code&gt;demo&lt;/code&gt; by using the following command:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl create ns demo
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Deploy &lt;code&gt;nginx&lt;/code&gt; application on Kubernetes cluster by using the following command:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl create deploy nginx --image=nginx:latest -n demo
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Check the status of nginx Pod by using the following command:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl get po -n demo
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;nginx&lt;/code&gt; Pod should be in the &lt;code&gt;Running&lt;/code&gt; state.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Restart the nginx Pod by using the following command:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl restart pod nginx -n demo
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Notes
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;As a prerequisite, you should have kubectl CLI installed on your workstation machine, where you can access the &lt;code&gt;Kubernetes&lt;/code&gt; cluster. Visit &lt;a href="https://kubernetes.io/docs/tasks/tools/"&gt;here&lt;/a&gt; for steps to install kubectl CLI.&lt;/li&gt;
&lt;li&gt;Name of the plugin standalone executable file should start with &lt;code&gt;kubectl-&lt;/code&gt; for example &lt;code&gt;kubectl-restart-pod.sh&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;You cannot override the existing kubectl command using plugins for example you cannot create a plugin &lt;code&gt;kubectl-delete-pod&lt;/code&gt;. If you create such plugin then it will be ignored when you run &lt;code&gt;kubectl delete pod&lt;/code&gt; command. &lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Show Your Support
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://www.buymeacoffee.com/sagarjadhv23"&gt;Buy me a coffee&lt;/a&gt; If you like the content and find it useful.&lt;/li&gt;
&lt;li&gt;Report an issue &lt;a href="https://github.com/developersthought/roadmap/issues/new"&gt;here&lt;/a&gt; If you find a bug or want to improve the content.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>kubernetes</category>
      <category>devops</category>
      <category>opensource</category>
    </item>
    <item>
      <title>Demystify Pointers in Go</title>
      <dc:creator>Sagar Jadhav</dc:creator>
      <pubDate>Wed, 21 Apr 2021 05:46:04 +0000</pubDate>
      <link>https://forem.com/sagarjadhv23/demystify-pointers-in-go-3anj</link>
      <guid>https://forem.com/sagarjadhv23/demystify-pointers-in-go-3anj</guid>
      <description>&lt;ul&gt;
&lt;li&gt;Introduction&lt;/li&gt;
&lt;li&gt;Pass By Value&lt;/li&gt;
&lt;li&gt;Pointer in Action&lt;/li&gt;
&lt;li&gt;Pointer Receiver&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Pointers is Go is one of the most complex concepts especially for beginners. In this blog, I have explained the Pointers in a very simple format through visualization and point-by-point explanation. Please read the full blog for complete understanding. To start with let me give you the definition of Pointers:&lt;br&gt;
&lt;code&gt;&lt;br&gt;
Pointer stores the memory address of the variable instead of the value of a variable. &lt;br&gt;
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This makes it different from other types of variables.&lt;/p&gt;

&lt;h2&gt;
  
  
  Pass By Value
&lt;/h2&gt;

&lt;p&gt;Let me explain to you the concept of &lt;code&gt;Pass By Value&lt;/code&gt; before going deep in understanding Pointers. If you understand this then It will help you in understanding the code with extensive use of Pointers. In &lt;code&gt;Pass By Value&lt;/code&gt; the value of a variable is copied into the calling method argument instead of the reference or memory address of the variable. Just remember this simple formula:&lt;br&gt;
&lt;code&gt;&lt;br&gt;
 Go always follows Pass By Value and not Pass By Reference&lt;br&gt;
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Let's see How &lt;code&gt;Pass By Value&lt;/code&gt; works in Go.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--jQXwlyO0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ty3dmxann6uhitawqvhr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--jQXwlyO0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ty3dmxann6uhitawqvhr.png" alt="Pass By Value"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Variable &lt;code&gt;x&lt;/code&gt; of type string is defined and the value "Sagar" is assigned to it.&lt;/li&gt;
&lt;li&gt;Method &lt;code&gt;addSurname()&lt;/code&gt; is called with &lt;code&gt;x&lt;/code&gt;, Here the value of &lt;code&gt;x&lt;/code&gt; that is "Sagar" is copied to variable &lt;code&gt;y&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;String "Jadhav" is appended to the value of &lt;code&gt;y&lt;/code&gt; and the result is assigned back to &lt;code&gt;y&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;So updating the value of &lt;code&gt;y&lt;/code&gt; doesn't update the value of &lt;code&gt;x&lt;/code&gt; as both are different variables but storing the same value.&lt;/p&gt;

&lt;h2&gt;
  
  
  Pointer in Action
&lt;/h2&gt;

&lt;p&gt;In the above example How to change the value of &lt;code&gt;x&lt;/code&gt; by updating the value of &lt;code&gt;y&lt;/code&gt;? Here Pointers come into the action. Yes, It is possible to update the value of one variable through other variables with the help of Pointers. Let me explain you through the below example:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--NI0nGLJJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mmz1p9tsh52lk1brm3hw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--NI0nGLJJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mmz1p9tsh52lk1brm3hw.png" alt="Pointer in Action"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Variable &lt;code&gt;x&lt;/code&gt; of type string is defined and the value "Sagar" is assigned to it.&lt;/li&gt;
&lt;li&gt;Variable &lt;code&gt;y&lt;/code&gt; of type string pointer is defined and the address of &lt;code&gt;x&lt;/code&gt; is assigned to it.&lt;/li&gt;
&lt;li&gt;Method &lt;code&gt;addSurname()&lt;/code&gt; is called with &lt;code&gt;y&lt;/code&gt;, Here the value of &lt;code&gt;y&lt;/code&gt; that is the address of &lt;code&gt;x&lt;/code&gt; is copied to variable &lt;code&gt;z&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;String "Jadhav" is appended to the value at address stored in &lt;code&gt;z&lt;/code&gt; and the result "Sagar Jadhav" is assigned back to the variable at the address stored in &lt;code&gt;z&lt;/code&gt;. Sounds complicated, Map this point with the above picture for better understanding.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Pointer Receiver
&lt;/h2&gt;

&lt;p&gt;The use of Pointer with Structs is very common, Hence understanding this concept is a must. Let's get deep-dive through the below example:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--D3Y4qkYV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nk4jh9puh8tc0smfklq3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--D3Y4qkYV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nk4jh9puh8tc0smfklq3.png" alt="Pointer Receiver"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--PD4lkwxT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jf8j8kkdh7a5r4cu7owf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--PD4lkwxT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jf8j8kkdh7a5r4cu7owf.png" alt="Pointer Receiver"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Variable &lt;code&gt;emp&lt;/code&gt; of type employee struct is defined and the property &lt;code&gt;Name&lt;/code&gt; is initialized with value "Sagar".&lt;/li&gt;
&lt;li&gt;Method Receiver &lt;code&gt;addTitle()&lt;/code&gt; is called with string "Mr.", Here the string "Mr." is copied to variable &lt;code&gt;t&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Value of &lt;code&gt;Name&lt;/code&gt; property is appended to Value of &lt;code&gt;t&lt;/code&gt; and the result "Mr. Sagar" is assigned back to the &lt;code&gt;Name&lt;/code&gt; property. But here the &lt;code&gt;Name&lt;/code&gt; property of &lt;code&gt;emp&lt;/code&gt; is not updated because &lt;code&gt;addTitle()&lt;/code&gt; is a method receiver so when it is called, Value of &lt;code&gt;emp&lt;/code&gt; variable is copied to another variable &lt;code&gt;e&lt;/code&gt;. So any update &lt;code&gt;e&lt;/code&gt; will not affect &lt;code&gt;emp&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Pointer receiver &lt;code&gt;addSurname()&lt;/code&gt; is called with string "Jadhav", Here the string "Jadhav" is copied to variable &lt;code&gt;s&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Value of &lt;code&gt;s&lt;/code&gt; is appended to the value of &lt;code&gt;Name&lt;/code&gt; property and the result "Sagar Jadhav" assigned back to the &lt;code&gt;Name&lt;/code&gt; property. Here &lt;code&gt;emp&lt;/code&gt; variable is updated because variable &lt;code&gt;e&lt;/code&gt; is a pointer to &lt;code&gt;emp&lt;/code&gt; so any changes in &lt;code&gt;e&lt;/code&gt; will also affect &lt;code&gt;emp&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Checkout &lt;a href="https://tour.golang.org/methods/4"&gt;here&lt;/a&gt; for more details. &lt;/p&gt;

</description>
      <category>go</category>
      <category>opensource</category>
      <category>programming</category>
    </item>
    <item>
      <title>How to effectively Tag a Cloud Resource?</title>
      <dc:creator>Sagar Jadhav</dc:creator>
      <pubDate>Tue, 26 Jan 2021 13:28:22 +0000</pubDate>
      <link>https://forem.com/sagarjadhv23/how-to-effectively-tag-a-cloud-resource-3j93</link>
      <guid>https://forem.com/sagarjadhv23/how-to-effectively-tag-a-cloud-resource-3j93</guid>
      <description>&lt;ul&gt;
&lt;li&gt;Introduction&lt;/li&gt;
&lt;li&gt;
Types of Tagging

&lt;ul&gt;
&lt;li&gt;I. Automated Tagging&lt;/li&gt;
&lt;li&gt;II. Manual Tagging&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Tagging Best Practices&lt;/li&gt;
&lt;li&gt;Why Tag a Cloud Resource?&lt;/li&gt;
&lt;li&gt;
Demo

&lt;ul&gt;
&lt;li&gt;Add &lt;code&gt;timestamp&lt;/code&gt; tag to EC2 instance through Terraform&lt;/li&gt;
&lt;li&gt;Add &lt;code&gt;env&lt;/code&gt; tag to EC2 instance through AWS Console&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;
Glossary

&lt;ul&gt;
&lt;li&gt;Cloud Resource&lt;/li&gt;
&lt;li&gt;Provision&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Labeling a Cloud Resource in &lt;code&gt;key:value&lt;/code&gt; format is known as Tagging. Labels should contain meaningful information. For e.g. To mark the &lt;code&gt;EC2&lt;/code&gt; instance as a production environment you can tag it with the label &lt;code&gt;env:prod&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Types of Tagging
&lt;/h2&gt;

&lt;h3&gt;
  
  
  I. Automated Tagging
&lt;/h3&gt;

&lt;p&gt;Automated Tagging is a method of adding machine-generated Tag to Cloud Resource at the time of provisioning. You can use Automated Tagging in case of provisioning a Cloud Resource through an automation tool like &lt;a href="https://www.terraform.io/"&gt;Terraform&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Examples:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;user:sagar&lt;/code&gt;: A user who provisioned the Cloud Resource. &lt;/li&gt;
&lt;li&gt;
&lt;code&gt;timestamp:06/01/22 04:11:05&lt;/code&gt;: Time of provisioning.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;id:12456&lt;/code&gt;: Unique identifier of the Cloud Resource.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;group:finance&lt;/code&gt;: A group that owns the Cloud Resource.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  II. Manual Tagging
&lt;/h3&gt;

&lt;p&gt;Manual Tagging is a method of adding Tag manually to Cloud Resource at the time of provisioning. You can use Manual Tagging in case of provisioning a Cloud Resource through UI.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Examples:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;purpose:poc&lt;/code&gt;: The purpose behind provisioning a Cloud Resource.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;env:prod&lt;/code&gt;: Name of the environment where the Cloud Resource is provisioned.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;cleanup:yes&lt;/code&gt;: Delete a Cloud Resource after certain days. &lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Tagging Best Practices
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Use a small case.&lt;/li&gt;
&lt;li&gt;Don't use any special character especially &lt;code&gt;@&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Use underscore &lt;code&gt;_&lt;/code&gt; instead of space.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Why Tag a Cloud Resource?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;To group Cloud Resources. For e.g. If an application has multiple Cloud Resources then you can tag them with the label &lt;code&gt;app:myapp&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;To delete Cloud Resources after certain days. For e.g. You can implement a policy that Cloud Resources will be automatically deleted after 7 days If they are tagged with a &lt;code&gt;cleanup:yes&lt;/code&gt; label.&lt;/li&gt;
&lt;li&gt;For audit purposes. For e.g. You can generate a User per Cloud Resource report i.e How many Cloud Resources are owned by a particular User? By looking at the &lt;code&gt;owner:sagar&lt;/code&gt; Tag.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Demo
&lt;/h2&gt;

&lt;p&gt;Let us understand Automated &amp;amp; Manual Tagging through the following examples:&lt;/p&gt;

&lt;h3&gt;
  
  
  Add &lt;code&gt;timestamp&lt;/code&gt; tag to EC2 instance through Terraform
&lt;/h3&gt;

&lt;p&gt;In this example, you will learn How to add the &lt;code&gt;timestamp&lt;/code&gt; tag to the EC2 instance through &lt;a href="https://www.terraform.io/"&gt;Terraform&lt;/a&gt; at the time of provisioning. Check out &lt;a href="https://registry.terraform.io/providers/hashicorp/aws/latest/docs"&gt;documentation&lt;/a&gt; to configure AWS connection before proceeding with the below steps.&lt;/p&gt;

&lt;p&gt;I. Create a file called &lt;code&gt;main.tf&lt;/code&gt; and add the below content to it&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;data "aws_ami" "ubuntu" {
  most_recent = true

  filter {
    name   = "name"
    values = ["ubuntu/images/hvm-ssd/ubuntu-focal-20.04-amd64-server-*"]
  }

  filter {
    name   = "virtualization-type"
    values = ["hvm"]
  }

  owners = ["099720109477"] # Canonical
}

resource "aws_instance" "web" {
  ami           = data.aws_ami.ubuntu.id
  instance_type = "m1.small"

  tags = {
    Name = "automatedtaggedvm"
    timestamp = "${timestamp()}"
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;II. Run &lt;code&gt;terraform init&lt;/code&gt; command&lt;/p&gt;

&lt;p&gt;III. Run &lt;code&gt;terraform plan&lt;/code&gt; command&lt;/p&gt;

&lt;p&gt;IV. Run &lt;code&gt;terraform apply&lt;/code&gt; command&lt;/p&gt;

&lt;p&gt;V. Verify EC2 instance provisioned with &lt;code&gt;timestamp&lt;/code&gt; Tag&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--xUazTA0A--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/omrox1tcqtzoentmtkfq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--xUazTA0A--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/omrox1tcqtzoentmtkfq.png" alt="EC2 instance with timestamp Tag"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Add &lt;code&gt;env&lt;/code&gt; tag to EC2 instance through AWS Console
&lt;/h3&gt;

&lt;p&gt;In this example, you will learn How to add the &lt;code&gt;env&lt;/code&gt; tag to the EC2 instance through AWS Console at the time of provisioning.&lt;/p&gt;

&lt;p&gt;I. Login to &lt;a href="https://aws.amazon.com/console/"&gt;AWS Console&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;II. Launch EC2 instance and add &lt;code&gt;env&lt;/code&gt; Tag as follows:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--EeMj-QE_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ct5ds498rgqmsvugq0fp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--EeMj-QE_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ct5ds498rgqmsvugq0fp.png" alt="Adding Tag env to EC2 instance"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;III. Verify EC2 instance provisioned with &lt;code&gt;env&lt;/code&gt; Tag&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--XQ_2CObk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/q0gnq5ym8v80j2uq7ooa.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--XQ_2CObk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/q0gnq5ym8v80j2uq7ooa.png" alt="EC2 instance with env Tag"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Glossary
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Cloud Resource
&lt;/h3&gt;

&lt;p&gt;A resource deployed in Cloud. For e.g. EC2 instance, SNS service, Managed Kubernetes Service, etc.&lt;/p&gt;

&lt;h3&gt;
  
  
  Provision
&lt;/h3&gt;

&lt;p&gt;A process of deploying or creating Cloud Resources in Cloud. For e.g. Launching EC2 instance in AWS.&lt;/p&gt;

</description>
      <category>devops</category>
      <category>cloudskills</category>
      <category>terraform</category>
      <category>aws</category>
    </item>
    <item>
      <title>12 Useful OpenShift Commands You Should Know</title>
      <dc:creator>Sagar Jadhav</dc:creator>
      <pubDate>Sat, 09 Jan 2021 06:48:03 +0000</pubDate>
      <link>https://forem.com/sagarjadhv23/12-useful-openshift-commands-you-should-know-3ml4</link>
      <guid>https://forem.com/sagarjadhv23/12-useful-openshift-commands-you-should-know-3ml4</guid>
      <description>&lt;h1&gt;
  
  
  Introduction
&lt;/h1&gt;

&lt;p&gt;Redhat OpenShift is a Container Management and a Hybrid Cloud Platform. It gives you the ability to develop and run containerized applications along with OOTB integration with existing DevOps tools. Checkout OpenShift &lt;a href="https://docs.openshift.com/"&gt;documentation&lt;/a&gt; for more details.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/cUMNWzWZ5n75LvcCIe/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/cUMNWzWZ5n75LvcCIe/giphy.gif" alt="Containers"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;OC&lt;/code&gt; CLI is used to perform various operations on OpenShift. It is similar to &lt;code&gt;kubectl&lt;/code&gt; CLI and offers all the operations that you can perform with &lt;code&gt;kubectl&lt;/code&gt; CLI plus additional support for native OpenShift features. Checkout &lt;code&gt;OC&lt;/code&gt; CLI &lt;a href="https://docs.openshift.com/container-platform/4.6/cli_reference/openshift_cli/getting-started-cli.html#installing-the-cli"&gt;documentation&lt;/a&gt; for more details.&lt;/p&gt;

&lt;h1&gt;
  
  
  12 Useful OpenShift Commands
&lt;/h1&gt;

&lt;p&gt;I. Create Service Account &lt;code&gt;testsa&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;oc create sa testsa
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;II. Add &lt;code&gt;anyuid&lt;/code&gt; SCC to Service Account &lt;code&gt;testsa&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;oc adm policy add-scc-to-user anyuid -z testa
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;III. Deploy &lt;code&gt;nginx&lt;/code&gt; application using &lt;code&gt;nginx&lt;/code&gt; Docker Image from Docker Hub with label &lt;code&gt;app=test&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;oc new-app --docker-image nginx --name nginx -l app=test
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;IV. Scale up &lt;code&gt;nginx&lt;/code&gt; application to 5 replicas&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;oc scale --replicas=5 dc nginx
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;V. Delete &lt;code&gt;nginx&lt;/code&gt; application using label &lt;code&gt;app=test&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;oc delete all -l app=test
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;VI. Export &lt;code&gt;nginx&lt;/code&gt; application definition to &lt;code&gt;nginx.yaml&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;oc new-app --docker-image nginx --name nginx -l app=test -o yaml &amp;gt; nginx.yaml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;VII. Deploy &lt;code&gt;nginx&lt;/code&gt; application using &lt;code&gt;nginx.yaml&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;oc apply -f nginx.yaml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;VIII. Deploy Node.js &lt;code&gt;Hello World&lt;/code&gt; application using GitHub URL with label &lt;code&gt;app=test&lt;/code&gt; and name &lt;code&gt;helloworld&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;oc new-app https://github.com/sagar-jadhav/node-hello --name helloworld -l app=test
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;IX. Export &lt;code&gt;nginx&lt;/code&gt; application to &lt;code&gt;nginx-template&lt;/code&gt; template&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;oc export dc nginx --as-template=nginx-template
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;X. Set &lt;code&gt;requests&lt;/code&gt; &amp;amp; &lt;code&gt;limits&lt;/code&gt; of &lt;code&gt;nginx&lt;/code&gt; application&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;oc set resources dc nginx --requests=cpu=250m --limits=cpu=250m
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;XI. Create Edge Terminated Route &lt;code&gt;nginx-route&lt;/code&gt; for &lt;code&gt;nginx&lt;/code&gt; service using &lt;code&gt;nginx.key&lt;/code&gt; &amp;amp; &lt;code&gt;nginx.crt&lt;/code&gt; files&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;oc create route edge nginx-route --service=nginx --key=nginx.key --cert=nginx.crt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;XII. Create secret &lt;code&gt;user-creds&lt;/code&gt; with values &lt;code&gt;user=admin&lt;/code&gt; and &lt;code&gt;password=admin&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;oc create secret generic user-creds --from-literal='user'='admin' --from-literal='password'='admin'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>devops</category>
      <category>kubernetes</category>
      <category>opensource</category>
      <category>cloud</category>
    </item>
    <item>
      <title>A quick introduction to Velero</title>
      <dc:creator>Sagar Jadhav</dc:creator>
      <pubDate>Mon, 21 Dec 2020 10:00:27 +0000</pubDate>
      <link>https://forem.com/sagarjadhv23/a-quick-introduction-to-velero-43bh</link>
      <guid>https://forem.com/sagarjadhv23/a-quick-introduction-to-velero-43bh</guid>
      <description>&lt;h1&gt;
  
  
  Introduction
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;Formerly known as "Heptio Ark"&lt;/li&gt;
&lt;li&gt;It provides tools to Backup and Restore K8s cluster&lt;/li&gt;
&lt;li&gt;It consists of the following components:

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Server:&lt;/strong&gt; Runs on K8s cluster&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;CLI:&lt;/strong&gt; Runs locally&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Current release: v1.5.x&lt;/li&gt;
&lt;li&gt;GitHub stars: 4.6K+ &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Checkout &lt;a href="https://velero.io/"&gt;here&lt;/a&gt; for more details&lt;/p&gt;

&lt;h1&gt;
  
  
  Architecture
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--GcPWwwvX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://velero.io/docs/v1.5/img/backup-process.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--GcPWwwvX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://velero.io/docs/v1.5/img/backup-process.png" alt="Velero Architecture"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Source:&lt;/strong&gt; &lt;a href="https://velero.io/docs/v1.5/img/backup-process.png"&gt;https://velero.io/docs/v1.5/img/backup-process.png&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Velero supports the following operations:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;On-demand backup&lt;/li&gt;
&lt;li&gt;Scheduled backup&lt;/li&gt;
&lt;li&gt;Restore&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Each operation is a custom resource defined with the custom resource definition and stored in etcd. Velero has controllers that act on these resources.&lt;/p&gt;

&lt;h2&gt;
  
  
  On-demand backup
&lt;/h2&gt;

&lt;p&gt;Creates a copy of k8s objects in the form of tarball and uploads that tarball to cloud object storage&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; Backup operation is not atomic.&lt;/p&gt;

&lt;h2&gt;
  
  
  Scheduled backup
&lt;/h2&gt;

&lt;p&gt;As the name suggests you can schedule the backup at a particular time. You can also schedule recurrent backups. Provide &lt;code&gt;Cron&lt;/code&gt; expression to specify a schedule. For e.g. Use the &lt;code&gt;0 0 * * *&lt;/code&gt; Cron expression to take backup once a day.&lt;/p&gt;

&lt;h2&gt;
  
  
  Restore
&lt;/h2&gt;

&lt;p&gt;Creates k8s objects from the definition stored in cloud object storage.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; As a good practice always set the mode of backup storage location to &lt;code&gt;Read-Only&lt;/code&gt; during restore to avoid update or deletion of backup.&lt;/p&gt;

&lt;p&gt;Velero uses cloud object storage as a source of truth. It synchronizes data between cloud object storage and the K8s cluster.&lt;/p&gt;

&lt;h1&gt;
  
  
  Features
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;Filtering k8s objects based on type, namespace &amp;amp; label during backup and restore&lt;/li&gt;
&lt;li&gt;TTL (Time to Live) for backups. Backup resources will be deleted after TTL is reached&lt;/li&gt;
&lt;li&gt;Different lifecycle hooks for both backup and restore operations&lt;/li&gt;
&lt;li&gt;Supports namespace remapping i.e. K8s object from namespace &lt;code&gt;A&lt;/code&gt; can be restored to namespace &lt;code&gt;B&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>devops</category>
      <category>opensource</category>
      <category>kubernetes</category>
    </item>
    <item>
      <title>Executing Shell Script in Terraform via Null Resource</title>
      <dc:creator>Sagar Jadhav</dc:creator>
      <pubDate>Mon, 07 Dec 2020 12:45:52 +0000</pubDate>
      <link>https://forem.com/sagarjadhv23/executing-shell-script-in-terraform-via-null-resource-872</link>
      <guid>https://forem.com/sagarjadhv23/executing-shell-script-in-terraform-via-null-resource-872</guid>
      <description>&lt;p&gt;Null Resource in Terraform implements all the lifecycle methods as compare to other resources but it doesn't take any action. It is very useful for many use cases but in this blog I will cover How I can use Null Resource to execute the shell script by using local exec provisioner during provision.&lt;/p&gt;

&lt;h3&gt;
  
  
  Use Case
&lt;/h3&gt;

&lt;p&gt;Let say I am deploying some resources on private cloud (x-cloud) through terraform but provision should only start when x-cloud is up &amp;amp; running. x-cloud exposed a &lt;code&gt;REST&lt;/code&gt; API for health check, Hence as part of provisioning I should first check whether x-cloud is up &amp;amp; running, If it is running then continue with the provisioning otherwise stop the provisioning.&lt;/p&gt;

&lt;h4&gt;
  
  
  Step 1: Shell script to perform health check
&lt;/h4&gt;

&lt;p&gt;healthcheck.sh&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#!/bin/sh

result=$(curl -X GET --header "Accept: */*" "https://jsonplaceholder.typicode.com/todos/1" | jq -r '.id')

if [ $result -eq 1 ]
then
   exit 0
else
   exit 1
fi
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Step 2: Terraform file for provision
&lt;/h4&gt;

&lt;p&gt;main.tf&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;terraform {
  required_version = "&amp;gt; 0.8.0"
}

resource "null_resource" "health_check" {

 provisioner "local-exec" {

    command = "/bin/bash healthcheck.sh"
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Step 3: Initializing Terraform
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;terraform init
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Initializing provider plugins...

The following providers do not have any version constraints in configuration,
so the latest version was installed.

To prevent automatic upgrades to new major versions that may contain breaking
changes, it is recommended to add version = "..." constraints to the
corresponding provider blocks in configuration, with the constraint strings
suggested below.

* provider.null: version = "~&amp;gt; 2.1"

Terraform has been successfully initialized!

You may now begin working with Terraform. Try running "terraform plan" to see
any changes that are required for your infrastructure. All Terraform commands
should now work.

If you ever set or change modules or backend configuration for Terraform,
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Step 4: Provisioning resources
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;terraform apply
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # null_resource.health_check will be created
  + resource "null_resource" "health_check" {
      + id = (known after apply)
    }

Plan: 1 to add, 0 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

null_resource.health_check: Creating...
null_resource.health_check: Provisioning with 'local-exec'...
null_resource.health_check (local-exec): Executing: ["/bin/sh" "-c" "/bin/bash healthcheck.sh"]
null_resource.health_check (local-exec):   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
null_resource.health_check (local-exec):                                  Dload  Upload   Total   Spent    Left  Speed
null_resource.health_check (local-exec):   0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
null_resource.health_check (local-exec):   0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
null_resource.health_check (local-exec): 100    83  100    83    0     0    154      0 --:--:-- --:--:-- --:--:--   154
null_resource.health_check: Creation complete after 0s [id=9103842202970100490]

Apply complete! Resources: 1 added, 0 changed, 0 destroyed.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  References:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.terraform.io/docs/providers/null/resource.html"&gt;Null Resource&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.terraform.io/docs/provisioners/local-exec.html"&gt;Local Exec&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>terraform</category>
      <category>devops</category>
      <category>bash</category>
    </item>
    <item>
      <title>How to deploy applications using Helm in Kubernetes?</title>
      <dc:creator>Sagar Jadhav</dc:creator>
      <pubDate>Sun, 28 Jun 2020 05:15:59 +0000</pubDate>
      <link>https://forem.com/sagarjadhv23/how-to-deploy-applications-using-helm-in-kubernetes-5b0k</link>
      <guid>https://forem.com/sagarjadhv23/how-to-deploy-applications-using-helm-in-kubernetes-5b0k</guid>
      <description>&lt;p&gt;Let's learn How to deploy PHPMyAdmin application using helm chart? Learn more about helm &lt;a href="https://helm.sh/"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites:
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Create NFS share
&lt;/h3&gt;

&lt;p&gt;Reference:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.linuxbabe.com/ubuntu/nfs-share"&gt;https://www.linuxbabe.com/ubuntu/nfs-share&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://vitux.com/install-nfs-server-and-client-on-ubuntu/"&gt;https://vitux.com/install-nfs-server-and-client-on-ubuntu/&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Install Helm
&lt;/h3&gt;

&lt;p&gt;Refer installation guide &lt;a href="https://helm.sh/docs/intro/install/"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Clone github repository
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git clone https://github.com/sagar-jadhav/kubernetes-essentials.git
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Go to &lt;code&gt;session_5&lt;/code&gt; directory
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cd ./kubernetes-essentials/session_5/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Enable Nginx ingress controller
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;minikube addons enable ingress
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl get pods --watch -n kube-system
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Exit once controller pod goes into running state&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1: Create PHPMyAdmin helm chart
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;helm create phpmyadmin
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 2: Add all application YAML files to templates directory
&lt;/h2&gt;

&lt;p&gt;Remove unwanted files from template directory&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rm -rf ./phpmyadmin/templates/*
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Copy YAML files&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cp configmap.yaml db-deployment.yaml db-pv.yaml db-pvc.yaml db-service.yaml secret.yaml phpmyadmin-deployment.yaml phpmyadmin-ingress.yaml phpmyadmin-service.yaml ./phpmyadmin/templates/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 3: Package helm chart
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;helm package phpmyadmin
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 4: Deploy PHPMyAdmin application
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;helm install phpmyadmin ./phpmyadmin-0.1.0.tgz
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 5: List helm release
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;helm ls
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 6: List pods
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl get pods
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Demo
&lt;/h2&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/7yjyLG66Rk0"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

</description>
      <category>kubernetes</category>
      <category>opensource</category>
      <category>beginners</category>
      <category>devops</category>
    </item>
    <item>
      <title>What is Readiness &amp; Liveness Probes in Kubernetes?</title>
      <dc:creator>Sagar Jadhav</dc:creator>
      <pubDate>Sun, 21 Jun 2020 04:34:45 +0000</pubDate>
      <link>https://forem.com/sagarjadhv23/what-is-readiness-liveness-probes-in-kubernetes-12ep</link>
      <guid>https://forem.com/sagarjadhv23/what-is-readiness-liveness-probes-in-kubernetes-12ep</guid>
      <description>&lt;p&gt;Kubernetes uses &lt;code&gt;Readiness&lt;/code&gt; &amp;amp; &lt;code&gt;Liveness&lt;/code&gt; probes to manage pod lifecycle. Readiness probe is used to determine whether pod is ready to accept the traffic or not and liveness probe is used to determine whether pod is functioning properly or not. Read more about them &lt;a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/"&gt;here&lt;/a&gt;. In this blog I am adding readiness &amp;amp; liveness probe to PHPMyAdmin application.&lt;/p&gt;

&lt;h2&gt;
  
  
  Architecture
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--clG_myr0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/0fe50x78pk2frhoeizlr.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--clG_myr0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/0fe50x78pk2frhoeizlr.JPG" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites:
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Deploy PHPMyAdmin Application
&lt;/h3&gt;

&lt;p&gt;Follow &lt;a href="https://dev.to/sagarjadhv23/what-is-deployment-service-secret-and-configmap-in-kubernetes-1pk5"&gt;Deploy phpMyAdmin application on kubernetes&lt;/a&gt; blog&lt;/p&gt;

&lt;h3&gt;
  
  
  Go to session_4 directory
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cd ../session_4/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 1: Delete PHPMyAdmin deployment
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl delete deployment phpmyadmin
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 2: Deploy PHPMyAdmin deployment with Readiness &amp;amp; Liveness probes
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl create -f phpmyadmin-deployment.yaml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl get pods --watch
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Exit once pod goes into running state&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 9: Browse phpmyadmin application
&lt;/h2&gt;

&lt;p&gt;Go to browser and browse &lt;a href="http://IP_ADDRESS:30030"&gt;http://IP_ADDRESS:30030&lt;/a&gt;. Login with &lt;code&gt;root&lt;/code&gt; user &amp;amp; &lt;code&gt;test&lt;/code&gt; password&lt;/p&gt;

&lt;p&gt;here IP_ADDRESS is the ip address of virtual machine where kubernetes is running.&lt;/p&gt;

&lt;h2&gt;
  
  
  Demo
&lt;/h2&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/c9cnPuD6QgU"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

</description>
      <category>devops</category>
      <category>kubernetes</category>
      <category>opensource</category>
      <category>beginners</category>
    </item>
    <item>
      <title>What is Ingress Controller in Kubernetes?</title>
      <dc:creator>Sagar Jadhav</dc:creator>
      <pubDate>Sat, 13 Jun 2020 04:31:03 +0000</pubDate>
      <link>https://forem.com/sagarjadhv23/what-is-ingress-controller-in-kubernetes-1p1c</link>
      <guid>https://forem.com/sagarjadhv23/what-is-ingress-controller-in-kubernetes-1p1c</guid>
      <description>&lt;p&gt;In &lt;a href="https://dev.to/sagarjadhv23/what-is-deployment-service-secret-and-configmap-in-kubernetes-1pk5"&gt;Deploy phpMyAdmin application on kubernetes&lt;/a&gt; blog I used &lt;code&gt;NodePort&lt;/code&gt; service type to expose application to external world but disadvantage with that approach is &lt;code&gt;port&lt;/code&gt; needs to be exposed on each node and there is a dependency on external load balancer for load balancing requests, custom hostname and SSL/TLS encryption support etc. With the help of &lt;code&gt;Ingress&lt;/code&gt; controllers I can eliminate dependency on external load balancer. In this blog I am using &lt;code&gt;Nginx Ingress&lt;/code&gt; controller to expose PHPMyAdmin application to external world. Learn more about ingress controller &lt;a href="https://kubernetes.io/docs/concepts/services-networking/ingress/"&gt;here&lt;/a&gt; &lt;/p&gt;

&lt;h2&gt;
  
  
  Architecture
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--OPj_2nm6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ihtot7hu86d7sx2z5yms.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--OPj_2nm6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ihtot7hu86d7sx2z5yms.JPG" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites:
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Deploy PHPMyAdmin Application
&lt;/h3&gt;

&lt;p&gt;Follow &lt;a href="https://dev.to/sagarjadhv23/what-is-deployment-service-secret-and-configmap-in-kubernetes-1pk5"&gt;Deploy phpMyAdmin application on kubernetes&lt;/a&gt; blog&lt;/p&gt;

&lt;h3&gt;
  
  
  Go to session_2 directory
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cd ../session_3/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 1: Enable Nginx ingress controller
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;minikube addons enable ingress
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl get pods --watch -n kube-system
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Exit once controller pod goes into running state&lt;/p&gt;

&lt;p&gt;This step is valid only for &lt;code&gt;Minikube&lt;/code&gt;. Check steps to enable &lt;code&gt;Nginx Ingress&lt;/code&gt; controller on &lt;code&gt;Kubernetes&lt;/code&gt; &lt;a href="https://www.nginx.com/products/nginx/kubernetes-ingress-controller/"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: Delete PHPMyAdmin NodePort service
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl delete svc phpmyadmin
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 3: Deploy PHPMyAdmin ClusterIP service
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl create -f phpmyadmin-service.yaml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 4: Deploy PHPMyAdmin Ingress rule
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl create -f phpmyadmin-ingress.yaml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl get ingress --watch
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Exit once address gets populated&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 5: Update hosts file custome hostname
&lt;/h2&gt;

&lt;p&gt;Add below entry in /etc/hosts&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;INGRESS_ADDRESS&amp;gt; myapp.xyz
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Get INGRESS_ADDRESS from &lt;code&gt;kubectl get ingress&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Demo
&lt;/h2&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/ZS1TaAmuNl4"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

</description>
      <category>kubernetes</category>
      <category>devops</category>
      <category>beginners</category>
      <category>opensource</category>
    </item>
    <item>
      <title>What is Persistent Volume (PV) &amp; Persistent Volume Claim (PVC) in Kubernetes?</title>
      <dc:creator>Sagar Jadhav</dc:creator>
      <pubDate>Sat, 06 Jun 2020 04:38:13 +0000</pubDate>
      <link>https://forem.com/sagarjadhv23/what-is-persistent-volume-pv-persistent-volume-claim-pvc-in-kubernetes-33io</link>
      <guid>https://forem.com/sagarjadhv23/what-is-persistent-volume-pv-persistent-volume-claim-pvc-in-kubernetes-33io</guid>
      <description>&lt;p&gt;Here, I am covering concepts of &lt;code&gt;persistent volume&lt;/code&gt; (PV) &amp;amp; &lt;code&gt;persistent volume claim&lt;/code&gt; (PVC). In the previous &lt;a href="https://dev.to/sagarjadhv23/what-is-deployment-service-secret-and-configmap-in-kubernetes-1pk5"&gt;blog&lt;/a&gt; I have covered how to deploy PHPMyAdmin application in kubernetes. PHPMyAdmin application does not have a persistent storage. Hence If MySQL pod die due to some unexpected error for e.g. resource crunch then data stored in database will also get deleted as data by default stored in pod. Pods by default are stateless in nature. Hence to persist MySQL data &lt;code&gt;PV&lt;/code&gt; &amp;amp;  &lt;code&gt;PVC&lt;/code&gt; is required.&lt;/p&gt;

&lt;h3&gt;
  
  
  Persistent Volume (PV)
&lt;/h3&gt;

&lt;p&gt;Storage provisioned by administrator. Learn more &lt;a href="https://kubernetes.io/docs/concepts/storage/persistent-volumes/" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Persistent Volume Clain (PVC)
&lt;/h3&gt;

&lt;p&gt;Request for a storage by user. Learn more &lt;a href="https://kubernetes.io/docs/concepts/storage/persistent-volumes/" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Architecture
&lt;/h2&gt;

&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%2Fi%2Fvvwmoqyabngy72l8idb6.JPG" 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%2Fi%2Fvvwmoqyabngy72l8idb6.JPG" alt="Architecture"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites:
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Deploy PHPMyAdmin Application
&lt;/h3&gt;

&lt;p&gt;Follow &lt;a href="https://dev.to/sagarjadhv23/what-is-deployment-service-secret-and-configmap-in-kubernetes-1pk5"&gt;Deploy phpMyAdmin application on kubernetes&lt;/a&gt; blog&lt;/p&gt;

&lt;h3&gt;
  
  
  Go to session_2 directory
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cd ../session_2/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 1: Create NFS share
&lt;/h2&gt;

&lt;p&gt;Reference:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.linuxbabe.com/ubuntu/nfs-share" rel="noopener noreferrer"&gt;https://www.linuxbabe.com/ubuntu/nfs-share&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://vitux.com/install-nfs-server-and-client-on-ubuntu/" rel="noopener noreferrer"&gt;https://vitux.com/install-nfs-server-and-client-on-ubuntu/&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I have created NFS mount at &lt;code&gt;/mnt/share&lt;/code&gt; location on VM with IP &lt;code&gt;192.168.1.6&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: Create Persistent Volume (PV)
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl create -f db-pv.yaml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 3: Create Persistent Volume Claim (PVC)
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl create -f db-pvc.yaml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 4: List PV &amp;amp; PVC
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl get pvc
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl get pv
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 5: Redeploy MySQL deployment
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl delete deployment db
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl create -f db-deployment.yaml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here &lt;code&gt;db-deployment.yaml&lt;/code&gt; is updated YAML with volume &amp;amp; volume mounts. Next watch pods.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl get pods -n watch
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Exit once db pod goes into running state.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 6: Go to mount directory and list files
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cd /mnt/share
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ls -ltr
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Demo
&lt;/h2&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/uUsuHvOohDk"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

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