<?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>DEV Community: Akshay Rao</title>
    <description>The latest articles on DEV Community by Akshay Rao (@aksrao1998).</description>
    <link>https://dev.to/aksrao1998</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%2F881898%2F46435714-27bb-4468-852d-58b3502060d8.jpeg</url>
      <title>DEV Community: Akshay Rao</title>
      <link>https://dev.to/aksrao1998</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/aksrao1998"/>
    <language>en</language>
    <item>
      <title>Trigger workflows of different repositories and exchange data</title>
      <dc:creator>Akshay Rao</dc:creator>
      <pubDate>Thu, 07 Mar 2024 15:04:45 +0000</pubDate>
      <link>https://dev.to/aksrao1998/trigger-workflows-of-different-repositories-and-exchange-data-5a1p</link>
      <guid>https://dev.to/aksrao1998/trigger-workflows-of-different-repositories-and-exchange-data-5a1p</guid>
      <description>&lt;p&gt;Hi, i am Akshay rao&lt;br&gt;
This blog shows the demo of triggering a workflow and exchanging data between two workflow.&lt;br&gt;
I have taken two repo:-&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;chat-app-helm-chart repo(helm-chart repo)&lt;/li&gt;
&lt;li&gt;real-time-chat-app repo(dev repo)&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;helm-chart repo -&amp;gt; it will trigger the workflow in dev repo.&lt;/li&gt;
&lt;li&gt;dev repo -&amp;gt; the workflow will build a image and push it to the docker hub and it will pass the tag which has been attached to the image, in this case i have take the timestamp as the tag.&lt;/li&gt;
&lt;li&gt;helm chart repo -&amp;gt; another workflow will be trigger form the dev repo to pul the image.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6qjomgqbk69zymngu766.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6qjomgqbk69zymngu766.png" alt="Image 1" width="800" height="455"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Lets start&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Create a personal Access token(PAT) with admin, repo read write and workflow permission.&lt;/li&gt;
&lt;li&gt;Save this PAT as a secret in the repository as i hvae saved as &lt;code&gt;TOKEN_TO_TRIGGER&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;In the helm chart repo make a file trigger.yaml and pull.yaml in ./github/workflows
trigger.yaml
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;name: deploy the app

on:
  push:
    branches:
      main
jobs:
  build:
    runs-on: ubuntu-22.04
    steps:
      - name: trigger dev repo to build image
        uses: peter-evans/repository-dispatch@v1
        with:
         token: ${{ secrets.TOKEN_TO_TRIGGER }}
         repository: Devops-MLOps/real-time-chat-application
         event-type: my-event
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;pull.yaml&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;name: pull the image

on:
  repository_dispatch:
    types: [my-pull]
jobs:
  run_if_failure:
    if: ${{ !github.event.client_payload.passed }}
    runs-on: ubuntu-latest
    steps: 
      - env:
          TAG: ${{ github.event.client_payload.tag }}
        run: echo $TAG &amp;amp;&amp;amp; docker pull aksrao1998/chat-app-be:$TAG
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;In dev repo ./github/workflow create trigger_build.yaml
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;name: build and push image
on:
  repository_dispatch:
    types: [my-event]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: checkout the repository
        uses: actions/checkout@v2
      - name: docker login
        uses: docker/login-action@v3
        with:
          username: ${{secrets.DOCKER_USER}}
          password: ${{secrets.DOCKER_PASS}}
      - name: timestamp for tag
        id: timestamp
        run: echo "::set-output name=timestamp::$(date +'%Y%m%d%H%M%S')"
      - name: build and push the frontend image 
        uses: docker/build-push-action@v5
        with:
          context: ./client
          file: ./client/Dockerfile
          push : true
          tags: aksrao1998/chat-app-fe:${{ steps.timestamp.outputs.timestamp }}
      - name:  build and push the backend image 
        uses: docker/build-push-action@v5
        with:
          context: ./server
          file: ./server/Dockerfile
          push : true
          tags: aksrao1998/chat-app-be:${{ steps.timestamp.outputs.timestamp }}
      - name: trigger helm repo for pull
        uses: peter-evans/repository-dispatch@v1
        with:
         token: ${{ secrets.TOKEN_TO_TRIGGER }}
         repository: Devops-MLOps/chat-app-helm-chart
         event-type: my-pull
         client-payload: '{"passed": false, "tag": "${{ steps.timestamp.outputs.timestamp }}"}'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Trigger the helm chart trigger workflow by pushing to main branch or manually&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd2lanfv516dgla2zbntx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd2lanfv516dgla2zbntx.png" alt="Image 2" width="800" height="328"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Once above build is success then automaically the workflow in the dev repo (with my-event) will be triggered.&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flkckuh9pmj4rlnmz7704.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flkckuh9pmj4rlnmz7704.png" alt="Image 3" width="800" height="388"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Once above build is success then automaically the workflow in the pull.yaml in helm repo(my-pull event) will be triggered.&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fa3kauf2xlnw25js972p0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fa3kauf2xlnw25js972p0.png" alt="Image 4" width="800" height="388"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;We can exchange the data here tag of a image is sent from dev repo workflow to helm chart repo.&lt;br&gt;
tag in dev repo -&amp;gt; 20240307130426&lt;br&gt;
tag received by helm chart -&amp;gt;20240307130426&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I hope that this blog will help you by any means.&lt;br&gt;
i have attached my repos for reference&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/Devops-MLOps/chat-app-helm-chart"&gt;https://github.com/Devops-MLOps/chat-app-helm-chart&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/Devops-MLOps/real-time-chat-application"&gt;https://github.com/Devops-MLOps/real-time-chat-application&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Thank you.&lt;/p&gt;

</description>
      <category>githubactions</category>
      <category>github</category>
    </item>
    <item>
      <title>K8s Exercise: Secrets</title>
      <dc:creator>Akshay Rao</dc:creator>
      <pubDate>Sun, 29 Oct 2023 17:14:19 +0000</pubDate>
      <link>https://dev.to/aksrao1998/k8s-exercise-secrets-4lhb</link>
      <guid>https://dev.to/aksrao1998/k8s-exercise-secrets-4lhb</guid>
      <description>&lt;p&gt;&lt;strong&gt;Introduction&lt;/strong&gt;&lt;br&gt;
Hi, I am Akshay Rao, will be starting a exercise series on k8s.&lt;br&gt;
In this blog there will not explanation only problems and solutions.if you want explanation have a look at this series:-&lt;br&gt;
&lt;a href="https://dev.to/aksrao1998/series/24887"&gt;https://dev.to/aksrao1998/series/24887&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Pre-requisite&lt;/strong&gt;&lt;br&gt;
have minikube or kind running in the local machine.&lt;/p&gt;

&lt;p&gt;Note:- k is alias for kubectl.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Problem 1&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create a secret called mysecret with the values password=mypass.&lt;/li&gt;
&lt;li&gt;Create a secret called mysecret2 that gets key/value from a file.&lt;/li&gt;
&lt;li&gt;Get the value of mysecret2&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Solution&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;#1 soln
[k8s-ckad (⎈|minikube:mynamespace)]$ k create secret generic mysecret --from-literal=password=mypass
secret/mysecret created

#2 soln
[k8s-ckad (⎈|minikube:mynamespace)]$ echo -n admin &amp;gt; username
[k8s-ckad (⎈|minikube:mynamespace)]$ k create secret generic mysecret2 --from-file=username
secret/mysecret2 created
[k8s-ckad (⎈|minikube:mynamespace)]$ k get secrets
NAME        TYPE     DATA   AGE
mysecret    Opaque   1      5m32s
mysecret2   Opaque   1      19s

#3 soln
[k8s-ckad (⎈|minikube:mynamespace)]$ k get secret mysecret2 -o yaml
apiVersion: v1
data:
  username: YWRtaW4=
kind: Secret
metadata:
  creationTimestamp: "2023-10-29T16:27:43Z"
  name: mysecret2
  namespace: mynamespace
  resourceVersion: "968"
  uid: 6fa05aa1-fb8e-464e-9a81-11ef9833662a
type: Opaque

# the value of username is coded so need to decode it.
[k8s-ckad (⎈|minikube:mynamespace)]$ k get secret mysecret2 -o jsonpath='{.data.username}' | base64 -D
admin
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Problem 2&lt;/strong&gt;&lt;br&gt;
Create an nginx pod that mounts the secret mysecret2 in a volume on path /etc/foo.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Solution&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;[k8s-ckad (⎈|minikube:mynamespace)]$ k run nginx --image=nginx --dry-run=client -o yaml &amp;gt; pod4.yaml

#edit the pod4.yaml

apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: null
  labels:
    run: nginx
  name: nginx
spec:
  volumes:
    - name: mysecrets
      secret:
        secretName: mysecret2
  containers:
  - image: nginx
    name: pod1
    resources: {}
    volumeMounts:
      - name: mysecrets
        mountPath: /etc/foo
  dnsPolicy: ClusterFirst
  restartPolicy: Always
status: {}
[k8s-ckad (⎈|minikube:mynamespace)]$ k create -f pod4.yaml 
pod/nginx created
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Problem 3&lt;/strong&gt;&lt;br&gt;
Delete the pod you just created and mount the variable 'username' from secret mysecret2 onto a new nginx pod in env variable called 'USERNAME'&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Solution&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;[k8s-ckad (⎈|minikube:mynamespace)]$ k delete pod nginx
pod "nginx" deleted

#edit the pod4.yaml
apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: null
  labels:
    run: nginx
  name: nginx
spec:
  containers:
  - image: nginx
    name: pod1
    env:
      - name: USERNAME
        valueFrom:
          secretKeyRef:
            name: mysecret2
            key: username
    resources: {}
  dnsPolicy: ClusterFirst
  restartPolicy: Always
status: {}
[k8s-ckad (⎈|minikube:mynamespace)]$ k create -f pod4.yaml 
pod/nginx created

[k8s-ckad (⎈|minikube:mynamespace)]$ k exec nginx -- env
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
HOSTNAME=nginx
USERNAME=admin
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Problem&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;See all the service accounts of the cluster in all namespaces.&lt;/li&gt;
&lt;li&gt;Create a new serviceaccount called 'myuser'&lt;/li&gt;
&lt;li&gt;Create an nginx pod that uses 'myuser' as a service account&lt;/li&gt;
&lt;li&gt;Generate an API token for the service account 'myuser'&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Solution&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;#1 soln
[k8s-ckad (⎈|minikube:mynamespace)]$ k get sa
NAME      SECRETS   AGE
default   0         42m

#2 soln
[k8s-ckad (⎈|minikube:mynamespace)]$ k create serviceaccount myuser
serviceaccount/myuser created

#3 soln
edit the pod4.yaml
apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: null
  labels:
    run: nginx
  name: nginx
spec:
  serviceAccountName: myuser
  containers:
  - image: nginx
    name: pod1
    resources: {}
  dnsPolicy: ClusterFirst
  restartPolicy: Always
status: {}
[k8s-ckad (⎈|minikube:mynamespace)]$ k create -f pod4.yaml 
pod/nginx created
[k8s-ckad (⎈|minikube:mynamespace)]$ k describe pod nginx
Name:             nginx
Namespace:        mynamespace
Priority:         0
Service Account:  myuser
Node:             minikube/192.168.49.2
Start Time:       Mon, 30 Oct 2023 02:08:22 +0900

#4 soln
[ts-akshay.rao@JP-FVFZ91DHL414 k8s-ckad (⎈|minikube:mynamespace)]$ k create token myuser
eyJhbGciOiJSUzI1NiIsImtpZCI6IlcyR2FBcUpHb2lreVVfc2ZLOEJlUkZkenpTZHhEY0ZlYU9vWEJrYmVtb0kifQ.eyJhdWQiOlsiaHR0cHM6Ly9rdWJlcm5ldGVzLmRlZmF1bHQuc3ZjLmNsdXN0ZXIubG9jYWwiXSwiZXhwIjoxNjk4NjAzMDk1LCJpYXQiOjE2OTg1OTk0OTUsImlzcyI6Imh0dHBzOi8va3ViZXJuZXRlcy5kZWZhdWx0LnN2Yy5jbHVzdGVyLmxvY2FsIiwia3ViZXJuZXRlcy5pbyI6eyJuYW1lc3BhY2UiOiJteW5hbWVzcGFjZSIsInNlcnZpY2VhY2NvdW50Ijp7Im5hbWUiOiJteXVzZXIiLCJ1aWQiOiIyMTIyZTQxNC03ZjlmLTQxZWUtYjgyNi03MzhlYTgyNTY5MzIifX0sIm5iZiI6MTY5ODU5OTQ5NSwic3ViIjoic3lzdGVtOnNlcnZpY2VhY2NvdW50Om15bmFtZXNwYWNlOm15dXNlciJ9.nC0yOa8TG8xMFKO_tmd9P0Wuzqp2C_yqoziokxAf67Kr9svN_wJWV3hQja4ULl48VTKOOyXopdF4fwbu6QNOnSJR2pHOTAwk9Klav6x3mBRHINQRdoMs8PvmrGNY7zdBB1cM83xHnpV_FxCZ6d-lDNY2gxc8OItCevvgqoh-ZChFXLIrpG6hVR12Q-1KqIntx71Q1l9HhkXvVTaGq-gZpiHgOBMh8n1Vq6fV2GjiB1r5atTlXFrhzM6D2YHkJTEZcTYi4AAVKrAQD-JIzQN0LRBoBWIPMtYOh7RE-IzrGoKgfWmwvHik8lNWS70G8qOvLZGL9R8M2DtrDPbQiZEp7Q

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

&lt;/div&gt;



&lt;p&gt;I hope this helps you in practicing.&lt;br&gt;
Thank you&lt;/p&gt;

</description>
      <category>kubernetes</category>
      <category>tutorial</category>
      <category>beginners</category>
    </item>
    <item>
      <title>K8s Exercise: Pod Placement</title>
      <dc:creator>Akshay Rao</dc:creator>
      <pubDate>Sat, 28 Oct 2023 14:24:05 +0000</pubDate>
      <link>https://dev.to/aksrao1998/k8s-exercise-pod-placement-6fo</link>
      <guid>https://dev.to/aksrao1998/k8s-exercise-pod-placement-6fo</guid>
      <description>&lt;p&gt;&lt;strong&gt;Introduction&lt;/strong&gt;&lt;br&gt;
Hi, I am Akshay Rao, will be starting a exercise series on k8s.&lt;br&gt;
In this blog there will not explanation only problems and solutions.if you want explanation have a look at this series:-&lt;br&gt;
&lt;a href="https://dev.to/aksrao1998/series/24887"&gt;https://dev.to/aksrao1998/series/24887&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Pre-requisite&lt;/strong&gt;&lt;br&gt;
have minikube or kind running in the local machine.&lt;/p&gt;

&lt;p&gt;Note:- k is alias for kubectl.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Problem 1&lt;/strong&gt;&lt;br&gt;
Create a pod that will be deployed to a Node that has the label 'accelerator=nvidia-tesla-p100'&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Solution&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;[~ (⎈|minikube:mynamespace)]$ k label node minikube accelerator=nvidia-tesla-p100
node/minikube labeled
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Problem 2&lt;/strong&gt;&lt;br&gt;
Taint a node with key tier and value frontend with the effect NoSchedule. Then, create a pod that tolerates this taint.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Solution&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;
[~ (⎈|minikube:mynamespace)]$ k taint nodes minikube tier=frontend:NoSchedule
node/minikube tainted
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;i hope this helps you&lt;br&gt;
Thank you&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>kubernetes</category>
      <category>devops</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>K8s Exercise : Labels and Annotations</title>
      <dc:creator>Akshay Rao</dc:creator>
      <pubDate>Sat, 28 Oct 2023 01:53:03 +0000</pubDate>
      <link>https://dev.to/aksrao1998/k8s-exercise-labels-and-annotations-3nl0</link>
      <guid>https://dev.to/aksrao1998/k8s-exercise-labels-and-annotations-3nl0</guid>
      <description>&lt;p&gt;&lt;strong&gt;Introduction&lt;/strong&gt;&lt;br&gt;
Hi, I am Akshay Rao, will be starting a exercise series on k8s.&lt;br&gt;
In this blog there will not explanation only problems and solutions.if you want explanation have a look at this series:-&lt;br&gt;
&lt;a href="https://dev.to/aksrao1998/series/24887"&gt;https://dev.to/aksrao1998/series/24887&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Pre-requisite&lt;/strong&gt;&lt;br&gt;
have minikube or kind running in the local machine.&lt;/p&gt;

&lt;p&gt;Note:- k is alias for kubectl.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Let's Start&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Problem&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create 3 pods with names nginx1,nginx2,nginx3. All of them should have the label app=v1.&lt;/li&gt;
&lt;li&gt;Show all labels of the pods.&lt;/li&gt;
&lt;li&gt;Change the labels of pod 'nginx2' to be app=v2.&lt;/li&gt;
&lt;li&gt;Get the label 'app' for the pods (show a column with APP labels).&lt;/li&gt;
&lt;li&gt;Get only the 'app=v2' pods&lt;/li&gt;
&lt;li&gt;Add a new label tier=web to all pods having 'app=v2' or 'app=v1' labels.&lt;/li&gt;
&lt;li&gt;Add an annotation 'owner: marketing' to all pods having 'app=v2' label.&lt;/li&gt;
&lt;li&gt;Remove the 'app' label from the pods we created before.&lt;/li&gt;
&lt;li&gt;Annotate pods nginx1, nginx2, nginx3 with "description='mydescription'" value.&lt;/li&gt;
&lt;li&gt;Check the annotations for pod nginx1.&lt;/li&gt;
&lt;li&gt;Remove the annotations for these three pods.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Solution&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;#1 Soln
[ ~ (⎈|minikube:mynamespace)]$ k run nginx1 --image=nginx -l app=v1
pod/nginx1 created
[~ (⎈|minikube:mynamespace)]$ k run nginx2 --image=nginx -l app=v1
pod/nginx2 created
[~ (⎈|minikube:mynamespace)]$ k run nginx3 --image=nginx -l app=v1
pod/nginx3 created

#2 Soln
[~ (⎈|minikube:mynamespace)]$ k get po -l app=v1
NAME     READY   STATUS    RESTARTS   AGE
nginx1   1/1     Running   0          2m11s
nginx2   1/1     Running   0          2m4s
nginx3   1/1     Running   0          115s

#3 Soln
[~ (⎈|minikube:mynamespace)]$ k label pod nginx2 app=v2 --overwrite
pod/nginx2 labeled

#4 Soln
[ ~ (⎈|minikube:mynamespace)]$ k get po -l app
NAME     READY   STATUS    RESTARTS   AGE
nginx1   1/1     Running   0          16m
nginx2   1/1     Running   0          16m
nginx3   1/1     Running   0          16m

#5 Soln
[ ~ (⎈|minikube:mynamespace)]$ k get po -l app=v2
NAME     READY   STATUS    RESTARTS   AGE
nginx2   1/1     Running   0          14m

#6 Soln
[~ (⎈|minikube:mynamespace)]$ k label po -l "app in (v1.v2)" teir=web

#7 Soln
[~ (⎈|minikube:mynamespace)]$ k annotate po -l "app=v2" owner=marketing
pod/nginx2 annotated

#8 Soln
[~ (⎈|minikube:mynamespace)]$ k label po nginx{1..3} app-
pod/nginx1 unlabeled
pod/nginx2 unlabeled
pod/nginx3 unlabeled

#9 Soln
[~ (⎈|minikube:mynamespace)]$ k annotate po nginx{1..3} description=mydescription
pod/nginx1 annotated
pod/nginx2 annotated
pod/nginx3 annotated

#10 Soln
[~ (⎈|minikube:mynamespace)]$ k annotate po nginx1 --list
description=mydescription

#11 Soln
[ts-akshay.rao@JP-FVFZ91DHL414 ~ (⎈|minikube:mynamespace)]$ k annotate po nginx{1..3} description-
pod/nginx1 annotated
pod/nginx2 annotated
pod/nginx3 annotated

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

&lt;/div&gt;



</description>
      <category>kubernetes</category>
      <category>devops</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Automate the deletion of old screenshots.</title>
      <dc:creator>Akshay Rao</dc:creator>
      <pubDate>Sat, 21 Oct 2023 09:35:44 +0000</pubDate>
      <link>https://dev.to/aksrao1998/automate-the-deletion-of-old-screenshots-153l</link>
      <guid>https://dev.to/aksrao1998/automate-the-deletion-of-old-screenshots-153l</guid>
      <description>&lt;p&gt;&lt;strong&gt;Introduction&lt;/strong&gt;&lt;br&gt;
Hi, This is Akshay Rao, in my daily work life I have to take a lot of screenshot for documentation purpose.So, there were so many screenshots and had to delete only other days screenshots, so every day I had to delete them manually.&lt;br&gt;
So, I thought of automating the deletion of screenshots at 5PM everyday.&lt;br&gt;
In this blog will share how i did this.I hope this will help you also.&lt;br&gt;
&lt;strong&gt;Lets's start&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt; made a file name screenshot-deletion.py &lt;/li&gt;
&lt;li&gt;we will have to know the path where all the screenshots are saved.&lt;/li&gt;
&lt;li&gt;now identify the dates that are attached in the name of the screenshot.&lt;/li&gt;
&lt;li&gt;Identify the dates first with regular expressions.&lt;/li&gt;
&lt;li&gt;now one by one compare the date with the current date, then delete them.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import os
import re
from datetime import datetime

#set path where all the screenshots are saved
folder_path = "put/path/folder"

files = os.listdir(folder_path)
current_date = datetime.now().date()

#pattern for date to recognize
date_pattern=r"\d{4}-\d{2}-\d{2}"

#print(current_date)
#print(folder_path)

for file in files:
    file_path=os.path.join(folder_path, file)
    #print(file_path)
    if os.path.isfile(file_path):
        screenshots=re.search(date_pattern, file_path)
        if screenshots:
            if screenshots.group() != current_date:
                try:
                    print("removing this file:", file)
                    os.remove(file_path)
                except Exception as e:
                    print("cannot delete this file - {e}")
        else:
            print("screenshots don't exist")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;edit the &lt;strong&gt;crontab -e&lt;/strong&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;00 17 * * * /usr/bin/python3 /path/to/your/script.py
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;i hope that this helps you by any means.&lt;br&gt;
&lt;strong&gt;Thank you&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>python</category>
      <category>beginners</category>
      <category>programming</category>
    </item>
    <item>
      <title>K8s Exercise: Persistent State</title>
      <dc:creator>Akshay Rao</dc:creator>
      <pubDate>Wed, 18 Oct 2023 13:58:36 +0000</pubDate>
      <link>https://dev.to/aksrao1998/k8s-exercise-part-4-2ie1</link>
      <guid>https://dev.to/aksrao1998/k8s-exercise-part-4-2ie1</guid>
      <description>&lt;p&gt;&lt;strong&gt;Introduction&lt;/strong&gt;&lt;br&gt;
Hi, I am Akshay Rao, will be starting a exercise series on k8s.&lt;br&gt;
In this blog there will not explanation only problems and solutions.if you want explanation have a look at this series:-&lt;br&gt;
&lt;a href="https://dev.to/aksrao1998/series/24887"&gt;https://dev.to/aksrao1998/series/24887&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Pre-requisite&lt;/strong&gt;&lt;br&gt;
have minikube or kind running in the local machine.&lt;/p&gt;

&lt;p&gt;Note:- k is alias for kubectl.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Let's Start&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Problem 1&lt;/strong&gt;&lt;br&gt;
Create busybox pod with two containers, each one will have the image busybox and will run the 'sleep 3600' command. Make both containers mount an emptyDir at '/etc/foo'. Connect to the second busybox, write the first column of '/etc/passwd' file to '/etc/foo/passwd'. Connect to the first busybox and write '/etc/foo/passwd' file to standard output. Delete pod.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Solution&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;[k8s-ckad (⎈|minikube:mynamespace)]$ k run busybox --image=busybox --dry-run=client -o yaml &amp;gt; pod2.yaml

#edit the pod2.yaml

apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: null
  labels:
    run: busybox
  name: busybox
spec:
  dnsPolicy: ClusterFirst
  restartPolicy: Never
  containers:
  - image: busybox
    name: busybox0
    command: ["/bin/sh","-c","sleep 3600"]
    volumeMounts:
    - mountPath: /etc/foo
      name: anyvolume
    resources: {}
  - image: busybox
    name: busybox1
    command: ["/bin/sh","-c","sleep 3600"]
    volumeMounts:
    - mountPath: /etc/foo
      name: anyvolume
    resources: {}
  dnsPolicy: ClusterFirst
  restartPolicy: Always
  volumes:
  - name: anyvolume
    emptyDir: {}
status: {}

[k8s-ckad (⎈|minikube:mynamespace)]$ k create -f pod2.yaml
pod/busybox created

# login in container
[k8s-ckad (⎈|minikube:mynamespace)]$ k exec -it busybox -c busybox0  -- /bin/sh
/etc # cd /etc/foo/
/etc/foo # ls
/etc/foo # cat /etc/passwd 
root:x:0:0:root:/root:/bin/sh
daemon:x:1:1:daemon:/usr/sbin:/bin/false
bin:x:2:2:bin:/bin:/bin/false
sys:x:3:3:sys:/dev:/bin/false
sync:x:4:100:sync:/bin:/bin/sync
mail:x:8:8:mail:/var/spool/mail:/bin/false
www-data:x:33:33:www-data:/var/www:/bin/false
operator:x:37:37:Operator:/var:/bin/false
nobody:x:65534:65534:nobody:/home:/bin/false
/etc/foo # cat /etc/passwd | awk '{print $1}' &amp;gt; /etc/foo/passwd
/etc/foo # ls
passwd
/etc/foo # cat passwd 
root:x:0:0:root:/root:/bin/sh
daemon:x:1:1:daemon:/usr/sbin:/bin/false
bin:x:2:2:bin:/bin:/bin/false
sys:x:3:3:sys:/dev:/bin/false
sync:x:4:100:sync:/bin:/bin/sync
mail:x:8:8:mail:/var/spool/mail:/bin/false
www-data:x:33:33:www-data:/var/www:/bin/false
operator:x:37:37:Operator:/var:/bin/false
nobody:x:65534:65534:nobody:/home:/bin/false
/etc/foo # 

# verify this is updated in the other container automatically 

[k8s-ckad (⎈|minikube:mynamespace)]$ k exec -it busybox -c busybox1  -- /bin/sh
/ # 
/ # cat /etc/foo/passwd 
root:x:0:0:root:/root:/bin/sh
daemon:x:1:1:daemon:/usr/sbin:/bin/false
bin:x:2:2:bin:/bin:/bin/false
sys:x:3:3:sys:/dev:/bin/false
sync:x:4:100:sync:/bin:/bin/sync
mail:x:8:8:mail:/var/spool/mail:/bin/false
www-data:x:33:33:www-data:/var/www:/bin/false
operator:x:37:37:Operator:/var:/bin/false
nobody:x:65534:65534:nobody:/home:/bin/false
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Problem 2&lt;/strong&gt;&lt;br&gt;
Create a PersistentVolume of 10Gi, called 'myvolume'. Make it have accessMode of 'ReadWriteOnce' and 'ReadWriteMany', storageClassName 'normal', mounted on hostPath '/etc/foo'. Save it on pv.yaml, add it to the cluster. Show the PersistentVolumes that exist on the cluster.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Solution&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;# create a file name pv.yaml
apiVersion: v1
kind: PersistentVolume
metadata:
  name: myvolume
spec:
  capacity:
    storage: 10Gi
  accessModes:
    - ReadWriteOnce
    - ReadWriteMany
  persistentVolumeReclaimPolicy: Recycle
  storageClassName: normal
  hostPath:
    path: /etc/foo

# verify
[k8s-ckad (⎈|minikube:mynamespace)]$ k get pv
NAME       CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS      CLAIM   STORAGECLASS   REASON   AGE
myvolume   10Gi       RWO,RWX        Recycle          Available           normal                  32s
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Problem 3&lt;/strong&gt;&lt;br&gt;
Create a PersistentVolumeClaim for this storage class, called 'mypvc', a request of 4Gi and an accessMode of ReadWriteOnce, with the storageClassName of normal, and save it on pvc.yaml. Create it on the cluster. Show the PersistentVolumeClaims of the cluster.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Solution&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;# create a pvc.yaml file
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: mypvc
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 4Gi
  storageClassName: normal

# verify
[k8s-ckad (⎈|minikube:mynamespace)]$ k create -f pvc.yaml
persistentvolumeclaim/mypvc created
[k8s-ckad (⎈|minikube:mynamespace)]$ k get pvc
NAME    STATUS   VOLUME     CAPACITY   ACCESS MODES   STORAGECLASS   AGE
mypvc   Bound    myvolume   10Gi       RWO,RWX        normal         5s
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Problem 3&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Create a busybox pod with command 'sleep 3600', save it on pod.yaml. Mount the PersistentVolumeClaim to '/etc/foo'. Connect to the 'busybox' pod, and copy the '/etc/passwd' file to '/etc/foo/passwd'.
&lt;/li&gt;
&lt;li&gt;Create a second pod which is identical with the one you just created (you can easily do it by changing the 'name' property on pod.yaml). Connect to it and verify that '/etc/foo' contains the 'passwd' file. Delete pods to cleanup. Note: If you can't see the file from the second pod, can you figure out why? What would you do to fix that?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Solution&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;Part-1

apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: null
  labels:
    run: busybox
  name: busybox
spec:
  dnsPolicy: ClusterFirst
  restartPolicy: Never
  containers:
  - image: busybox
    name: busybox0
    command: ["/bin/sh","-c","sleep 3600"]
    volumeMounts:
    - mountPath: /etc/foo
      name: anyvolume
    resources: {}
  dnsPolicy: ClusterFirst
  restartPolicy: Always
  volumes:
    - name: anyvolume
      persistentVolumeClaim:
        claimName: mypvc
status: {}

[k8s-ckad (⎈|minikube:mynamespace)]$ k create -f pod.yaml
pod/busybox created

Copy the passwd file
[k8s-ckad (⎈|minikube:mynamespace)]$ k exec -it busybox -- /bin/sh 
/ # cp /etc/passwd /etc/foo/
/ # ls /etc/foo
passwd

Part-2
# change the labels to busybox1
apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: null
  labels:
    run: busybo1
  name: busybox1
spec:
  dnsPolicy: ClusterFirst
  restartPolicy: Never
  containers:
  - image: busybox
    name: busybox1
    command: ["/bin/sh","-c","sleep 3600"]
    volumeMounts:
    - mountPath: /etc/foo
      name: anyvolume
    resources: {}
  dnsPolicy: ClusterFirst
  restartPolicy: Always
  volumes:
    - name: anyvolume
      persistentVolumeClaim:
        claimName: mypvc
status: {}

[k8s-ckad (⎈|minikube:mynamespace)]$ k create -f pod3.yaml
pod/busybox1 created

#verify 

[k8s-ckad (⎈|minikube:mynamespace)]$ k exec -it busybox1 -- /bin/sh
/ # 
/ # ls /etc/foo
passwd
/ # 

# delete the resources

[k8s-ckad (⎈|minikube:mynamespace)]$ k delete po  busybox
pod "busybox" deleted
[k8s-ckad (⎈|minikube:mynamespace)]$ k delete po  busybox1
pod "busybox1" deleted
[k8s-ckad (⎈|minikube:mynamespace)]$ k delete pv myvolume
persistentvolume "myvolume" deleted
[k8s-ckad (⎈|minikube:mynamespace)]$ k delete pvc mypvc
persistentvolumeclaim "mypvc" deleted

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

&lt;/div&gt;



</description>
      <category>kubernetes</category>
      <category>devops</category>
      <category>beginners</category>
    </item>
    <item>
      <title>K8s Exercise: ConfigMaps</title>
      <dc:creator>Akshay Rao</dc:creator>
      <pubDate>Mon, 16 Oct 2023 04:29:15 +0000</pubDate>
      <link>https://dev.to/aksrao1998/k8s-exercise-part-3-4ji</link>
      <guid>https://dev.to/aksrao1998/k8s-exercise-part-3-4ji</guid>
      <description>&lt;p&gt;&lt;strong&gt;Introduction&lt;/strong&gt;&lt;br&gt;
Hi, I am Akshay Rao, will be starting a exercise series on k8s.&lt;br&gt;
In this blog there will not explanation only problems and solutions.if you want explanation have a look at this series:-&lt;br&gt;
&lt;a href="https://dev.to/aksrao1998/series/24887"&gt;https://dev.to/aksrao1998/series/24887&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Pre-requisite&lt;/strong&gt;&lt;br&gt;
have minikube or kind running in the local machine.&lt;/p&gt;

&lt;p&gt;Note:- k is alias for kubectl.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Let's Start&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Problem 1&lt;/strong&gt;&lt;br&gt;
Create a configMap called 'options' with the value var1=val1. Create a new nginx pod that loads the value from variable 'var5' in an env variable called 'option'&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Solution&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;# create a configmap
[k8s-ckad (⎈|minikube:hands-on)]$ k create configmap options --from-literal=val1=val1 --dry-run=client -o yaml &amp;gt; options.yaml

[k8s-ckad (⎈|minikube:mynamespace)]$ k create -f options.yaml 
configmap/options created
[k8s-ckad (⎈|minikube:mynamespace)]$ k get cm
NAME               DATA   AGE
kube-root-ca.crt   1      3d19h
options            1      5s

# create a pod
[k8s-ckad (⎈|minikube:mynamespace)]$ k run nginx --image=nginx --dry-run=client -o yaml &amp;gt; pods.yaml

#edit the pods.yaml
apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: null
  labels:
    run: nginx
  name: nginx
  namespace: mynamespace 
spec:
  containers:
  - image: nginx
    name: nginx
    env:
      - name: options
        valueFrom:
          configMapKeyRef:
            name: options
            key: val1
    resources: {}
  dnsPolicy: ClusterFirst
  restartPolicy: Always
status: {}

[k8s-ckad (⎈|minikube:mynamespace)]$ k create -f pods.yaml 
pod/nginx created
[ts-akshay.rao@JP-FVFZ91DHL414 k8s-ckad (⎈|minikube:mynamespace)]$ k get po
NAME    READY   STATUS    RESTARTS   AGE
nginx   1/1     Running   0          3m53s

#verify

[k8s-ckad (⎈|minikube:mynamespace)]$ k exec -it nginx -- env
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
HOSTNAME=nginx
TERM=xterm
options=val1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Problem 2&lt;/strong&gt;&lt;br&gt;
Create a configMap 'anotherone' with values 'var2=val2', 'var3=val3'. Load this configMap as env variables into a new nginx pod&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Solution&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;# create another cm
[k8s-ckad (⎈|minikube:mynamespace)]$ k create cm anotherone --from-literal=val2=val2 --from-literal=val3=val3
configmap/anotherone created

#edit the pods.yaml
apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: null
  labels:
    run: nginx
  name: nginx
  namespace: mynamespace 
spec:
  containers:
  - image: nginx
    name: nginx
    envFrom:
    - configMapRef:
        name: anotherone
  dnsPolicy: ClusterFirst
  restartPolicy: Always
status: {}

[k8s-ckad (⎈|minikube:mynamespace)]$ k create -f pods.yaml 
pod/nginx created
[k8s-ckad (⎈|minikube:mynamespace)]$ k get po
NAME    READY   STATUS    RESTARTS   AGE
nginx   1/1     Running   0          35s

# verify
[k8s-ckad (⎈|minikube:mynamespace)]$ k exec -it nginx -- env
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
HOSTNAME=nginx
TERM=xterm
val2=val2
val3=val3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Problem 3&lt;/strong&gt;&lt;br&gt;
Create a configMap 'cmvolume' with values 'var4=val4', 'var5=val5'. Load this as a volume inside an nginx pod on path '/etc/lala'. Create the pod and 'ls' into the '/etc/lala' directory.&lt;br&gt;
&lt;strong&gt;Solution&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;[k8s-ckad (⎈|minikube:mynamespace)]$ k create cm cmvolume --from-literal=val4=val4 --from-literal=val5=val5
configmap/cmvolume created

# edit the pods.yaml
apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: null
  labels:
    run: nginx
  name: nginx
  namespace: mynamespace 
spec:
  containers:
  - image: nginx
    name: nginx
    volumeMoints:
    - name: cm-volume
      mountPath: /etc/lala
  dnsPolicy: ClusterFirst
  restartPolicy: Always
  volumes:
    - name: cm-volume
      configMap:
        name: cmvolume
status: {}

[k8s-ckad (⎈|minikube:mynamespace)]$ k create -f pods.yaml 
pod/nginx created

# verify
[k8s-ckad (⎈|minikube:mynamespace)]$ k exec -it nginx bash
kubectl exec [POD] [COMMAND] is DEPRECATED and will be removed in a future version. Use kubectl exec [POD] -- [COMMAND] instead.
root@nginx:/# cd /etc/lala
root@nginx:/etc/lala# ls
val4  val5

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

&lt;/div&gt;



</description>
      <category>devops</category>
      <category>kubernetes</category>
      <category>docker</category>
      <category>beginners</category>
    </item>
    <item>
      <title>K8s Exercise: Multi-container</title>
      <dc:creator>Akshay Rao</dc:creator>
      <pubDate>Sat, 14 Oct 2023 07:04:40 +0000</pubDate>
      <link>https://dev.to/aksrao1998/k8s-exercise-part-2-2647</link>
      <guid>https://dev.to/aksrao1998/k8s-exercise-part-2-2647</guid>
      <description>&lt;p&gt;&lt;strong&gt;Introduction&lt;/strong&gt;&lt;br&gt;
Hi, I am Akshay Rao, will be starting a exercise series on k8s.&lt;br&gt;
In this blog there will not explanation only problems and solutions.if you want explanation have a look at this series:-&lt;br&gt;
&lt;a href="https://dev.to/aksrao1998/series/24887"&gt;https://dev.to/aksrao1998/series/24887&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Pre-requisite&lt;/strong&gt;&lt;br&gt;
have minikube or kind running in the local machine.&lt;/p&gt;

&lt;p&gt;Note:- k is alias for kubectl.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Let's Start&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Problem&lt;/strong&gt;&lt;br&gt;
Create a pod with an nginx container exposed on port 80. Add a busybox init container which downloads a page using "wget -O /work-dir/index.html &lt;a href="http://neverssl.com/online"&gt;http://neverssl.com/online&lt;/a&gt;". Make a volume of type emptyDir and mount it in both containers. For the nginx container, mount it on "/usr/share/nginx/html" and for the initcontainer, mount it on "/work-dir". When done, get the IP of the created pod and create a busybox pod and run "wget -O- IP"&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Solution&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;k run multi-container --image=nginx --dry-run=client -o yaml &amp;gt; multi-container.yaml

apiVersion: v1
kind: Pod
metadata:
  labels:
    run: multi-container
  name: multi-container
spec:
  initContainers: 
  - args: 
    - /bin/sh 
    - -c 
    - "wget -O /work-dir/index.html http://neverssl.com/online"
    image: busybox 
    name: box 
    volumeMounts: 
    - name: vol 
      mountPath: /work-dir 
  containers:
  - image: nginx
    name: nginx
    ports:
    - containerPort: 80
    volumeMounts: 
    - name: vol 
      mountPath: /usr/share/nginx/html 
  volumes: 
  - name: vol 
    emptyDir: {}

[k8s-ckad (⎈|minikube:hands-on)]$ k create -f multi-container.yaml 
pod/multi-container created
[k8s-ckad (⎈|minikube:hands-on)]$ k get po -o wide
NAME              READY   STATUS    RESTARTS   AGE   IP           NODE       NOMINATED NODE   READINESS GATES
multi-container   1/1     Running   0          84s   172.17.0.4   minikube   &amp;lt;none&amp;gt;           &amp;lt;none&amp;gt;

#verify

[k8s-ckad (⎈|minikube:hands-on)]$ k run test --image=busybox --restart=Never -it -- /bin/sh -c "wget -O- $(kubectl get pod multi-container -o jsonpath='{.status.podIP}')"
Connecting to 172.17.0.4 (172.17.0.4:80)
writing to stdout
&amp;lt;html&amp;gt;
        &amp;lt;head&amp;gt;
                &amp;lt;title&amp;gt;NeverSSL - helping you get online&amp;lt;/title&amp;gt;

                &amp;lt;style&amp;gt;
                body {
                        font-family: Montserrat, helvetica, arial, sans-serif; 
                        font-size: 16x;
                        color: #444444;
                        margin: 0;
                }
                h2 {
                        font-weight: 700;
                        font-size: 1.6em;
                        margin-top: 30px;
                }
                p {
                        line-height: 1.6em;
                }
                .container {
                        max-width: 650px;
                        margin: 20px auto 20px auto;
                        padding-left: 15px;
                        padding-right: 15px
                }
                .header {
                        background-color: #42C0FD;
                        color: #FFFFFF;
                        padding: 10px 0 10px 0;
                        font-size: 2.2em;
                }
                &amp;lt;!-- CSS from Mark Webster https://gist.github.com/markcwebster/9bdf30655cdd5279bad13993ac87c85d --&amp;gt;
                &amp;lt;/style&amp;gt;
        &amp;lt;/head&amp;gt;
        &amp;lt;body&amp;gt;

        &amp;lt;div class="header"&amp;gt;
                &amp;lt;div class="container"&amp;gt;
                &amp;lt;h1&amp;gt;NeverSSL&amp;lt;/h1&amp;gt;
                &amp;lt;/div&amp;gt;
        &amp;lt;/div&amp;gt;

        &amp;lt;div class="content"&amp;gt;
        &amp;lt;div class="container"&amp;gt;

        &amp;lt;h2&amp;gt;What?&amp;lt;/h2&amp;gt;
        &amp;lt;p&amp;gt;This website is for when you try to open Facebook, Google, Amazon, etc
        on a wifi network, and nothing happens. Type "http://neverssl.com"
        into your browser's url bar, and you'll be able to log on.&amp;lt;/p&amp;gt;

        &amp;lt;h2&amp;gt;How?&amp;lt;/h2&amp;gt;
        &amp;lt;p&amp;gt;neverssl.com will never use SSL (also known as TLS). No
        encryption, no strong authentication, no &amp;lt;a
        href="https://en.wikipedia.org/wiki/HTTP_Strict_Transport_Security"&amp;gt;HSTS&amp;lt;/a&amp;gt;,
        no HTTP/2.0, just plain old unencrypted HTTP and forever stuck in the dark
        ages of internet security.&amp;lt;/p&amp;gt; 

        &amp;lt;h2&amp;gt;Why?&amp;lt;/h2&amp;gt;
        &amp;lt;p&amp;gt;Normally, that's a bad idea. You should always use SSL and secure
        encryption when possible. In fact, it's such a bad idea that most websites
        are now using https by default.&amp;lt;/p&amp;gt;

        &amp;lt;p&amp;gt;And that's great, but it also means that if you're relying on
        poorly-behaved wifi networks, it can be hard to get online.  Secure
        browsers and websites using https make it impossible for those wifi
        networks to send you to a login or payment page. Basically, those networks
        can't tap into your connection just like attackers can't. Modern browsers
        are so good that they can remember when a website supports encryption and
        even if you type in the website name, they'll use https.&amp;lt;/p&amp;gt; 

        &amp;lt;p&amp;gt;And if the network never redirects you to this page, well as you can
        see, you're not missing much.&amp;lt;/p&amp;gt;

        &amp;lt;a href="https://twitter.com/neverssl"&amp;gt;Follow @neverssl&amp;lt;/a&amp;gt;

        &amp;lt;/div&amp;gt;
        &amp;lt;/div&amp;gt;
        &amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
-                    100% |********************************|  2238  0:00:00 ETA
written to stdout

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

&lt;/div&gt;



</description>
      <category>beginners</category>
      <category>kubernetes</category>
      <category>devops</category>
    </item>
    <item>
      <title>K8s Exercise : Core Concepts</title>
      <dc:creator>Akshay Rao</dc:creator>
      <pubDate>Thu, 12 Oct 2023 08:39:36 +0000</pubDate>
      <link>https://dev.to/aksrao1998/k8s-exercise-part-1-2jbn</link>
      <guid>https://dev.to/aksrao1998/k8s-exercise-part-1-2jbn</guid>
      <description>&lt;p&gt;&lt;strong&gt;Introduction&lt;/strong&gt;&lt;br&gt;
Hi, I am Akshay Rao, will be starting a exercise series on k8s.&lt;br&gt;
In this blog there will not explanation only problems and solutions.if you want explanation have a look at this series:-&lt;br&gt;
&lt;a href="https://dev.to/aksrao1998/series/24887"&gt;https://dev.to/aksrao1998/series/24887&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Pre-requisite&lt;/strong&gt;&lt;br&gt;
have minikube or kind running in the local machine.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;:- k is alias for kubectl.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Let's Start&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Problem 1&lt;/strong&gt;&lt;br&gt;
Create a namespace called 'mynamespace' and a pod with image nginx called nginx on this namespace.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Solution&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;[k8s-ckad (⎈|minikube:default)]$ k get ns
NAME              STATUS   AGE
default           Active   9d
hands-on          Active   9d
kube-node-lease   Active   9d
kube-public       Active   9d
kube-system       Active   9d

[k8s-ckad (⎈|minikube:default)]$ k create namespace mynamespace
namespace/mynamespace created
[k8s-ckad (⎈|minikube:default)]$ k config set-context --current --namespace=mynamespace
Context "minikube" modified.

# deploy a pod
[k8s-ckad (⎈|minikube:mynamespace)]$ kubectl run nginx --image=nginx --dry-run=client -o yaml &amp;gt; pods.yaml

# edit the pods.yaml
metadata:
  creationTimestamp: null
  labels:
    run: nginx
  name: nginx
  namespace: mynamespace 

# verify
[k8s-ckad (⎈|minikube:mynamespace)]$ k create -f pods.yaml 
pod/nginx created
[k8s-ckad (⎈|minikube:mynamespace)]$ k get po
NAME    READY   STATUS    RESTARTS   AGE
nginx   1/1     Running   0          6s

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Problem 2&lt;/strong&gt;&lt;br&gt;
Create a busybox pod (using kubectl command) that runs the command "env". Run it and see the output.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Solution&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;[k8s-ckad (⎈|minikube:mynamespace)]$ k run soln2 --image=busybox --command --restart=Never -it --rm -- env
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
HOSTNAME=soln2
TERM=xterm
KUBERNETES_PORT_443_TCP_PROTO=tcp
KUBERNETES_PORT_443_TCP_PORT=443
KUBERNETES_PORT_443_TCP_ADDR=10.96.0.1
KUBERNETES_SERVICE_HOST=10.96.0.1
KUBERNETES_SERVICE_PORT=443
KUBERNETES_SERVICE_PORT_HTTPS=443
KUBERNETES_PORT=tcp://10.96.0.1:443
KUBERNETES_PORT_443_TCP=tcp://10.96.0.1:443
HOME=/root
pod "soln2" deleted
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Problem 3&lt;/strong&gt;&lt;br&gt;
Create the YAML for a new ResourceQuota called 'myrq' with hard limits of 1 CPU, 1G memory and 2 pods without creating it&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Solution&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;[k8s-ckad (⎈|minikube:mynamespace)]$ k create quota myrq  --hard=cpu=1,memory=1G,pods=2 --dry-run=client -o y
aml
apiVersion: v1
kind: ResourceQuota
metadata:
  creationTimestamp: null
  name: myrq
spec:
  hard:
    cpu: "1"
    memory: 1G
    pods: "2"
status: {}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Problem 4&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Create a pod with image nginx:1.25.1 called nginx and expose traffic on port 80&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Solution&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;[k8s-ckad (⎈|minikube:mynamespace)]$ k run  mypod --image=nginx:1.25.1 --port=80
pod/mypod created

#Verify

[k8s-ckad (⎈|minikube:mynamespace)]$ k get po
NAME    READY   STATUS              RESTARTS   AGE
mypod   0/1     ContainerCreating   0          4s
nginx   1/1     Running             0          20m

[k8s-ckad (⎈|minikube:mynamespace)]$ k exec -it mypod bash -- nginx -v
nginx version: nginx/1.25.1

[k8s-ckad (⎈|minikube:mynamespace)]$ k describe pods mypod
Name:             mypod
Namespace:        mynamespace
Priority:         0
Service Account:  default
Node:             minikube/192.168.49.2
Start Time:       Thu, 12 Oct 2023 17:33:46 +0900
Labels:           run=mypod
Annotations:      &amp;lt;none&amp;gt;
Status:           Running
IP:               172.17.0.4
IPs:
  IP:  172.17.0.4
Containers:
  mypod:
    Container ID:   docker://147821ce3a12c57d9fef21026a57fcd0cee71360b411275db391a3dcccc25270
    Image:          nginx:1.25.1
    Image ID:       docker-pullable://nginx@sha256:67f9a4f10d147a6e04629340e6493c9703300ca23a2f7f3aa56fe615d75d31ca
    Port:           80/TCP
    Host Port:      0/TCP
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I hope this blog exercise has helped you.&lt;br&gt;
&lt;strong&gt;Thank you&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>kubernetes</category>
      <category>opensource</category>
      <category>devops</category>
    </item>
    <item>
      <title>K8s Hands-On: Probes</title>
      <dc:creator>Akshay Rao</dc:creator>
      <pubDate>Thu, 12 Oct 2023 07:38:04 +0000</pubDate>
      <link>https://dev.to/aksrao1998/k8s-hands-on-probes-3cbm</link>
      <guid>https://dev.to/aksrao1998/k8s-hands-on-probes-3cbm</guid>
      <description>&lt;p&gt;&lt;strong&gt;Introduction&lt;/strong&gt;&lt;br&gt;
Hi, I am Akshay Rao. This series will help you in hands on experience with Kubernetes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Pre-requisites&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Understand of deployment and pods.&lt;/li&gt;
&lt;li&gt;minikube running.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Agenda&lt;/strong&gt;&lt;br&gt;
In this blog we will understand about the probes, what are they, why are they used.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Let's Start&lt;/strong&gt;&lt;br&gt;
What and Why  are probes in k8s?&lt;br&gt;
We need to check the application containers are running properly before exposing it to the real world. These check are called probes. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;readiness probe&lt;/strong&gt;&lt;br&gt;
When an application might need to load large data or configuration files during startup, or depend on external services after startup then readiness probe is used.&lt;br&gt;
Let's understand through hands on&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;create a pod.
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;apiVersion: v1
kind: Pod
metadata:
  name: pod1 
spec:
  containers:
  - name: probes
    image: nginx
    livenessProbe:
      exec:
        command:
        - cat
        - /tmp/healthy
      initialDelaySeconds: 5   # delay of 5 sec for 1st probe 
      periodSeconds: 5.      # every 5 sec the probe will run 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;deploy it
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[ k8s-ckad (⎈|minikube:hands-on)]$ k create -f pod1.yaml 
pod/pod1 created
[ k8s-ckad (⎈|minikube:hands-on)]$ k get po
NAME   READY   STATUS              RESTARTS   AGE
pod1   0/1     ContainerCreating   0          3s
[ k8s-ckad (⎈|minikube:hands-on)]$ k get po
NAME   READY   STATUS    RESTARTS   AGE
pod1   0/1     Running   0          7s
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;you can see that the pods is not ready(0/1) that can verify it by describing the events.
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Conditions:
  Type              Status
  Initialized       True 
  Ready             False 
  ContainersReady   False 
  PodScheduled      True
Events:
  Type     Reason     Age                From               Message
  ----     ------     ----               ----               -------
  Normal   Scheduled  98s                default-scheduler  Successfully assigned hands-on/pod1 to minikube
  Normal   Pulling    97s                kubelet            Pulling image "nginx"
  Normal   Pulled     95s                kubelet            Successfully pulled image "nginx" in 1.895668441s
  Normal   Created    95s                kubelet            Created container probes
  Normal   Started    95s                kubelet            Started container probes
  Warning  Unhealthy  3s (x19 over 88s)  kubelet            Readiness probe failed: cat: /tmp/healthy: No such file or directory
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;it says that the healthy directory doesn’t exist. now get in the pod and make a directory called healthy
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[ k8s-ckad (⎈|minikube:hands-on)]$ kubectl exec -it pod1 bash
kubectl exec [POD] [COMMAND] is DEPRECATED and will be removed in a future version. Use kubectl exec [POD] -- [COMMAND] instead.
root@pod1:/# cd /tmp
root@pod1:/tmp# ls
root@pod1:/tmp# touch healthy
root@pod1:/tmp# ls
healthy
root@pod1:/tmp# exit
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;now use &lt;strong&gt;kubectl get po&lt;/strong&gt; and describe it.
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Conditions:
  Type              Status
  Initialized       True 
  Ready             True 
  ContainersReady   False 
  PodScheduled      True
[k8s-ckad (⎈|minikube:hands-on)]$ k get po
NAME   READY   STATUS    RESTARTS   AGE
pod1   1/1     Running   0          6m26s
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;liveness probe&lt;/strong&gt;&lt;br&gt;
Liveness probes detects a deadlock, in which a program is operating but unable to advance. Despite issues, restarting a container in this condition can assist to make the program more available.&lt;br&gt;
Let's understand through hands on&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;apiVersion: v1
kind: Pod
metadata:
  name: pod1
spec:
  containers:
  - name: liveness
    image: nginx
    args:
    - /bin/sh
    - -c
    - touch /tmp/healthy; sleep 30; rm -f /tmp/healthy; sleep 600
    livenessProbe:
      exec:
        command:
        - cat
        - /tmp/healthy
      initialDelaySeconds: 5
      periodSeconds: 5
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;deploy the pod, and describe it
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Conditions:
  Type              Status
  Initialized       True 
  Ready             True 
  ContainersReady   True 
  PodScheduled      True 
Volumes:
  kube-api-access-hbk44:
    Type:                    Projected (a volume that contains injected data from multiple sources)
    TokenExpirationSeconds:  3607
    ConfigMapName:           kube-root-ca.crt
    ConfigMapOptional:       &amp;lt;nil&amp;gt;
    DownwardAPI:             true
QoS Class:                   BestEffort
Node-Selectors:              &amp;lt;none&amp;gt;
Tolerations:                 node.kubernetes.io/not-ready:NoExecute op=Exists for 300s
                             node.kubernetes.io/unreachable:NoExecute op=Exists for 300s
Events:
  Type    Reason     Age   From               Message
  ----    ------     ----  ----               -------
  Normal  Scheduled  9s    default-scheduler  Successfully assigned hands-on/pod1 to minikube
  Normal  Pulling    8s    kubelet            Pulling image "nginx"
  Normal  Pulled     6s    kubelet            Successfully pulled image "nginx" in 1.917415303s
  Normal  Created    6s    kubelet            Created container liveness
  Normal  Started    6s    kubelet            Started container liveness
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;wait for 30s and again describe the pod
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Events:
  Type     Reason     Age                 From               Message
  ----     ------     ----                ----               -------
  Normal   Scheduled  2m1s                default-scheduler  Successfully assigned hands-on/pod1 to minikube
  Normal   Pulled     118s                kubelet            Successfully pulled image "nginx" in 1.917415303s
  Normal   Pulling    45s (x2 over 2m)    kubelet            Pulling image "nginx"
  Normal   Created    43s (x2 over 118s)  kubelet            Created container liveness
  Normal   Started    43s (x2 over 118s)  kubelet            Started container liveness
  Normal   Pulled     43s                 kubelet            Successfully pulled image "nginx" in 1.993915629s
  Warning  Unhealthy  0s (x6 over 85s)    kubelet            Liveness probe failed: cat: /tmp/healthy: No such file or directory
  Normal   Killing    0s (x2 over 75s)    kubelet            Container liveness failed liveness probe, will be restarted
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;now the probe are failed, and it will try to restart the container
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[k8s-ckad (⎈|minikube:hands-on)]$ k get po
NAME   READY   STATUS    RESTARTS      AGE
pod1   1/1     Running   4 (23s ago)   5m24s
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;hope that this has clarified you with probes.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Thank you&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>kubernetes</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>How does a pod get launched when deployment is applied.</title>
      <dc:creator>Akshay Rao</dc:creator>
      <pubDate>Wed, 04 Oct 2023 07:23:32 +0000</pubDate>
      <link>https://dev.to/aksrao1998/how-does-a-pod-get-launched-when-deployment-is-applied-2m9g</link>
      <guid>https://dev.to/aksrao1998/how-does-a-pod-get-launched-when-deployment-is-applied-2m9g</guid>
      <description>&lt;p&gt;&lt;strong&gt;Introduction&lt;/strong&gt;&lt;br&gt;
Hi, I am Akshay Rao.&lt;br&gt;
While working with Kubernetes, i had a question how does the deployment make a pod, even in the yaml file, the kind we don't mention the as pod then also the pod is created, i researched and understood how it actually it works.&lt;br&gt;
&lt;strong&gt;Let's Start&lt;/strong&gt; &lt;br&gt;
For this flow to understand we need to understand the controllers in the k8s.&lt;br&gt;
every controller has a 2 component:-&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Informers&lt;/strong&gt; keep an eye on the desired state of resources in a scalable and sustainable manner. They also have a resync mechanism, which enforces periodic reconciliation and is frequently used to ensure that the cluster state and the assumed state cached in memory do not drift (due to faults or network issues.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Work queue&lt;/strong&gt; is essentially a component that may be utilized by the event handler to handle the queuing of state changes and aid in the implementation of retries.
This feature is accessible in client-go via the work queue package. Resources can be requeued if there are mistakes when updating the world or publishing the status, or if we need to evaluate the resource after a period of time for various reasons.
we have understood the controller components, now we will see the pods creation flow.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--zlovi_w6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4cey1z72ohxpjndzc8hx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--zlovi_w6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4cey1z72ohxpjndzc8hx.png" alt="Image flowchart" width="720" height="970"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The deployment controller (located within kube-controller-manager) detects (through a deployment informer) that the user has created a deployment. In its business logic, it generates a replica set.&lt;/li&gt;
&lt;li&gt;The replica set controller (again, inside kube-controllermanager) observes the new replica set (through a replica set informer) and executes its business logic, which generates a pod object.&lt;/li&gt;
&lt;li&gt;The scheduler (within the kube-scheduler binary), which is also a controller, observes the pod with an empty spec.nodeName field (through a pod informer). Its business logic queues the pod for scheduling.&lt;/li&gt;
&lt;li&gt;Meanwhile, another controller, the kubelet, observes the new pod (via its pod informer). However, the new pod's spec.nodeName field is empty, therefore it does not match the kubelet's node name. It ignores the pod and returns to sleep until  next event is triggered.&lt;/li&gt;
&lt;li&gt;The scheduler removes the pod from the work queue and assigns it to a node with appropriate spare resources by modifying the pod's spec.nodeName field and writing it to the API server.&lt;/li&gt;
&lt;li&gt;The kubelet re-wakes as a result of the pod update event. It compares the spec.nodeName to its own node name once again. Because the names match, the kubelet launches the pod's containers and informs back to the API server that the containers have been launched by writing this information into the pod status.&lt;/li&gt;
&lt;li&gt;The replica set controller observes the modified pod but is powerless to intervene.&lt;/li&gt;
&lt;li&gt;The pod eventually comes to an end. The kubelet will detect this, retrieve the pod object from the API server, set the "terminated" condition in the pod's status, and return it to the API server.&lt;/li&gt;
&lt;li&gt;When the replica set controller observes the terminated pod, he determines that it must be replaced. It removes the terminated pod from the API server and replaces it with a fresh one.&lt;/li&gt;
&lt;li&gt;And so on.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Thus this ishow the pods are created via deployments.&lt;br&gt;
I hope this has brough some clarity.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Thank you&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>kubernetes</category>
      <category>devops</category>
    </item>
    <item>
      <title>K8s Hands-On: Deployments</title>
      <dc:creator>Akshay Rao</dc:creator>
      <pubDate>Wed, 04 Oct 2023 05:12:12 +0000</pubDate>
      <link>https://dev.to/aksrao1998/k8s-hands-on-deployments-54fb</link>
      <guid>https://dev.to/aksrao1998/k8s-hands-on-deployments-54fb</guid>
      <description>&lt;p&gt;&lt;strong&gt;Introduction&lt;/strong&gt;&lt;br&gt;
Hi, I am Akshay Rao. This series will help you in hands on experience.&lt;br&gt;
&lt;strong&gt;Pre-requisites&lt;/strong&gt;&lt;br&gt;
We have done with service and multi-container pod.&lt;br&gt;
&lt;a href="https://dev.to/aksrao1998/k8s-hands-on-multi-container-pod-and-service-4kih"&gt;https://dev.to/aksrao1998/k8s-hands-on-multi-container-pod-and-service-4kih&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Agenda&lt;/strong&gt;&lt;br&gt;
In this blog we will learn about the deployment with 5W2H framework. this blog is a bit theory, because i think in real world we will not creating the pods, deployment will do it for us and while building a project deployment is important.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Let's Start&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Theory&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is Kubernetes Deployment?&lt;/strong&gt;&lt;br&gt;
A Kubernetes Deployment is a resource object in Kubernetes that provides declarative updates to applications. It allows you to define an application's desired state and then automatically manages the deployment, scaling, and updating of the application to match that desired state.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why use Kubernetes Deployments?&lt;/strong&gt;&lt;br&gt;
Deployments are essential for ensuring the reliability and availability of containerized applications. They provide the following benefits:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Rolling Updates: Deployments enable rolling updates, allowing you to change application versions without downtime.&lt;/li&gt;
&lt;li&gt;Automatic Rollbacks: In case of errors or failures, Deployments can automatically roll back to the previous version.&lt;/li&gt;
&lt;li&gt;Scaling: They allow you to scale your application up or down based on demand.&lt;/li&gt;
&lt;li&gt;Self-healing: If a pod fails, Deployments automatically replace it to maintain the desired state.&lt;/li&gt;
&lt;li&gt;Replication: You can specify the desired number of replicas, ensuring high availability.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;When should you use Kubernetes Deployments?&lt;/strong&gt;&lt;br&gt;
Kubernetes Deployments are used when you want to manage the lifecycle of your containerized applications, ensuring they run reliably and are easy to update. You should use them whenever you have stateless applications that can be horizontally scaled.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Where can Kubernetes Deployments be used?&lt;/strong&gt;&lt;br&gt;
Kubernetes Deployments can be used in any Kubernetes cluster, whether it's on-premises or in the cloud. They are designed to work in various environments.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How do you create and manage Kubernetes Deployments?&lt;/strong&gt;&lt;br&gt;
To create and manage a Kubernetes Deployment, you typically follow these steps:&lt;br&gt;
Define a Deployment: Create a YAML file describing the desired state of your application, including the container image, replicas, and update strategy.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Apply the Deployment: Use the kubectl apply command to create or update the Deployment in your Kubernetes cluster.&lt;/li&gt;
&lt;li&gt;Monitor and Scale: Use kubectl or Kubernetes dashboard to monitor the Deployment's status and scale it as needed.&lt;/li&gt;
&lt;li&gt;Update the Application: To update the application, you modify the Deployment YAML to specify a new container image version and reapply it.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Hands-On&lt;/strong&gt;&lt;br&gt;
create a basic deployment&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[Downloads (⎈|minikube:hands-on)]$ kubectl create deployment pod1 --image=nginx
deployment.apps/pod1 created

[Downloads (⎈|minikube:hands-on)]$ kubectl get deploy
NAME   READY   UP-TO-DATE   AVAILABLE   AGE
pod1   1/1     1            1           5s

[Downloads (⎈|minikube:hands-on)]$ kubectl get po
NAME                    READY   STATUS    RESTARTS   AGE
pod1-6f7b75cbfc-6pnmv   1/1     Running   0          2m46s
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;lets describe it&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[Downloads (⎈|minikube:hands-on)]$ kubectl describe deploy pod1
Name:                   pod1
Namespace:              hands-on
CreationTimestamp:      Wed, 04 Oct 2023 13:58:21 +0900
Labels:                 app=pod1
Annotations:            deployment.kubernetes.io/revision: 1
Selector:               app=pod1
Replicas:               1 desired | 1 updated | 1 total | 1 available | 0 unavailable
StrategyType:           RollingUpdate
MinReadySeconds:        0
RollingUpdateStrategy:  25% max unavailable, 25% max surge
Pod Template:
  Labels:  app=pod1
  Containers:
   nginx:
    Image:        nginx
    Port:         &amp;lt;none&amp;gt;
    Host Port:    &amp;lt;none&amp;gt;
    Environment:  &amp;lt;none&amp;gt;
    Mounts:       &amp;lt;none&amp;gt;
  Volumes:        &amp;lt;none&amp;gt;
Conditions:
  Type           Status  Reason
  ----           ------  ------
  Available      True    MinimumReplicasAvailable
  Progressing    True    NewReplicaSetAvailable
OldReplicaSets:  &amp;lt;none&amp;gt;
NewReplicaSet:   pod1-6f7b75cbfc (1/1 replicas created)
Events:
  Type    Reason             Age   From                   Message
  ----    ------             ----  ----                   -------
  Normal  ScalingReplicaSet  84s   deployment-controller  Scaled up replica set pod1-6f7b75cbfc to 1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;change the replicas from 1 to 2&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;edit the deployments in the cluster(it is not bets practices to edit the k8s resource in the cluster but it is a good tool to know as it can come in handy)
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[Downloads (⎈|minikube:hands-on)]$ kubectl edit deploy pod1

[Downloads (⎈|minikube:hands-on)]$ kubectl get po
NAME                    READY   STATUS    RESTARTS   AGE
pod1-6f7b75cbfc-6pnmv   1/1     Running   0          8m47s
pod1-6f7b75cbfc-r86bb   1/1     Running   0          57s
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;now we have two pods of same configuration, we did not even create new yaml file or anything.&lt;/li&gt;
&lt;li&gt;Deployments are very important in the real world scenario, i always work with deployments with helm chart in production.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To understand more on the deployments, refer this blog&lt;br&gt;
&lt;a href="https://dev.to/aksrao1998/how-does-a-pod-get-launched-when-deployment-is-applied-2m9g"&gt;https://dev.to/aksrao1998/how-does-a-pod-get-launched-when-deployment-is-applied-2m9g&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Thank you&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>kubernetes</category>
      <category>tutorial</category>
      <category>handson</category>
    </item>
  </channel>
</rss>
