Followers

Kubernetes Assignment - Pod Overview

  Try This Consideration:- You have 3 nodes ( 1 master and 2 worker nodes) Cluster. Create a Pod called nginx-pod1 with image nginx (it runs...

 

Try This

Consideration:- You have 3 nodes ( 1 master and 2 worker nodes) Cluster.

  1. Create a Pod called nginx-pod1 with image nginx (it runs on Port 80)
  2. Create another Pod called tomcat-pod1 with image tomcat (it runs on Port 8080)
  3. Access these pods on worker nodes (use curl command ). Are you able to Access ? If not then checkout the reason.
  4. Go inside tomcat pod ( use kubectl exec ....command) and try to access nginx service Pod by using nginx-pod1 IP address and pod name. Are you able to access the nginx website ? if no then figure out the reason.
  5. Go inside nginx pod (use kubectl exec ....command) and try to access tomcat service with IP address and pod name ot tomcat-pod1. Are you able to access the nginx website? if no then figure out the reason.
  6. Change docker image of nginx-pod1 from nginx to tomcat. Is it possible for running a pod?
  7. Check the restart value of nginx-pod1.
  8. check all the events of tomcat-pod1 and also find out in which namespace tomcat-pod1 is created.
  9. Display the tomcat-pod1 properties in json format.
  10. Delete all the pods.

COMMENTS

BLOGGER: 13
  1. 1. Create a Pod called nginx-pod1 with image nginx (it runs on Port 80)

    kubectl run nginx-pod1 --image=nginx
    OR
    #nginx-pod1.yaml
    apiVersion: v1
    kind: Pod
    metadata:
    name: nginx-pod1
    spec:
    containers:
    - name: c1
    image: nginx

    2. Create another Pod called tomcat-pod1 with image tomcat (it runs on Port 8080)

    kubectl run tomcat-pod1 --image=tomcat
    OR
    #tomcat-pod1.yaml
    apiVersion: v1
    kind: Pod
    metadata:
    name: tomcat-pod1
    spec:
    containers:
    - name: c1
    image: tomcat

    3. Access these pods on worker nodes (use curl command ). Are you able to Access ? If not then checkout the reason.

    kubectl get pods -o wide
    curl
    (yes able to, for nginx is ok but for tomcat need to put port number (8080))

    4. Go inside tomcat pod ( use kubectl exec ....command) and try to access nginx service Pod by using nginx-pod1 IP address and pod name. Are you able to access the nginx website ? if no then figure out the reason.

    kubectl exec -it tomcat-pod1 -- bash
    curl
    (can access as they are in the same CIDR range (calico network layer))

    5. Go inside nginx pod (use kubectl exec ....command) and try to access tomcat service with IP address and pod name ot tomcat-pod1. Are you able to access the nginx website? if no then figure out the reason.

    kubectl exec -it nginx-pod1 -- bash
    curl
    (can access as they are in the same CIDR range (calico network layer))

    6. Change docker image of nginx-pod1 from nginx to tomcat. Is it possible to do on a running pod?

    No.
    Error from server (AlreadyExists): pods "nginx-pod1" already exists

    7. Check the restart value of nginx-pod1

    kubectl get pod nginx-pod1 -o wide

    8. Check all the events of tomcat-pod1 and also find out in which namespace tomcat-pod1 is created.

    kubectl describe pod tomcat-pod1
    Name: tomcat-pod1
    Namespace: default

    9. Display the tomcat-pod1 properties in json format.

    kubectl get pod tomcat-pod1 -o json

    10. Delete all the pods.

    kubectl delete pod --all

    ReplyDelete
  2. 1. Create a Pod called nginx-pod1 with image nginx (it runs on Port 80)
    root@kmaster:/home/vagrant# kubectl run nginx-pod1 --image=nginx
    pod/nginx-pod1 created


    2. Create another Pod called tomcat-pod1 with image tomcat (it runs on Port 8080)
    root@kmaster:/home/vagrant# kubectl run tomcat-pod1 --image=tomcat
    pod/tomcat-pod1 created


    3. Access these pods on worker nodes (use curl command ). Are you able to Access ? If not then checkout the reason. Can access.
    vagrant@kworker1:~$ curl 192.168.41.137:8080


    4. Go inside tomcat pod ( use kubectl exec ....command) and try to access nginx service Pod by using nginx-pod1 IP address and pod name.
    Are you able to access the nginx website ? if no then figure out the reason. Can access.
    root@kmaster:/home/vagrant# kubectl exec -it tomcat-pod1 -- bash
    root@tomcat-pod1:/usr/local/tomcat# curl 192.168.77.132


    5. Go inside nginx pod (use kubectl exec ....command) and try to access tomcat service with IP address and pod name ot tomcat-pod1.
    Are you able to access the nginx website? if no then figure out the reason. can access.
    root@kmaster:/home/vagrant# kubectl exec -it nginx-pod1 -- bash
    root@nginx-pod1:/# curl 192.168.41.137:8080


    6. Change docker image of nginx-pod1 from nginx to tomcat. Is it possible for running a pod? No.
    root@kmaster:/home/vagrant# vi eg.yml
    apiVersion: v1
    kind: Pod
    metadata:
    name: nginx-pod1
    spec:
    containers:
    - name: nginxc
    image: tomcat

    root@kmaster:/home/vagrant# kubectl create -f eg.yml
    Error from server (AlreadyExists): error when creating "eg.yml": pods "nginx-pod1" already exists


    7. Check the restart value of nginx-pod1.
    root@kmaster:/home/vagrant# kubectl get pod -o wide
    NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
    nginx-pod1 1/1 Running 0 24m 192.168.77.132 kworker2
    tomcat-pod1 1/1 Running 0 23m 192.168.41.137 kworker1


    8. check all the events of tomcat-pod1 and also find out in which namespace tomcat-pod1 is created.
    root@kmaster:/home/vagrant# kubectl describe pod tomcat-pod1
    Name: tomcat-pod1
    Namespace: default


    9. Display the tomcat-pod1 properties in json format.
    root@kmaster:/home/vagrant# kubectl get pod tomcat-pod1 -o json
    {
    "apiVersion": "v1",
    "kind": "Pod",
    "metadata": {
    "annotations": {
    ...........


    10.Delete all the pods.
    root@kmaster:/home/vagrant# kubectl delete pod --all
    pod "nginx-pod1" deleted
    pod "tomcat-pod1" deleted
    root@kmaster:/home/vagrant# kubectl get pods
    No resources found in default namespace.

    ReplyDelete
  3. 1.
    vi nginx-pod1
    apiVersion: v1
    kind: Pod
    metadata:
    name: nginx
    spec:
    containers:
    - name: nginx
    image: nginx:1.14.2
    ports:
    - containerPort: 80

    2.
    vi tomcat-pod1
    apiVersion: v1
    kind: Pod
    metadata:
    name: tomcat
    spec:
    containers:
    - name: tomcat
    image: tomcat
    ports:
    - containerPort: 8080

    3. Able to access both pods in kworker2

    4. kubectl exec -it tomcat -- bash
    curl 190.168.77.136:8080

    5. kubectl exec -it nginx -- bash
    curl 190.168.77.135:80

    6. Yes, image updated

    7. Restart value is 0

    8. Namespace: default

    9. kubectl get pod tomcat -o json

    10. kubectl delete pod --all

    ReplyDelete
  4. 1. kubectl run nginx-pod1 --image=nginx
    2. kubectl run tomcat-pod1 --image=tomcat
    3. Use kubectl get pods -o wide to obtain IPs of the two pods.
    NGINX pod runs on port 80 and can be accessed directly with IP,
    TOMCAT pod runs on port 8080 and thus the port has to be appended
    after IP in the curl command, e.g. curl <>:8080.
    Both pods can be accessed from both worker nodes.
    4. Able to
    5. Able to.
    6. No.
    Error from server (AlreadyExists): pods "nginx-pod1" already exists
    7. kubectl get pods -o wide
    0.
    8. kubectl describe pod tomcat-pod1
    Name: tomcat-pod1
    Namespace: default
    9. kubectl get pod tomcat-pod1 -o json
    10. kubectl delete pod --all

    ReplyDelete
    Replies
    1. 6. kubectl edit pod nginx-pod1
      Change image to tomcat
      7. kubectl get pods -o wide
      1.

      Delete
  5. Create a Pod called nginx-pod1 with image nginx (it runs on Port 80)

    kubectl run nginxpod1 --image=nginx

    Create another Pod called tomcat-pod1 with image tomcat (it runs on Port 8080)

    kubectl run tomcatpod1 --image=tomcat

    Access these pods on worker nodes (use curl command ). Are you able to Access ? If not then checkout the reason.

    vagrant@kworker1:~$ curl 192.168.77.137
    vagrant@kworker1:~$ curl 190.168.77.136:8080

    Go inside tomcat pod ( use kubectl exec ....command) and try to access nginx service Pod by using nginx-pod1 IP address and pod name. Are you able to access the nginx website ? if no then figure out the reason.

    kubectl exec -it tomcatpod1 -- bash
    curl 192.168.77.137

    Go inside nginx pod (use kubectl exec ....command) and try to access tomcat service with IP address and pod name ot tomcat-pod1. Are you able to access the nginx website? if no then figure out the reason.

    kubectl exec -it nginxpod1 -- bash
    curl 190.168.77.136:8080

    Change docker image of nginx-pod1 from nginx to tomcat. Is it possible for running a pod?

    No, because nginx image is running

    Check the restart value of nginx-pod1.

    kubectl get pod nginxpod1 -o wide

    check all the events of tomcat-pod1 and also find out in which namespace tomcat-pod1 is created.

    kubectl describe pod tomcatpod1
    Name: tomcatpod1
    Namespace: default

    Display the tomcat-pod1 properties in json format.

    kubectl get pod tomcatpod1 -o json

    Delete all the pods.

    kubectl delete pod --all

    ReplyDelete
  6. exec it:
    kubectl exec -it nginx-pod -- bash

    from tomcat:
    curl 192.168.77.133:80 -works
    from nginx:
    curl 192.168.77.134:8080-works

    ReplyDelete
    Replies
    1. exec it:
      kubectl exec -it nginx-pod -- bash

      from tomcat:
      curl 192.168.77.133:80 -works
      from nginx:
      curl 192.168.77.134:8080-works

      amend the nginx.yaml file to change the container to tomcat from nginx, then run this command : kubectl apply -f nginx.yaml

      Delete
    2. after update of yaml file, restart value of nginx-pod becomes "1"

      Delete
    3. display as json
      kubectl get pod tomcat-pod1 -o json

      delete all pods
      kubectl delete --all pods

      Delete
  7. This comment has been removed by the author.

    ReplyDelete
  8. 1. Create a Pod called nginx-pod1 with image nginx (it runs on Port 80)
    
-> kubectl run nginx-pod1 --image=nginx


    2. Create another Pod called tomcat-pod1 with image tomcat (it runs on Port 8080)

    -> kubectl run tomcat-pod1 --image=tomcat


    3. Access these pods on worker nodes (use curl command ). Are you able to Access? If not then checkout the reason.

    On master server -> kubectl get pods -o wide (to view IP address)

    On worker nodes -> curl 190.168.41.129 (nginx pod) YES, both worker nodes have access

    On worker nodes -> curl 190.168.77.129 (tomcat pod) NO, port 80: Connection refused


    4. Go inside tomcat pod ( use kubectl exec ....command) and try to access nginx service Pod by using nginx-pod1 IP address and pod name. Are you able to access the nginx website ? if no then figure out the reason.

    On master server -> kubectl exec -it tomcat-pod1 -- bash

    -> curl 190.168.41.129 (YES)


    5. Go inside nginx pod (use kubectl exec ....command) and try to access tomcat service with IP address and pod name of tomcat-pod1. Are you able to access the nginx website? if no then figure out the reason.
    
-> exit

    -> kubectl exec -it nginx-pod1 -- bash

    -> curl 190.168.77.129:8080 (YES)


    6. Change docker image of nginx-pod1 from nginx to tomcat. Is it possible for running a pod?

    -> exit
-> kubectl edit pod nginx-pod1 (change image: nginx to tomcat in the editor)

    NO

    7. Check the restart value of nginx-pod1.
-> kubectl get pods -o wide (0 RESTARTS)


    8. check all the events of tomcat-pod1 and also find out in which namespace tomcat-pod1 is created.

    -> kubectl describe pod tomcat-pod1 (Namespace: default)


    9. Display the tomcat-pod1 properties in json format.
-
    > kubectl get pod tomcat-pod1 -o json


    10. Delete all the pods.

    -> kubectl delete pod --all

    ReplyDelete

Name

Ansible,6,AWS,1,Azure DevOps,1,Containerization with docker,2,DevOps,2,Docker Quiz,1,Docker Swarm,1,DockerCompose,1,ELK,2,git,2,Jira,1,Kubernetes,1,Kubernetes Quiz,5,SAST DAST Security Testing,1,SDLC Quiz,3,SonarQube,3,Splunk,2,vagrant kubernetes,1,YAML Basics,1,
ltr
item
DevOpsWorld: Kubernetes Assignment - Pod Overview
Kubernetes Assignment - Pod Overview
DevOpsWorld
https://www.devopsworld.co.in/2021/08/kubernetes-assignment-pod-overview.html
https://www.devopsworld.co.in/
https://www.devopsworld.co.in/
https://www.devopsworld.co.in/2021/08/kubernetes-assignment-pod-overview.html
true
5997357714110665304
UTF-8
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS PREMIUM CONTENT IS LOCKED STEP 1: Share to a social network STEP 2: Click the link on your social network Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy Table of Content