{"id":1661,"date":"2024-08-15T12:42:12","date_gmt":"2024-08-15T12:42:12","guid":{"rendered":"http:\/\/shijuvarghese.com\/?p=1661"},"modified":"2025-05-23T18:03:22","modified_gmt":"2025-05-23T18:03:22","slug":"kubernetes-apps-and-pods","status":"publish","type":"post","link":"http:\/\/shijuvarghese.com\/?p=1661","title":{"rendered":"Kubernetes: Apps and pods"},"content":{"rendered":"<p>A Pod is the smallest deployable units of computing in a Kubernetes environment. A pod can host just one application (container) or several.<\/p>\n<p>Let us see if there are any pods running in the default namespace &#8220;default&#8221;<\/p>\n<p><strong>[root@kubmaster01 ~]#<\/strong> kubectl get pod<br \/>\nNo resources found in default namespace.<\/p>\n<p>Now let us run an application (container)<br \/>\n<strong>[root@kubmaster01 ~]#<\/strong> kubectl run app1 &#8211;image=httpd<br \/>\npod\/app1 created<\/p>\n<p><strong>[root@kubmaster01 ~]#<\/strong> kubectl get pod<br \/>\n=======<br \/>\nNAME\u00a0 \u00a0 READY\u00a0 \u00a0 \u00a0STATUS\u00a0 \u00a0 \u00a0RESTARTS\u00a0 \u00a0 \u00a0AGE<br \/>\napp1\u00a0 \u00a0 1\/1\u00a0 \u00a0 Running\u00a0 \u00a0 \u00a00\u00a0 \u00a0 \u00a084s<br \/>\n========<\/p>\n<p>The above command ran the app1 container using <em>imperative<\/em> method. However, Kubernetes created the container using other default settings. Let us find out the configuration of the container in a yaml format. It reads that there is a pod named <em>app1<\/em> running a container named <em>app1<\/em>. <em>One<\/em> out of <em>One<\/em> container is running.<\/p>\n<p>The below command displays the <em>app1<\/em> pod in a yaml format<\/p>\n<p><strong>[root@kubmaster01 ~]#<\/strong> kubectl get pod app1 -o yaml<\/p>\n<p><strong>[root@kubmaster01 ~]#<\/strong> kubectl describe pod app1<\/p>\n<p><em>====== ===\u00a0<\/em><br \/>\n<em>Name: app1<\/em><br \/>\n<em>Namespace: default<\/em><br \/>\n<em>Priority: 0<\/em><br \/>\n<em>Service Account: default<\/em><br \/>\n<em>Node: kubworker01\/192.168.146.130<\/em><br \/>\n<em>Start Time: Thu, 15 Aug &#8230;&#8230;<\/em><br \/>\n<em>===== ===<\/em><\/p>\n<p><strong>[root@kubmaster01 ~]#<\/strong> kubectl describe pod app1<\/p>\n<p><em>===== =====<\/em><br \/>\n<em>Name: app1<\/em><br \/>\n<em>Namespace: default<\/em><br \/>\n<em>Priority: 0<\/em><br \/>\n<em>Service Account: default<\/em><br \/>\n<em>Node: kubworker01\/<span style=\"color: #993300;\">192.168.146.130<\/span><\/em><br \/>\n<em>Start Time: Thu, 15 Aug 2024 18:14:04 +0530<\/em><br \/>\n<em>Labels: run=app1<\/em><br \/>\n<em>Annotations: cni.projectcalico.org\/containerID: b175aaf32640bea4bb365e3b41cdf901b0ae0d33b26113c18f5eb06025449b78<\/em><br \/>\n<em> cni.projectcalico.org\/podIP: 172.16.135.65\/32<\/em><br \/>\n<em> cni.projectcalico.org\/podIPs: 172.16.135.65\/32<\/em><br \/>\n<em>Status: Running<\/em><br \/>\n<em>IP: <span style=\"color: #993300;\">172.16.135.65<\/span><\/em><br \/>\n<em>IPs:<\/em><br \/>\n<em> IP: <span style=\"color: #993300;\">172.16.135.65<\/span><\/em><br \/>\n<em>Containers:<\/em><br \/>\n<em> app1:<\/em><br \/>\n<em> Container ID: con<\/em><br \/>\n<em>===== =====<\/em><\/p>\n<p><strong>[root@kubmaster01 ~]#<\/strong> kubectl explain pods<\/p>\n<p>The above command explains the fields that are part of a yaml manifest file. However, it explains only the top-level parameters such as apiVersion, kind, metadata, spec, etc. If we need to see an explanation of the parameter that declared the name of the container in a pod, we will have to use the below command.<\/p>\n<p><strong>[root@kubmaster01 ~]#<\/strong> kubectl explain pod.spec.containers.name<\/p>\n<p>An alternate method will be to use the &#8220;recursive&#8221; switch that explains all parameters\u00a0from top level to low-level as show below.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>[root@kubmaster01 ~]#<\/strong> kubectl get pod -o wide<\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"mh-excerpt\"><p>A Pod is the smallest deployable units of computing in a Kubernetes environment. A pod can host just one application (container) or several. Let us <a class=\"mh-excerpt-more\" href=\"http:\/\/shijuvarghese.com\/?p=1661\" title=\"Kubernetes: Apps and pods\">[&#8230;]<\/a><\/p>\n<\/div>","protected":false},"author":1,"featured_media":1784,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17,21,34,3],"tags":[],"class_list":["post-1661","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-cluster","category-devops","category-kubernetes","category-linux"],"_links":{"self":[{"href":"http:\/\/shijuvarghese.com\/index.php?rest_route=\/wp\/v2\/posts\/1661","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/shijuvarghese.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/shijuvarghese.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/shijuvarghese.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/shijuvarghese.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1661"}],"version-history":[{"count":9,"href":"http:\/\/shijuvarghese.com\/index.php?rest_route=\/wp\/v2\/posts\/1661\/revisions"}],"predecessor-version":[{"id":1707,"href":"http:\/\/shijuvarghese.com\/index.php?rest_route=\/wp\/v2\/posts\/1661\/revisions\/1707"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/shijuvarghese.com\/index.php?rest_route=\/wp\/v2\/media\/1784"}],"wp:attachment":[{"href":"http:\/\/shijuvarghese.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1661"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/shijuvarghese.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1661"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/shijuvarghese.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1661"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}