{"id":873,"date":"2024-02-04T11:51:37","date_gmt":"2024-02-04T02:51:37","guid":{"rendered":"https:\/\/itstudy365.com\/blog\/?page_id=873"},"modified":"2024-03-25T21:37:03","modified_gmt":"2024-03-25T12:37:03","slug":"kubernetes-k8s-practice","status":"publish","type":"page","link":"https:\/\/itstudy365.com\/blog\/kubernetes-k8s-practice\/","title":{"rendered":"Kubernetes\u00a0(K8s) Practice"},"content":{"rendered":"\n<figure class=\"wp-block-image size-full is-resized\"><img decoding=\"async\" loading=\"lazy\" width=\"512\" height=\"512\" src=\"https:\/\/itstudy365.com\/blog\/wp-content\/uploads\/2024\/02\/Kubernetes.png\" alt=\"\" class=\"wp-image-874\" style=\"aspect-ratio:1;width:159px;height:auto\" srcset=\"https:\/\/itstudy365.com\/blog\/wp-content\/uploads\/2024\/02\/Kubernetes.png 512w, https:\/\/itstudy365.com\/blog\/wp-content\/uploads\/2024\/02\/Kubernetes-300x300.png 300w, https:\/\/itstudy365.com\/blog\/wp-content\/uploads\/2024\/02\/Kubernetes-150x150.png 150w\" sizes=\"(max-width: 512px) 100vw, 512px\" \/><\/figure>\n\n\n\n<p>The target Kubernetes(minikube) version is v1.32.0.<\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_62 counter-hierarchy ez-toc-counter ez-toc-light-blue ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title \" >\u76ee\u6b21<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/itstudy365.com\/blog\/kubernetes-k8s-practice\/#Step1Install_Minikube\" title=\"Step1.Install Minikube\">Step1.Install Minikube<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/itstudy365.com\/blog\/kubernetes-k8s-practice\/#Step2Learn_about_Kubernetes_architectureMaster_Nodes_Pods_etc\" title=\"Step2.Learn about Kubernetes architecture(Master, Nodes, Pods,  etc.)\">Step2.Learn about Kubernetes architecture(Master, Nodes, Pods,  etc.)<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/itstudy365.com\/blog\/kubernetes-k8s-practice\/#1_Kubernetes_Architecture\" title=\"1. Kubernetes Architecture:\">1. Kubernetes Architecture:<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/itstudy365.com\/blog\/kubernetes-k8s-practice\/#Step3Familiarize_Kubernetes_terminology_Deployments_ReplicaSets_Pods_Services_etc\" title=\"Step3.Familiarize Kubernetes terminology (Deployments, ReplicaSets, Pods, Services, etc.)\">Step3.Familiarize Kubernetes terminology (Deployments, ReplicaSets, Pods, Services, etc.)<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/itstudy365.com\/blog\/kubernetes-k8s-practice\/#1_Pods\" title=\"1. Pods:\">1. Pods:<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/itstudy365.com\/blog\/kubernetes-k8s-practice\/#2_Deployments\" title=\"2. Deployments:\">2. Deployments:<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/itstudy365.com\/blog\/kubernetes-k8s-practice\/#3_ReplicaSets\" title=\"3. ReplicaSets:\">3. ReplicaSets:<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/itstudy365.com\/blog\/kubernetes-k8s-practice\/#4_Services\" title=\"4. Services:\">4. Services:<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/itstudy365.com\/blog\/kubernetes-k8s-practice\/#5_ConfigMaps\" title=\"5. ConfigMaps:\">5. ConfigMaps:<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/itstudy365.com\/blog\/kubernetes-k8s-practice\/#6_Secrets\" title=\"6. Secrets:\">6. Secrets:<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/itstudy365.com\/blog\/kubernetes-k8s-practice\/#7_Volumes\" title=\"7. Volumes:\">7. Volumes:<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-12\" href=\"https:\/\/itstudy365.com\/blog\/kubernetes-k8s-practice\/#Step4Deploy_a_simple_application_eg_a_web_server\" title=\"Step4.Deploy a simple application (e.g., a web server)\">Step4.Deploy a simple application (e.g., a web server)<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-13\" href=\"https:\/\/itstudy365.com\/blog\/kubernetes-k8s-practice\/#1_Create_a_Deployment_Manifest_deploymentyaml\" title=\"1. Create a Deployment Manifest (deployment.yaml)\">1. Create a Deployment Manifest (deployment.yaml)<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-14\" href=\"https:\/\/itstudy365.com\/blog\/kubernetes-k8s-practice\/#2_Create_a_Service_Manifest_serviceyaml\" title=\"2. Create a Service Manifest (service.yaml)\">2. Create a Service Manifest (service.yaml)<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-15\" href=\"https:\/\/itstudy365.com\/blog\/kubernetes-k8s-practice\/#3_Apply_the_Manifests\" title=\"3. Apply the Manifests\">3. Apply the Manifests<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-16\" href=\"https:\/\/itstudy365.com\/blog\/kubernetes-k8s-practice\/#4_Verify_Deployment_and_Service\" title=\"4. Verify Deployment and Service\">4. Verify Deployment and Service<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-17\" href=\"https:\/\/itstudy365.com\/blog\/kubernetes-k8s-practice\/#5_Access_the_Web_Server\" title=\"5. Access the Web Server\">5. Access the Web Server<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-18\" href=\"https:\/\/itstudy365.com\/blog\/kubernetes-k8s-practice\/#Step5Use_kubectl_commands_to_interact_with_your_Kubernetes_cluster\" title=\"Step5.Use kubectl commands to interact with your Kubernetes cluster.\">Step5.Use kubectl commands to interact with your Kubernetes cluster.<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-19\" href=\"https:\/\/itstudy365.com\/blog\/kubernetes-k8s-practice\/#1List_Pods\" title=\"1.List Pods\">1.List Pods<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-20\" href=\"https:\/\/itstudy365.com\/blog\/kubernetes-k8s-practice\/#2Describe_a_Pod\" title=\"2.Describe a Pod\">2.Describe a Pod<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-21\" href=\"https:\/\/itstudy365.com\/blog\/kubernetes-k8s-practice\/#3List_Services\" title=\"3.List Services\">3.List Services<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-22\" href=\"https:\/\/itstudy365.com\/blog\/kubernetes-k8s-practice\/#4Descrive_a_Service\" title=\"4.Descrive a Service\">4.Descrive a Service<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-23\" href=\"https:\/\/itstudy365.com\/blog\/kubernetes-k8s-practice\/#5List_Deployments\" title=\"5.List Deployments\">5.List Deployments<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-24\" href=\"https:\/\/itstudy365.com\/blog\/kubernetes-k8s-practice\/#6Describe_a_Deployment\" title=\"6.Describe a Deployment\">6.Describe a Deployment<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-25\" href=\"https:\/\/itstudy365.com\/blog\/kubernetes-k8s-practice\/#7View_logs_of_a_Pod\" title=\"7.View logs of a Pod\">7.View logs of a Pod<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-26\" href=\"https:\/\/itstudy365.com\/blog\/kubernetes-k8s-practice\/#8Execute_a_Command_in_a_Pod\" title=\"8.Execute a Command in a Pod\">8.Execute a Command in a Pod<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-27\" href=\"https:\/\/itstudy365.com\/blog\/kubernetes-k8s-practice\/#9Delete_Resources\" title=\"9.Delete Resources\">9.Delete Resources<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-28\" href=\"https:\/\/itstudy365.com\/blog\/kubernetes-k8s-practice\/#Step6Learn_common_troubleshooting_techniques_in_Kubernetes_eg_checking_pod_status_logs_describing_resources\" title=\"Step6.Learn common troubleshooting techniques in Kubernetes (e.g., checking pod status, logs, describing resources).\">Step6.Learn common troubleshooting techniques in Kubernetes (e.g., checking pod status, logs, describing resources).<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-29\" href=\"https:\/\/itstudy365.com\/blog\/kubernetes-k8s-practice\/#1_Checking_Pod_Status\" title=\"1. Checking Pod Status\">1. Checking Pod Status<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-30\" href=\"https:\/\/itstudy365.com\/blog\/kubernetes-k8s-practice\/#2_Describing_a_Pod\" title=\"2. Describing a Pod\">2. Describing a Pod<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-31\" href=\"https:\/\/itstudy365.com\/blog\/kubernetes-k8s-practice\/#3_Viewing_Pod_Logs\" title=\"3. Viewing Pod Logs\">3. Viewing Pod Logs<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-32\" href=\"https:\/\/itstudy365.com\/blog\/kubernetes-k8s-practice\/#4_Following_Pod_Logs\" title=\"4. Following Pod Logs\">4. Following Pod Logs<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-33\" href=\"https:\/\/itstudy365.com\/blog\/kubernetes-k8s-practice\/#5_Executing_Commands_in_a_Pod\" title=\"5. Executing Commands in a Pod\">5. Executing Commands in a Pod<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-34\" href=\"https:\/\/itstudy365.com\/blog\/kubernetes-k8s-practice\/#6_Describing_Resources\" title=\"6. Describing Resources\">6. Describing Resources<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-35\" href=\"https:\/\/itstudy365.com\/blog\/kubernetes-k8s-practice\/#7_Checking_Service_Status\" title=\"7. Checking Service Status\">7. Checking Service Status<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-36\" href=\"https:\/\/itstudy365.com\/blog\/kubernetes-k8s-practice\/#8_Checking_Deployment_Status\" title=\"8. Checking Deployment Status\">8. Checking Deployment Status<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-37\" href=\"https:\/\/itstudy365.com\/blog\/kubernetes-k8s-practice\/#9_Troubleshooting_with_Events\" title=\"9. Troubleshooting with Events\">9. Troubleshooting with Events<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-38\" href=\"https:\/\/itstudy365.com\/blog\/kubernetes-k8s-practice\/#10_Describe_Node\" title=\"10. Describe Node\">10. Describe Node<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-39\" href=\"https:\/\/itstudy365.com\/blog\/kubernetes-k8s-practice\/#Step7Understand_the_role_of_Deployments_and_ReplicaSets_in_managing_containerized_applications\" title=\"Step7.Understand the role of Deployments and ReplicaSets in managing containerized applications.\">Step7.Understand the role of Deployments and ReplicaSets in managing containerized applications.<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-40\" href=\"https:\/\/itstudy365.com\/blog\/kubernetes-k8s-practice\/#Deployments\" title=\"Deployments:\">Deployments:<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-41\" href=\"https:\/\/itstudy365.com\/blog\/kubernetes-k8s-practice\/#ReplicaSets\" title=\"ReplicaSets:\">ReplicaSets:<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-42\" href=\"https:\/\/itstudy365.com\/blog\/kubernetes-k8s-practice\/#Relationship_between_Deployments_and_ReplicaSets\" title=\"Relationship between Deployments and ReplicaSets:\">Relationship between Deployments and ReplicaSets:<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-43\" href=\"https:\/\/itstudy365.com\/blog\/kubernetes-k8s-practice\/#Step8Experiment_with_scaling_deployments_and_updating_application_versions\" title=\"Step8.Experiment with scaling deployments and updating application versions.\">Step8.Experiment with scaling deployments and updating application versions.<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-44\" href=\"https:\/\/itstudy365.com\/blog\/kubernetes-k8s-practice\/#Scaling_Deployments\" title=\"Scaling Deployments:\">Scaling Deployments:<\/a><ul class='ez-toc-list-level-4' ><li class='ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-45\" href=\"https:\/\/itstudy365.com\/blog\/kubernetes-k8s-practice\/#1_View_Current_Deployments\" title=\"1. View Current Deployments:\">1. View Current Deployments:<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-46\" href=\"https:\/\/itstudy365.com\/blog\/kubernetes-k8s-practice\/#2_Scale_Deployment\" title=\"2. Scale Deployment:\">2. Scale Deployment:<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-47\" href=\"https:\/\/itstudy365.com\/blog\/kubernetes-k8s-practice\/#3_Verify_Scaling\" title=\"3. Verify Scaling:\">3. Verify Scaling:<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-48\" href=\"https:\/\/itstudy365.com\/blog\/kubernetes-k8s-practice\/#Updating_Application_Versions\" title=\"Updating Application Versions:\">Updating Application Versions:<\/a><ul class='ez-toc-list-level-4' ><li class='ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-49\" href=\"https:\/\/itstudy365.com\/blog\/kubernetes-k8s-practice\/#1_Update_Deployment_Image\" title=\"1. Update Deployment Image:\">1. Update Deployment Image:<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-50\" href=\"https:\/\/itstudy365.com\/blog\/kubernetes-k8s-practice\/#2_Apply_Updated_Manifest\" title=\"2. Apply Updated Manifest:\">2. Apply Updated Manifest:<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-51\" href=\"https:\/\/itstudy365.com\/blog\/kubernetes-k8s-practice\/#3_Verify_Update\" title=\"3. Verify Update:\">3. Verify Update:<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-52\" href=\"https:\/\/itstudy365.com\/blog\/kubernetes-k8s-practice\/#4_Check_Rollout_Status\" title=\"4. Check Rollout Status:\">4. Check Rollout Status:<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-53\" href=\"https:\/\/itstudy365.com\/blog\/kubernetes-k8s-practice\/#5_Rollback_Update_Optional\" title=\"5. Rollback Update (Optional):\">5. Rollback Update (Optional):<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-54\" href=\"https:\/\/itstudy365.com\/blog\/kubernetes-k8s-practice\/#1_Pod_Networking\" title=\"1. Pod Networking:\">1. Pod Networking:<\/a><ul class='ez-toc-list-level-4' ><li class='ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-55\" href=\"https:\/\/itstudy365.com\/blog\/kubernetes-k8s-practice\/#11_List_Pods\" title=\"1.1. List Pods:\">1.1. List Pods:<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-56\" href=\"https:\/\/itstudy365.com\/blog\/kubernetes-k8s-practice\/#12_Describe_Pod_Networking\" title=\"1.2. Describe Pod Networking:\">1.2. Describe Pod Networking:<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-57\" href=\"https:\/\/itstudy365.com\/blog\/kubernetes-k8s-practice\/#13_Connect_to_a_Pod\" title=\"1.3. Connect to a Pod:\">1.3. Connect to a Pod:<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-58\" href=\"https:\/\/itstudy365.com\/blog\/kubernetes-k8s-practice\/#2_Service_Networking\" title=\"2. Service Networking:\">2. Service Networking:<\/a><ul class='ez-toc-list-level-4' ><li class='ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-59\" href=\"https:\/\/itstudy365.com\/blog\/kubernetes-k8s-practice\/#21_List_Services\" title=\"2.1. List Services:\">2.1. List Services:<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-60\" href=\"https:\/\/itstudy365.com\/blog\/kubernetes-k8s-practice\/#22_Describe_Service_Networking\" title=\"2.2. Describe Service Networking:\">2.2. Describe Service Networking:<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-61\" href=\"https:\/\/itstudy365.com\/blog\/kubernetes-k8s-practice\/#23_Access_Service_from_Inside_Cluster\" title=\"2.3. Access Service from Inside Cluster:\">2.3. Access Service from Inside Cluster:<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-62\" href=\"https:\/\/itstudy365.com\/blog\/kubernetes-k8s-practice\/#3_Node_Networking\" title=\"3. Node Networking:\">3. Node Networking:<\/a><ul class='ez-toc-list-level-4' ><li class='ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-63\" href=\"https:\/\/itstudy365.com\/blog\/kubernetes-k8s-practice\/#31_List_Nodes\" title=\"3.1. List Nodes:\">3.1. List Nodes:<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-64\" href=\"https:\/\/itstudy365.com\/blog\/kubernetes-k8s-practice\/#32_Describe_Node_Networking\" title=\"3.2. Describe Node Networking:\">3.2. Describe Node Networking:<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-65\" href=\"https:\/\/itstudy365.com\/blog\/kubernetes-k8s-practice\/#4_Ingress_Networking\" title=\"4. Ingress Networking:\">4. Ingress Networking:<\/a><ul class='ez-toc-list-level-4' ><li class='ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-66\" href=\"https:\/\/itstudy365.com\/blog\/kubernetes-k8s-practice\/#41_List_Ingress_Resources\" title=\"4.1. List Ingress Resources:\">4.1. List Ingress Resources:<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-67\" href=\"https:\/\/itstudy365.com\/blog\/kubernetes-k8s-practice\/#42_Describe_Ingress_Networking\" title=\"4.2. Describe Ingress Networking:\">4.2. Describe Ingress Networking:<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-68\" href=\"https:\/\/itstudy365.com\/blog\/kubernetes-k8s-practice\/#5_Network_Policies\" title=\"5. Network Policies:\">5. Network Policies:<\/a><ul class='ez-toc-list-level-4' ><li class='ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-69\" href=\"https:\/\/itstudy365.com\/blog\/kubernetes-k8s-practice\/#51_List_Network_Policies\" title=\"5.1. List Network Policies:\">5.1. List Network Policies:<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-70\" href=\"https:\/\/itstudy365.com\/blog\/kubernetes-k8s-practice\/#52_Describe_Network_Policy\" title=\"5.2. Describe Network Policy:\">5.2. Describe Network Policy:<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-71\" href=\"https:\/\/itstudy365.com\/blog\/kubernetes-k8s-practice\/#6_Troubleshooting_Networking\" title=\"6. Troubleshooting Networking:\">6. Troubleshooting Networking:<\/a><ul class='ez-toc-list-level-4' ><li class='ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-72\" href=\"https:\/\/itstudy365.com\/blog\/kubernetes-k8s-practice\/#61_Network_Diagnostics\" title=\"6.1. Network Diagnostics:\">6.1. Network Diagnostics:<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-73\" href=\"https:\/\/itstudy365.com\/blog\/kubernetes-k8s-practice\/#62_DNS_Resolution\" title=\"6.2. DNS Resolution:\">6.2. DNS Resolution:<\/a><\/li><\/ul><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Step1Install_Minikube\"><\/span>Step1.Install Minikube<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>1.Install Minikube<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code># Download Minikube package\n$ curl -LO https:\/\/storage.googleapis.com\/minikube\/releases\/latest\/minikube-linux-amd64\n$ ls -l\nminikube-linux-amd64\n\n# Install Minikube(Copy minikube-linux-amd64 to \/usr\/local\/bin\/minikube)\n$ sudo install minikube-linux-amd64 \/usr\/local\/bin\/minikube\n\n# Remove the original file(optional)\n$ rm minikube-linux-amd64<\/code><\/pre><\/div>\n\n\n\n<p>2.Install kubectl<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code># Download kubectl package\n$ curl -LO https:\/\/storage.googleapis.com\/kubernetes-release\/release\/$(curl -s https:\/\/storage.googleapis.com\/kubernetes-release\/release\/stable.txt)\/bin\/linux\/amd64\/kubectl\n$ ls -l\nkubectl\n\n# Install kubectl(Move to \/usr\/local\/bin\/kubectl)\nchmod +x .\/kubectl\nsudo mv .\/kubectl \/usr\/local\/bin\/kubectl<\/code><\/pre><\/div>\n\n\n\n<p>3.Start Minikube (It will take a few minutes in the first time)<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>$ minikube start\n\ud83d\ude04  minikube v1.32.0 on Ubuntu 22.04 (amd64)\n\u2728  Automatically selected the docker driver. Other choices: none, ssh\n\ud83d\udccc  Using Docker driver with root privileges\n\ud83d\udc4d  Starting control plane node minikube in cluster minikube\n\ud83d\ude9c  Pulling base image ...\n\ud83d\udcbe  Downloading Kubernetes v1.28.3 preload ...\n    &gt; preloaded-images-k8s-v18-v1...:  403.35 MiB \/ 403.35 MiB  100.00% 2.87 Mi\n    &gt; gcr.io\/k8s-minikube\/kicbase...:  453.90 MiB \/ 453.90 MiB  100.00% 3.08 Mi\n\ud83d\udd25  Creating docker container (CPUs=2, Memory=2200MB) ...\n\ud83d\udc33  Preparing Kubernetes v1.28.3 on Docker 24.0.7 ...\n    \u25aa Generating certificates and keys ...\n    \u25aa Booting up control plane ...\n    \u25aa Configuring RBAC rules ...\n\ud83d\udd17  Configuring bridge CNI (Container Networking Interface) ...\n\ud83d\udd0e  Verifying Kubernetes components...\n    \u25aa Using image gcr.io\/k8s-minikube\/storage-provisioner:v5\n\ud83c\udf1f  Enabled addons: storage-provisioner, default-storageclass\n\ud83c\udfc4  Done! kubectl is now configured to use &quot;minikube&quot; cluster and &quot;default&quot; namespace by default<\/code><\/pre><\/div>\n\n\n\n<p>4.Verify installation<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>$ kubectl cluster-info\nKubernetes control plane is running at https:\/\/127.0.0.1:32769\nCoreDNS is running at https:\/\/127.0.0.1:32769\/api\/v1\/namespaces\/kube-system\/services\/kube-dns:dns\/proxy<\/code><\/pre><\/div>\n\n\n\n<p>5.Show pods in the <code>kube-system<\/code> namespace<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>$ kubectl get pods -n kube-system\nNAME                               READY   STATUS    RESTARTS      AGE\ncoredns-5dd5756b68-ht4bf           1\/1     Running   0             12h\netcd-minikube                      1\/1     Running   0             12h\nkube-apiserver-minikube            1\/1     Running   0             12h\nkube-controller-manager-minikube   1\/1     Running   0             12h\nkube-proxy-49nbn                   1\/1     Running   0             12h\nkube-scheduler-minikube            1\/1     Running   0             12h\nstorage-provisioner                1\/1     Running   1 (12h ago)   12h<\/code><\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Step2Learn_about_Kubernetes_architectureMaster_Nodes_Pods_etc\"><\/span>Step2.Learn about Kubernetes architecture(Master, Nodes, Pods,  etc.)<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"1_Kubernetes_Architecture\"><\/span>1. Kubernetes Architecture:<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Kubernetes follows a master-worker architecture, where the master node manages the cluster and the worker nodes (also known as minions) execute the tasks assigned by the master. Here&#8217;s a high-level overview:<\/p>\n\n\n\n<ul>\n<li><strong>Master Node:<\/strong>\n<ul>\n<li>The master node is responsible for managing the Kubernetes cluster.<\/li>\n\n\n\n<li>It coordinates all activities in the cluster, including scheduling applications, maintaining desired state, scaling, and rolling out updates.<\/li>\n\n\n\n<li>Components of the master node include:\n<ul>\n<li><strong>API Server<\/strong>: Exposes the Kubernetes API, which allows clients to interact with the cluster.<\/li>\n\n\n\n<li><strong>Scheduler<\/strong>: Assigns pods to nodes based on resource availability and scheduling policies.<\/li>\n\n\n\n<li><strong>Controller Manager<\/strong>: Watches the state of the cluster through the API server and performs cluster management tasks (e.g., node management, replication control, endpoint management).<\/li>\n\n\n\n<li><strong>etcd<\/strong>: A distributed key-value store that stores the cluster&#8217;s configuration data and the state of the cluster.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Worker Node:<\/strong>\n<ul>\n<li>Worker nodes are the machines (physical or virtual) where applications run.<\/li>\n\n\n\n<li>They communicate with the master node and execute the tasks assigned to them.<\/li>\n\n\n\n<li>Components of a worker node include:\n<ul>\n<li><strong>Kubelet<\/strong>: An agent that runs on each node and communicates with the Kubernetes master.<\/li>\n\n\n\n<li><strong>Container Runtime<\/strong>: Software responsible for running containers (e.g., Docker, containerd).<\/li>\n\n\n\n<li><strong>kube-proxy<\/strong>: Maintains network rules on the worker node. It enables communication between different pods and services within the cluster.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<div class=\"wp-block-group is-nowrap is-layout-flex wp-container-1 wp-block-group-is-layout-flex\">\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" loading=\"lazy\" width=\"981\" height=\"541\" src=\"https:\/\/itstudy365.com\/blog\/wp-content\/uploads\/2024\/02\/kubernetes_master.drawio.png\" alt=\"\" class=\"wp-image-926\" srcset=\"https:\/\/itstudy365.com\/blog\/wp-content\/uploads\/2024\/02\/kubernetes_master.drawio.png 981w, https:\/\/itstudy365.com\/blog\/wp-content\/uploads\/2024\/02\/kubernetes_master.drawio-300x165.png 300w, https:\/\/itstudy365.com\/blog\/wp-content\/uploads\/2024\/02\/kubernetes_master.drawio-768x424.png 768w\" sizes=\"(max-width: 981px) 100vw, 981px\" \/><\/figure>\n<\/div>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Step3Familiarize_Kubernetes_terminology_Deployments_ReplicaSets_Pods_Services_etc\"><\/span>Step3.Familiarize Kubernetes terminology (Deployments, ReplicaSets, Pods, Services, etc.)<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"1_Pods\"><\/span>1. Pods:<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<ul>\n<li><strong>Definition<\/strong>: A Pod is the smallest deployable unit in Kubernetes, representing one or more containers that are tightly coupled and share resources like networking and storage.<\/li>\n\n\n\n<li><strong>Usage<\/strong>: Pods are the basic building blocks of Kubernetes applications. They encapsulate the application&#8217;s containers, storage resources, and unique network IP.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"2_Deployments\"><\/span>2. Deployments:<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<ul>\n<li><strong>Definition<\/strong>: A Deployment is a Kubernetes resource that manages a replicated application, ensuring that a specified number of pod replicas are running at any given time.<\/li>\n\n\n\n<li><strong>Usage<\/strong>: Deployments are commonly used for managing stateless applications. They provide declarative updates, rollbacks, and scaling capabilities for application replicas.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"3_ReplicaSets\"><\/span>3. ReplicaSets:<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<ul>\n<li><strong>Definition<\/strong>: A ReplicaSet is a Kubernetes resource that ensures a specified number of identical pod replicas are running at any given time.<\/li>\n\n\n\n<li><strong>Usage<\/strong>: ReplicaSets are often managed by Deployments. They help maintain the desired number of pods and handle scaling up or down based on defined criteria.<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" loading=\"lazy\" width=\"721\" height=\"481\" src=\"https:\/\/itstudy365.com\/blog\/wp-content\/uploads\/2024\/02\/kubernetes_deployment.drawio.png\" alt=\"\" class=\"wp-image-930\" srcset=\"https:\/\/itstudy365.com\/blog\/wp-content\/uploads\/2024\/02\/kubernetes_deployment.drawio.png 721w, https:\/\/itstudy365.com\/blog\/wp-content\/uploads\/2024\/02\/kubernetes_deployment.drawio-300x200.png 300w\" sizes=\"(max-width: 721px) 100vw, 721px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"4_Services\"><\/span>4. Services:<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<ul>\n<li><strong>Definition<\/strong>: A Service is a Kubernetes resource that provides a consistent way to access a set of pods. It defines a logical set of pods and a policy by which to access them.<\/li>\n\n\n\n<li><strong>Usage<\/strong>: Services enable networking and load balancing within the Kubernetes cluster. They provide a stable endpoint (IP address and port) for accessing the application running inside pods, regardless of pod changes or failures.<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" loading=\"lazy\" width=\"441\" height=\"501\" src=\"https:\/\/itstudy365.com\/blog\/wp-content\/uploads\/2024\/02\/kubernetes_services.drawio-1.png\" alt=\"\" class=\"wp-image-935\" srcset=\"https:\/\/itstudy365.com\/blog\/wp-content\/uploads\/2024\/02\/kubernetes_services.drawio-1.png 441w, https:\/\/itstudy365.com\/blog\/wp-content\/uploads\/2024\/02\/kubernetes_services.drawio-1-264x300.png 264w\" sizes=\"(max-width: 441px) 100vw, 441px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"5_ConfigMaps\"><\/span>5. ConfigMaps:<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<ul>\n<li><strong>Definition<\/strong>: ConfigMaps are Kubernetes resources used to store configuration data in key-value pairs. They decouple configuration from the container images, allowing for easier management and updates.<\/li>\n\n\n\n<li><strong>Usage<\/strong>: ConfigMaps can be mounted as files or environment variables inside pods, providing configuration settings to applications without requiring changes to the application code.<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" loading=\"lazy\" width=\"641\" height=\"381\" src=\"https:\/\/itstudy365.com\/blog\/wp-content\/uploads\/2024\/02\/kubernetes_configmaps.drawio.png\" alt=\"\" class=\"wp-image-937\" srcset=\"https:\/\/itstudy365.com\/blog\/wp-content\/uploads\/2024\/02\/kubernetes_configmaps.drawio.png 641w, https:\/\/itstudy365.com\/blog\/wp-content\/uploads\/2024\/02\/kubernetes_configmaps.drawio-300x178.png 300w\" sizes=\"(max-width: 641px) 100vw, 641px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"6_Secrets\"><\/span>6. Secrets:<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<ul>\n<li><strong>Definition<\/strong>: Secrets are Kubernetes resources used to store sensitive information, such as passwords, tokens, or certificates, in an encrypted format.<\/li>\n\n\n\n<li><strong>Usage<\/strong>: Secrets provide a secure way to store and distribute sensitive data to pods. They can be mounted as files or environment variables, ensuring secure access within the application.<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" loading=\"lazy\" width=\"511\" height=\"301\" src=\"https:\/\/itstudy365.com\/blog\/wp-content\/uploads\/2024\/02\/kubernetes_secrets.drawio-1.png\" alt=\"\" class=\"wp-image-940\" srcset=\"https:\/\/itstudy365.com\/blog\/wp-content\/uploads\/2024\/02\/kubernetes_secrets.drawio-1.png 511w, https:\/\/itstudy365.com\/blog\/wp-content\/uploads\/2024\/02\/kubernetes_secrets.drawio-1-300x177.png 300w\" sizes=\"(max-width: 511px) 100vw, 511px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"7_Volumes\"><\/span>7. Volumes:<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<ul>\n<li><strong>Definition<\/strong>: Kubernetes Volumes are persistent storage units that exist beyond the lifecycle of individual Pods.<\/li>\n\n\n\n<li><strong>Usage<\/strong>: They provide data persistence for containers and enable sharing data between containers in a Pod.<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" loading=\"lazy\" width=\"476\" height=\"281\" src=\"https:\/\/itstudy365.com\/blog\/wp-content\/uploads\/2024\/02\/kubernetes_volumes.drawio.png\" alt=\"\" class=\"wp-image-941\" srcset=\"https:\/\/itstudy365.com\/blog\/wp-content\/uploads\/2024\/02\/kubernetes_volumes.drawio.png 476w, https:\/\/itstudy365.com\/blog\/wp-content\/uploads\/2024\/02\/kubernetes_volumes.drawio-300x177.png 300w\" sizes=\"(max-width: 476px) 100vw, 476px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Step4Deploy_a_simple_application_eg_a_web_server\"><\/span>Step4.Deploy a simple application (e.g., a web server)<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"1_Create_a_Deployment_Manifest_deploymentyaml\"><\/span>1. Create a Deployment Manifest (deployment.yaml)<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>apiVersion: apps\/v1\nkind: Deployment\nmetadata:\n  name: web-server-deployment\nspec:\n  replicas: 3        # Number of pod replicas to run\n  selector:\n    matchLabels:\n      app: web-server\n  template:\n    metadata:\n      labels:\n        app: web-server\n    spec:\n      containers:\n        - name: web-server\n          image: nginx:1.14.2   # Use the NGINX Docker image as an example\n          ports:\n            - containerPort: 80  # Port on which the container listens<\/code><\/pre><\/div>\n\n\n\n<ul>\n<li>The desired number of replicas (3 in this case).<\/li>\n\n\n\n<li>Labels to select the pods managed by this deployment.<\/li>\n\n\n\n<li>Configuration for the pod template, including the container specification (using the NGINX Docker image and exposing port 80).<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"2_Create_a_Service_Manifest_serviceyaml\"><\/span>2. Create a Service Manifest (service.yaml)<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>apiVersion: v1\nkind: Service\nmetadata:\n  name: web-server-service\nspec:\n  selector:\n    app: web-server\n  ports:\n    - protocol: TCP\n      port: 80          # Port on which the service listens\n      targetPort: 80    # Port to forward traffic to in the pods\n      name: wsp         # Just for reference. Any name is OK.\n  type: ClusterIP<\/code><\/pre><\/div>\n\n\n\n<ul>\n<li>Labels to select the pods to expose.<\/li>\n\n\n\n<li>Configuration for the service ports, including the port to listen on and the target port in the pods.<\/li>\n\n\n\n<li>The service type as ClusterIP, which exposes the service internally within the cluster.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"3_Apply_the_Manifests\"><\/span>3. Apply the Manifests<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>$ kubectl apply -f deployment.yaml\ndeployment.apps\/web-server-deployment created\n\n$ kubectl apply -f service.yaml\nservice\/web-server-service created<\/code><\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"4_Verify_Deployment_and_Service\"><\/span>4. Verify Deployment and Service<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>$ kubectl get deployments\nNAME                    READY   UP-TO-DATE   AVAILABLE   AGE\nweb-server-deployment   3\/3     3            3           91s\n\n$ kubectl get pods\nNAME                                     READY   STATUS    RESTARTS   AGE\nweb-server-deployment-6446bb766c-4skzc   1\/1     Running   0          106s\nweb-server-deployment-6446bb766c-9f8fr   1\/1     Running   0          106s\nweb-server-deployment-6446bb766c-h4zjg   1\/1     Running   0          106s\n\n$ kubectl get services\nNAME                 TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)   AGE\nkubernetes           ClusterIP   10.xx.x.x       &lt;none&gt;        443\/TCP   6d1h\nweb-server-service   ClusterIP   10.yyy.yyy.yy   &lt;none&gt;        8080\/TCP    109s\n\n$ kubectl describe service web-server-service\nName:              web-server-service\nNamespace:         default\nLabels:            &lt;none&gt;\nAnnotations:       &lt;none&gt;\nSelector:          app=web-server\nType:              ClusterIP\nIP Family Policy:  SingleStack\nIP Families:       IPv4\nIP:                10.yyy.yyy.yy\nIPs:               10.yyy.yyy.yy\nPort:              wsp  80\/TCP\nTargetPort:        8080\/TCP\nEndpoints:         10.zzz.z.33:8080,10.zzz.z.34:8080,10.zzz.z.35:8080\nSession Affinity:  None\nEvents:            &lt;none&gt;<\/code><\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"5_Access_the_Web_Server\"><\/span>5. Access the Web Server<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code># Expose the port number\n$ kubectl expose deploy\/web-server-deployment --port=80\n\n# Port forwarding\n$ kubectl port-forward svc\/web-server-deployment 8080:80\nForwarding from 127.0.0.1:8080 -&gt; 80\nForwarding from [::1]:8080 -&gt; 80\n\n# This will keep running on the console, &quot;ctrl + c&quot; to exit<\/code><\/pre><\/div>\n\n\n\n<p>Open a web browser and navigate to the &#8220;http:\/\/localhost:8080\/&#8221; to see the default NGINX welcome page.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" loading=\"lazy\" width=\"557\" height=\"212\" src=\"https:\/\/itstudy365.com\/blog\/wp-content\/uploads\/2024\/02\/image-1.png\" alt=\"\" class=\"wp-image-944\" srcset=\"https:\/\/itstudy365.com\/blog\/wp-content\/uploads\/2024\/02\/image-1.png 557w, https:\/\/itstudy365.com\/blog\/wp-content\/uploads\/2024\/02\/image-1-300x114.png 300w\" sizes=\"(max-width: 557px) 100vw, 557px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Step5Use_kubectl_commands_to_interact_with_your_Kubernetes_cluster\"><\/span>Step5.Use <code>kubectl<\/code> commands to interact with your Kubernetes cluster.<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"1List_Pods\"><\/span>1.List Pods<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>This command will list all the pods running in your cluster.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>$ kubectl get pods<\/code><\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"2Describe_a_Pod\"><\/span>2.Describe a Pod<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Replace <code>&lt;pod_name&gt;<\/code> with the name of a specific pod from the previous command output. This command provides detailed information about the specified pod, including its status, IP address, labels, and events.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>$ kubectl describe pod &lt;pod_name&gt;<\/code><\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"3List_Services\"><\/span>3.List Services<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>This command will list all the services in your cluster.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>$ kubectl get services<\/code><\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"4Descrive_a_Service\"><\/span>4.Descrive a Service<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Replace <code>&lt;service_name&gt;<\/code> with the name of a specific service from the previous command output. This command provides detailed information about the specified service, including its endpoints, ports, and selectors.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>$ kubectl describe service &lt;service_name&gt;<\/code><\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"5List_Deployments\"><\/span>5.List Deployments<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>This command will list all the deployments in your cluster.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>$ kubectl get deployments<\/code><\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"6Describe_a_Deployment\"><\/span>6.Describe a Deployment<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Replace <code>&lt;deployment_name&gt;<\/code> with the name of a specific deployment from the previous command output. This command provides detailed information about the specified deployment, including its replicas, strategy, and events.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>$ kubectl describe deployment &lt;deployment_name&gt;<\/code><\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"7View_logs_of_a_Pod\"><\/span>7.View logs of a Pod<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Replace <code>&lt;pod_name&gt;<\/code> with the name of a specific pod. This command will display the logs of the specified pod.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>$ kubectl logs &lt;pod_name&gt;<\/code><\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"8Execute_a_Command_in_a_Pod\"><\/span>8.Execute a Command in a Pod<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Replace <code>&lt;pod_name&gt;<\/code> with the name of a specific pod, and <code>&lt;command&gt;<\/code> with the command you want to execute. This command allows you to run arbitrary commands inside the specified pod.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>$ kubectl exec -it &lt;pod_name&gt; -- &lt;command&gt;<\/code><\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"9Delete_Resources\"><\/span>9.Delete Resources<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Replace <code>&lt;resource_type&gt;<\/code> with the type of Kubernetes resource you want to delete (e.g., pod, service, deployment) and <code>&lt;resource_name&gt;<\/code> with the name of the resource you want to delete. This command allows you to delete resources from your cluster.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>$ kubectl delete &lt;resource_type&gt; &lt;resource_name&gt;<\/code><\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Step6Learn_common_troubleshooting_techniques_in_Kubernetes_eg_checking_pod_status_logs_describing_resources\"><\/span>Step6.Learn common troubleshooting techniques in Kubernetes (e.g., checking pod status, logs, describing resources).<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"1_Checking_Pod_Status\"><\/span>1. Checking Pod Status<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>This command lists all pods in the default namespace along with their status.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>$ kubectl get pods<\/code><\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"2_Describing_a_Pod\"><\/span>2. Describing a Pod<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<ul>\n<li>Replace <code>&lt;pod_name&gt;<\/code> with the name of the pod you want to inspect.<\/li>\n\n\n\n<li>This command provides detailed information about the specified pod, including its status, IP address, labels, and events.<\/li>\n<\/ul>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>$ kubectl describe pod &lt;pod_name&gt;<\/code><\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"3_Viewing_Pod_Logs\"><\/span>3. Viewing Pod Logs<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<ul>\n<li>Replace <code>&lt;pod_name&gt;<\/code> with the name of the pod you want to view logs for.<\/li>\n\n\n\n<li>This command displays the logs produced by the specified pod.<\/li>\n<\/ul>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>$ kubectl logs &lt;pod_name&gt;<\/code><\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"4_Following_Pod_Logs\"><\/span>4. Following Pod Logs<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Similar to the previous command but continuously streams logs as they&#8217;re generated.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>$ kubectl logs -f &lt;pod_name&gt;<\/code><\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"5_Executing_Commands_in_a_Pod\"><\/span>5. Executing Commands in a Pod<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<ul>\n<li>Replace <code>&lt;pod_name&gt;<\/code> with the name of the pod you want to execute a command in, and <code>&lt;command&gt;<\/code> with the command you want to run.<\/li>\n\n\n\n<li>This command allows you to run arbitrary commands inside the specified pod.<\/li>\n<\/ul>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>$ kubectl exec -it &lt;pod_name&gt; -- &lt;command&gt;<\/code><\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"6_Describing_Resources\"><\/span>6. Describing Resources<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<ul>\n<li>Replace <code>&lt;resource_type&gt;<\/code> with the type of Kubernetes resource you want to describe (e.g., pod, service, deployment), and <code>&lt;resource_name&gt;<\/code> with the name of the resource.<\/li>\n\n\n\n<li>This command provides detailed information about the specified resource, including its configuration and status.<\/li>\n<\/ul>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>$ kubectl describe &lt;resource_type&gt; &lt;resource_name&gt;<\/code><\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"7_Checking_Service_Status\"><\/span>7. Checking Service Status<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>This command lists all services in the default namespace along with their status.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>$ kubectl get services<\/code><\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"8_Checking_Deployment_Status\"><\/span>8. Checking Deployment Status<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>This command lists all deployments in the default namespace along with their status.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>$ kubectl get deployments<\/code><\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"9_Troubleshooting_with_Events\"><\/span>9. Troubleshooting with Events<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>This command lists recent events in the cluster, which can provide insights into ongoing issues.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>$ kubectl get events<\/code><\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"10_Describe_Node\"><\/span>10. Describe Node<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<ul>\n<li>Replace <code>&lt;node_name&gt;<\/code> with the name of the node you want to describe.<\/li>\n\n\n\n<li>This command provides detailed information about the specified node, including its capacity, conditions, and allocated resources.<\/li>\n<\/ul>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>$ kubectl describe node &lt;node_name&gt;<\/code><\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Step7Understand_the_role_of_Deployments_and_ReplicaSets_in_managing_containerized_applications\"><\/span>Step7.Understand the role of Deployments and ReplicaSets in managing containerized applications.<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Deployments\"><\/span>Deployments:<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Deployments are Kubernetes resources used to manage the lifecycle of pods and ensure that a specified number of pod replicas are running at all times. Deployments are commonly used to define and manage stateless applications. Here&#8217;s a breakdown of their key features and functionalities:<\/p>\n\n\n\n<ol>\n<li><strong>Pod Template Specification<\/strong>:\n<ul>\n<li>Deployments define a pod template specification, which includes details such as the container image, environment variables, volumes, and ports for the pods.<\/li>\n\n\n\n<li>The pod template serves as a blueprint for creating and managing pod replicas.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Replica Management<\/strong>:\n<ul>\n<li>Deployments ensure that a desired number of pod replicas, specified by the <code>replicas<\/code> field, are running at all times.<\/li>\n\n\n\n<li>If a pod fails or becomes unavailable, the Deployment automatically replaces it with a new pod to maintain the desired replica count.<\/li>\n\n\n\n<li>Deployments facilitate rolling updates and rollbacks by gradually updating pods with new configurations or reverting to previous versions.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Scaling<\/strong>:\n<ul>\n<li>Deployments support horizontal scaling by allowing you to scale the number of pod replicas up or down dynamically based on resource demands.<\/li>\n\n\n\n<li>You can adjust the <code>replicas<\/code> field in the Deployment manifest or use <code>kubectl scale<\/code> command to scale deployments.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Rolling Updates and Rollbacks<\/strong>:\n<ul>\n<li>Deployments enable seamless rolling updates, allowing you to update the container image or configuration of pods without downtime.<\/li>\n\n\n\n<li>If an update causes issues, Deployments support automatic rollbacks to the previous stable version.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code># Definition of Deployment\napiVersion: apps\/v1\nkind: Deployment\nmetadata:\n  # Must be unique in the Namespace\n  name: deployment-sample\nspec:\n  # Number of replica (Replica Management, Scaling)\n  replicas: 2\n  # Pod Template (Pod Template Specification)\n  template:\n    metadata:\n      labels:\n        # Mandatory the label definition\n        app: deployment-sample\n    spec:\n      containers:\n      - name: nginx\n        image: nginx:1.10\n        ports:\n        - containerPort: 80<\/code><\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"ReplicaSets\"><\/span>ReplicaSets:<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>ReplicaSets are lower-level Kubernetes resources that ensure a specified number of pod replicas are running and maintained according to a defined template. They are typically created and managed by Deployments but can also be used independently. Here&#8217;s an overview of their role and functionality:<\/p>\n\n\n\n<ol>\n<li><strong>Pod Replication<\/strong>:\n<ul>\n<li>ReplicaSets are responsible for maintaining a specified number of identical pod replicas defined by the <code>replicas<\/code> field in the ReplicaSet manifest.<\/li>\n\n\n\n<li>They monitor the status of pods and create or delete pod replicas as needed to match the desired state.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Pod Template<\/strong>:\n<ul>\n<li>Similar to Deployments, ReplicaSets define a pod template specification that includes container images, configuration, and metadata for the pods it manages.<\/li>\n\n\n\n<li>The pod template serves as a blueprint for creating and managing pod replicas within the ReplicaSet.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Scalability<\/strong>:\n<ul>\n<li>ReplicaSets support horizontal scaling by allowing you to adjust the number of pod replicas dynamically.<\/li>\n\n\n\n<li>You can update the <code>replicas<\/code> field in the ReplicaSet manifest or use <code>kubectl scale<\/code> command to scale the number of replicas.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Replacement and Healing<\/strong>:\n<ul>\n<li>If a pod replica fails or becomes unavailable, the ReplicaSet automatically creates a new pod to replace it, ensuring that the desired replica count is maintained.<\/li>\n\n\n\n<li>ReplicaSets contribute to the high availability and fault tolerance of applications by automatically healing and replacing failed pods.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code># Definition of ReplicaSet\napiVersion: apps\/v1\nkind: ReplicaSet\nmetadata:\n  name: sample-replicaset\nspec:\n  # Number of replica (Pod Replication, Scalability)\n  replicas: 4\n  selector:\n    matchLabels:\n      app: sample-replicaset\n  # Pod Template\n  template:\n    metadata:\n      labels:\n        app: sample-replicaset\n    spec:\n      containers:\n      - name: nginx-container\n        image: nginx:latest<\/code><\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Relationship_between_Deployments_and_ReplicaSets\"><\/span>Relationship between Deployments and ReplicaSets:<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<ul>\n<li>Deployments use ReplicaSets internally to manage pod replicas. When you create a Deployment, Kubernetes creates a corresponding ReplicaSet based on the pod template specified in the Deployment manifest.<\/li>\n\n\n\n<li>Deployments provide higher-level functionality such as rolling updates, rollbacks, and declarative management of application deployments.<\/li>\n\n\n\n<li>ReplicaSets focus on ensuring the desired number of pod replicas are maintained and handling pod lifecycle events like scaling, replacement, and healing.<\/li>\n<\/ul>\n\n\n\n<p>In summary, Deployments and ReplicaSets work together to manage containerized applications in Kubernetes. Deployments provide orchestration and lifecycle management capabilities, while ReplicaSets handle pod replication and maintenance to ensure application availability and scalability.<br><strong>If we define &#8220;Deployment manifest&#8221;, we don&#8217;t need to define &#8220;ReplicaSet manifest&#8221; individually.<\/strong><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Step8Experiment_with_scaling_deployments_and_updating_application_versions\"><\/span>Step8.Experiment with scaling deployments and updating application versions.<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Scaling_Deployments\"><\/span>Scaling Deployments:<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"1_View_Current_Deployments\"><\/span>1. View Current Deployments:<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p>First, let&#8217;s check the current Deployments in your cluster:<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>kubectl get deployments<\/code><\/pre><\/div>\n\n\n\n<p><\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"2_Scale_Deployment\"><\/span>2. Scale Deployment:<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p>To scale a Deployment named <code>web-server-service<\/code> to a specific number of replicas (e.g., 5 replicas), use the following command:<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>kubectl scale deployment web-server-service --replicas=5<\/code><\/pre><\/div>\n\n\n\n<p>Replace <code>my-deployment<\/code> with the name of your Deployment.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"3_Verify_Scaling\"><\/span>3. Verify Scaling:<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p>Check the status of your Deployment to ensure it has scaled to the desired number of replicas:<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>kubectl get deployments kubectl get pods<\/code><\/pre><\/div>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Updating_Application_Versions\"><\/span>Updating Application Versions:<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"1_Update_Deployment_Image\"><\/span>1. Update Deployment Image:<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p>To update the container image of your Deployment, edit the Deployment manifest file (<code>deployment.yaml<\/code>) to specify the new image version. For example:<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>apiVersion: apps\/v2\nkind: Deployment\nmetadata:\n  name: web-server-deployment\nspec:\n  replicas: 5        # Update 3 to 5\n  selector:\n    matchLabels:\n      app: web-server\n  template:\n    metadata:\n      labels:\n        app: web-server\n    spec:\n      containers:\n        - name: web-server\n          image: nginx:1.14.2\n          ports:\n            - containerPort: 80<\/code><\/pre><\/div>\n\n\n\n<p>Save the changes to the file.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"2_Apply_Updated_Manifest\"><\/span>2. Apply Updated Manifest:<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p>Apply the updated Deployment manifest to apply the changes and trigger the rolling update:<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>kubectl apply -f deployment.yaml<\/code><\/pre><\/div>\n\n\n\n<p><\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"3_Verify_Update\"><\/span>3. Verify Update:<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p>Check the status of your Deployment to ensure the update is in progress and pods are being rolled out with the new image version:<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>kubectl get deployments kubectl get pods --watch<\/code><\/pre><\/div>\n\n\n\n<p>The <code>--watch<\/code> flag will continuously watch for changes in pod status.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"4_Check_Rollout_Status\"><\/span>4. Check Rollout Status:<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p>Monitor the rollout status to see the progress of the update:<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>kubectl rollout status deployment\/web-server-service<\/code><\/pre><\/div>\n\n\n\n<p><\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"5_Rollback_Update_Optional\"><\/span>5. Rollback Update (Optional):<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p>If the update encounters issues or you need to rollback to the previous version, use the following command:<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>kubectl rollout undo deployment\/web-server-service<\/code><\/pre><\/div>\n\n\n\n<p>This will rollback to the previous stable version of the Deployment.<\/p>\n\n\n\n<p>Step9.Explore Kubernetes networking concepts.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"1_Pod_Networking\"><\/span>1. Pod Networking:<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"11_List_Pods\"><\/span>1.1. List Pods:<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>kubectl get pods<\/code><\/pre><\/div>\n\n\n\n<p>This command lists all the pods in the default namespace.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"12_Describe_Pod_Networking\"><\/span>1.2. Describe Pod Networking:<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>kubectl describe pod &lt;pod_name&gt;<\/code><\/pre><\/div>\n\n\n\n<p>Replace <code>&lt;pod_name><\/code> with the name of a specific pod. This command provides detailed information about the pod, including its networking settings, IP address, and network interfaces.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"13_Connect_to_a_Pod\"><\/span>1.3. Connect to a Pod:<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>kubectl exec -it &lt;pod_name&gt; -- \/bin\/sh<\/code><\/pre><\/div>\n\n\n\n<p>Replace <code>&lt;pod_name><\/code> with the name of a specific pod. This command allows you to connect to a pod and execute commands inside its container.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"2_Service_Networking\"><\/span>2. Service Networking:<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"21_List_Services\"><\/span>2.1. List Services:<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>kubectl get services<\/code><\/pre><\/div>\n\n\n\n<p>This command lists all the services in the default namespace.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"22_Describe_Service_Networking\"><\/span>2.2. Describe Service Networking:<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>kubectl describe service &lt;service_name&gt;<\/code><\/pre><\/div>\n\n\n\n<p>Replace <code>&lt;service_name><\/code> with the name of a specific service. This command provides detailed information about the service, including its endpoints, cluster IP, ports, and selectors.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"23_Access_Service_from_Inside_Cluster\"><\/span>2.3. Access Service from Inside Cluster:<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p>You can access a service from inside the cluster using its cluster IP and port. For example:<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>curl http:\/\/&lt;service_name&gt;:&lt;port&gt;<\/code><\/pre><\/div>\n\n\n\n<p>Replace <code>&lt;service_name><\/code> with the name of the service and <code>&lt;port><\/code> with the service port.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"3_Node_Networking\"><\/span>3. Node Networking:<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"31_List_Nodes\"><\/span>3.1. List Nodes:<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>kubectl get nodes<\/code><\/pre><\/div>\n\n\n\n<p>This command lists all the nodes in the cluster.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"32_Describe_Node_Networking\"><\/span>3.2. Describe Node Networking:<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>kubectl describe node &lt;node_name&gt;<\/code><\/pre><\/div>\n\n\n\n<p>Replace <code>&lt;node_name><\/code> with the name of a specific node. This command provides detailed information about the node, including its IP address, allocated resources, and network configuration.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"4_Ingress_Networking\"><\/span>4. Ingress Networking:<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"41_List_Ingress_Resources\"><\/span>4.1. List Ingress Resources:<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>kubectl get ingresses<\/code><\/pre><\/div>\n\n\n\n<p>This command lists all the Ingress resources in the default namespace.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"42_Describe_Ingress_Networking\"><\/span>4.2. Describe Ingress Networking:<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>kubectl describe ingress &lt;ingress_name&gt;<\/code><\/pre><\/div>\n\n\n\n<p>Replace <code>&lt;ingress_name><\/code> with the name of a specific Ingress resource. This command provides detailed information about the Ingress resource, including its rules, backend services, and TLS settings.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"5_Network_Policies\"><\/span>5. Network Policies:<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"51_List_Network_Policies\"><\/span>5.1. List Network Policies:<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>kubectl get networkpolicies<\/code><\/pre><\/div>\n\n\n\n<p>This command lists all the Network Policies in the default namespace.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"52_Describe_Network_Policy\"><\/span>5.2. Describe Network Policy:<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>kubectl describe networkpolicy &lt;network_policy_name&gt;<\/code><\/pre><\/div>\n\n\n\n<p>Replace <code>&lt;network_policy_name><\/code> with the name of a specific Network Policy. This command provides detailed information about the Network Policy, including its rules for controlling pod-to-pod communication.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"6_Troubleshooting_Networking\"><\/span>6. Troubleshooting Networking:<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"61_Network_Diagnostics\"><\/span>6.1. Network Diagnostics:<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>kubectl exec &lt;pod_name&gt; -- ping &lt;ip_address&gt;<\/code><\/pre><\/div>\n\n\n\n<p>Replace <code>&lt;pod_name><\/code> with the name of a specific pod and <code>&lt;ip_address><\/code> with the IP address you want to ping. This command allows you to diagnose network connectivity between pods.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"62_DNS_Resolution\"><\/span>6.2. DNS Resolution:<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>kubectl exec &lt;pod_name&gt; -- nslookup &lt;service_name&gt;<\/code><\/pre><\/div>\n\n\n\n<p>Replace <code>&lt;pod_name><\/code> with the name of a specific pod and <code>&lt;service_name><\/code> with the DNS name of a service. This command checks DNS resolution for a service from inside a pod.<\/p>\n\n\n\n<p>Step10.Create different types of Services (ClusterIP, NodePort, LoadBalancer)<\/p>\n\n\n\n<p>Step11.Learn about PersistentVolumes (PVs) and PersistentVolumeClaims (PVCs) in Kubernetes<\/p>\n\n\n\n<p>Step12.Practice creating and using PersistentVolumes for stateful applications<\/p>\n\n\n\n<p>Step13.Learn about Helm, a package manager for Kubernetes<\/p>\n\n\n\n<p>Step14.Create and use Helm charts to package and deploy applications<\/p>\n\n\n\n<p>Step15.Practice upgrading application versions and rolling back changes using Kubernetes Deployment strategies<\/p>\n\n\n\n<p>Step16.Explore Horizontal Pod Autoscaling (HPA) and Vertical Pod Autoscaling (VPA)<\/p>\n\n\n\n<p>Step17.Experiment with setting up autoscaling for your deployments<\/p>\n\n\n\n<p>Step18.Learn about Kubernetes Operators and how they automate operational tasks<\/p>\n\n\n\n<p>Step19.Experiment with existing Operators or create your own<\/p>\n\n\n\n<p>Step20.Explore Kubernetes monitoring solutions like Prometheus and Grafana<\/p>\n\n\n\n<p>Step21.Set up monitoring for your cluster and applications<\/p>\n\n\n\n<p>Step22.Learn about Kubernetes security best practices<\/p>\n\n\n\n<p>Step23.Practice configuring Role-Based Access Control (RBAC) for your cluster<\/p>\n\n\n\n<p>Step24.Understand StatefulSets and their use cases for stateful applications<\/p>\n\n\n\n<p>Step25.Deploy a stateful application using StatefulSets<\/p>\n\n\n\n<p>Step26.Learn about Custom Resource Definitions and Custom Resources<\/p>\n\n\n\n<p>Step27.Experiment with creating and using custom resources<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The target Kubernetes(minikube&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"_links":{"self":[{"href":"https:\/\/itstudy365.com\/blog\/wp-json\/wp\/v2\/pages\/873"}],"collection":[{"href":"https:\/\/itstudy365.com\/blog\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/itstudy365.com\/blog\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/itstudy365.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/itstudy365.com\/blog\/wp-json\/wp\/v2\/comments?post=873"}],"version-history":[{"count":17,"href":"https:\/\/itstudy365.com\/blog\/wp-json\/wp\/v2\/pages\/873\/revisions"}],"predecessor-version":[{"id":1145,"href":"https:\/\/itstudy365.com\/blog\/wp-json\/wp\/v2\/pages\/873\/revisions\/1145"}],"wp:attachment":[{"href":"https:\/\/itstudy365.com\/blog\/wp-json\/wp\/v2\/media?parent=873"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}