{"id":3818,"date":"2024-03-11T18:16:27","date_gmt":"2024-03-11T18:16:27","guid":{"rendered":"https:\/\/code2deploy.com\/blog\/?p=3818"},"modified":"2024-03-11T18:16:28","modified_gmt":"2024-03-11T18:16:28","slug":"mastering-kubernetes-a-comprehensive-guide-to-every-command","status":"publish","type":"post","link":"https:\/\/code2deploy.com\/blog\/mastering-kubernetes-a-comprehensive-guide-to-every-command\/","title":{"rendered":"Mastering Kubernetes: A Comprehensive Guide to Every Command"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\"><strong>Introduction:<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Welcome to our comprehensive guide on Kubernetes commands! Kubernetes has become the de facto standard for container orchestration, empowering developers and operations teams to efficiently manage containerized applications at scale. However, mastering Kubernetes commands can be a daunting task due to its vast ecosystem and extensive feature set.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In this blog, we&#8217;ll break down each Kubernetes command, providing clear explanations and practical examples to help you understand and utilize them effectively. Whether you&#8217;re a beginner or an experienced Kubernetes user, this guide will serve as a valuable resource for navigating the complexities of Kubernetes command-line interface (CLI).<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Let&#8217;s dive in!<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>1. kubectl create<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Description:<\/strong> kubectl create is used to create Kubernetes resources from configuration files or directly via command-line arguments.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Example:<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"># Create a deployment named nginx-deployment<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>kubectl create deployment nginx-deployment &#8211;image=nginx:latest<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"># Create a service named nginx-service of type NodePort to expose the deployment<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>kubectl create service nodeport nginx-service &#8211;tcp=80:80<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Explanation:<\/strong> In the example above, we create a deployment named nginx-deployment using the nginx:latest image. Then, we create a service named nginx-service of type NodePort to expose the deployment on port 80.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>2. kubectl get<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Description<\/strong>: kubectl get is used to retrieve information about Kubernetes resources.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Example:<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"># Get all pods in the current namespace<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>kubectl get pods<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"># Get detailed information about a specific pod<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>kubectl get pod nginx-deployment-65b9c54f9f-7vmhs -o yaml<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Explanation: <\/strong>The first command retrieves information about all pods in the current namespace, while the second command provides detailed information about a specific pod identified by its name (nginx-deployment-65b9c54f9f-7vmhs) in YAML format.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>3. kubectl describe<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Description: <\/strong>kubectl describe provides detailed information about Kubernetes resources.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Example:<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"># Describe a pod<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>kubectl describe pod nginx-deployment-65b9c54f9f-7vmhs<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Explanation:<\/strong> This command gives a detailed description of the specified pod, including its status, events, and associated metadata.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>4. kubectl apply<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Description:<\/strong> kubectl apply is used to apply configuration changes to Kubernetes resources.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Example:<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"># Apply changes from a YAML configuration file<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>kubectl apply -f deployment.yaml<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Explanation:<\/strong> The command applies the changes defined in the deployment.yaml file to the Kubernetes cluster.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>5. kubectl delete<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Description:<\/strong> kubectl delete is used to delete Kubernetes resources.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Example:<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"># Delete a pod<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>kubectl delete pod nginx-deployment-65b9c54f9f-7vmhs<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Explanation: <\/strong>This command deletes the specified pod from the cluster.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>6. kubectl exec<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Description: <\/strong>kubectl exec allows you to execute commands inside a container running in a pod.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Example:<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"># Execute a shell command inside a pod<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>kubectl exec -it nginx-deployment-65b9c54f9f-7vmhs &#8212; \/bin\/bash<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"># Execute a command directly without entering the shell<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>kubectl exec nginx-deployment-65b9c54f9f-7vmhs &#8212; ls \/app<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Explanation:<\/strong> The first command opens an interactive shell (\/bin\/bash) inside the specified pod, allowing you to run multiple commands interactively. The second command executes a single command (ls \/app) inside the pod without entering the shell.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>7. kubectl logs<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Description:<\/strong> kubectl logs retrieves the logs of a container in a pod.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Example:<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"># Get logs of a container in a pod<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>kubectl logs nginx-deployment-65b9c54f9f-7vmhs<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"># Get logs of a specific container in a pod with multiple containers<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>kubectl logs nginx-deployment-65b9c54f9f-7vmhs -c nginx-container<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Explanation: <\/strong>The first command retrieves the logs of all containers in the specified pod. The second command retrieves logs from a specific container (nginx-container) within the same pod.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>8. kubectl scale<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Description: <\/strong>kubectl scale is used to scale the number of replicas of a deployment, replicaset, or statefulset.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Example:<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"># Scale a deployment to 3 replicas<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>kubectl scale deployment nginx-deployment &#8211;replicas=3<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Explanation:<\/strong> This command scales the number of replicas of the nginx-deployment to 3, effectively increasing the number of instances running the application.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>9. kubectl edit<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Description: <\/strong>kubectl edit allows you to edit the configuration of Kubernetes resources directly in the default text editor.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Example:<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"># Edit the configuration of a deployment<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>kubectl edit deployment nginx-deployment<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Explanation:<\/strong> This command opens the deployment configuration in the default text editor (usually vi or nano), allowing you to make changes to the configuration interactively.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>10. kubectl rollout<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Description: <\/strong>kubectl rollout manages rollouts of updates to Kubernetes resources like deployments.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Example:<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"># View the rollout history of a deployment<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>kubectl rollout history deployment\/nginx-deployment<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"># Roll back to a previous revision of a deployment<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>kubectl rollout undo deployment\/nginx-deployment &#8211;to-revision=2<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Explanation: <\/strong>The first command retrieves the rollout history of the nginx-deployment, while the second command rolls back the deployment to a specific revision (in this case, revision 2).<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>11. kubectl port-forward<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Description:<\/strong> kubectl port-forward allows you to forward one or more local ports to a pod.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Example:<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"># Forward local port 8080 to port 80 of a pod<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>kubectl port-forward pod\/nginx-pod 8080:80<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"># Forward local port 9090 to port 9090 of a service<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>kubectl port-forward service\/nginx-service 9090:9090<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Explanation: <\/strong>The first command forwards local port 8080 to port 80 of the pod nginx-pod. The second command forwards local port 9090 to port 9090 of the service nginx-service.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>12. kubectl rollout status<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Description:<\/strong> kubectl rollout status checks the status of a rollout.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Example:<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"># Check the status of a deployment rollout<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>kubectl rollout status deployment\/nginx-deployment<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Explanation: <\/strong>This command checks the status of the rollout for the nginx-deployment and provides information about whether the rollout is complete or still in progress.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>13. kubectl label<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Description:<\/strong> kubectl label is used to add or update labels on resources.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Example:<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"># Add a label to a pod<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>kubectl label pod\/nginx-pod app=nginx<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"># Update a label on a service<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>kubectl label service\/nginx-service environment=production<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Explanation: <\/strong>The first command adds a label app=nginx to the pod nginx-pod. The second command updates the label environment to production on the service nginx-service.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>14. kubectl annotate<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Description:<\/strong> kubectl annotate is used to add or update annotations on resources.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Example:<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"># Add an annotation to a pod<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>kubectl annotate pod\/nginx-pod description=&#8221;Frontend web server&#8221;<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"># Update an annotation on a service<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>kubectl annotate service\/nginx-service owner=&#8221;John Doe&#8221;<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Explanation: <\/strong>The first command adds an annotation description with the value &#8220;Frontend web server&#8221; to the pod nginx-pod. The second command updates the annotation owner to &#8220;John Doe&#8221; on the service nginx-service.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>15. kubectl rollout pause\/resume<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Description:<\/strong> kubectl rollout pause and kubectl rollout resume are used to pause and resume a rollout, respectively.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Example:<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"># Pause a deployment rollout<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>kubectl rollout pause deployment\/nginx-deployment<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"># Resume a deployment rollout<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>kubectl rollout resume deployment\/nginx-deployment<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Explanation:<\/strong> The first command pauses the rollout of the nginx-deployment, while the second command resumes the paused rollout.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>16. kubectl top<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Description:<\/strong> kubectl top provides resource usage statistics for nodes and pods.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Example:<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"># Get CPU and memory usage of nodes<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>kubectl top nodes<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"># Get CPU and memory usage of pods<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>kubectl top pods<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Explanation:<\/strong> These commands provide resource usage statistics such as CPU and memory usage for nodes and pods in the cluster.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>17. kubectl exec -ti<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Description:<\/strong> kubectl exec -ti is an extension of the kubectl exec command that opens an interactive session with a pod.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Example:<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"># Open an interactive shell inside a pod<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>kubectl exec -ti nginx-pod &#8212; \/bin\/bash<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Explanation: <\/strong>This command opens an interactive terminal (-ti) inside the specified pod (nginx-pod), allowing you to run multiple commands interactively.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>18. kubectl logs -f<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Description: <\/strong>kubectl logs -f follows the log output of a container in real-time.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Example:<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"># Stream logs of a container in a pod<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>kubectl logs -f nginx-deployment-65b9c54f9f-7vmhs<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Explanation:<\/strong> This command streams the logs of the specified container (nginx-deployment-65b9c54f9f-7vmhs) in real-time, allowing you to monitor the container&#8217;s output as it changes.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>19. kubectl rollout restart<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Description:<\/strong> kubectl rollout restart restarts a rollout of a deployment.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Example:<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"># Restart a deployment rollout<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>kubectl rollout restart deployment\/nginx-deployment<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Explanation:<\/strong> This command restarts the rollout of the nginx-deployment, effectively triggering a new rollout with the existing configuration.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>20. kubectl run<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Description:<\/strong> kubectl run creates and manages deployments or jobs.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Example:<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"># Create a new deployment<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>kubectl run nginx &#8211;image=nginx:latest &#8211;port=80<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"># Create a job to run a one-time task<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>kubectl run &#8211;generator=run-pod\/v1 my-job &#8211;image=busybox &#8212; \/bin\/sh -c &#8220;echo Hello, Kubernetes!&#8221;<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Explanation: <\/strong>The first command creates a new deployment named nginx using the nginx:latest image. The second command creates a job named my-job to run a one-time task that echoes &#8220;Hello, Kubernetes!&#8221;.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>21. kubectl cp<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Description: <\/strong>kubectl cp copies files and directories to and from containers.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Example:<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"># Copy a file from a pod to the local filesystem<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>kubectl cp nginx-pod:\/var\/log\/nginx\/access.log .\/access.log<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"># Copy a file from the local filesystem to a pod<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>kubectl cp .\/config.ini nginx-pod:\/etc\/nginx\/config.ini<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Explanation: <\/strong>The first command copies the access.log file from the nginx-pod to the local filesystem. The second command copies the config.ini file from the local filesystem to the nginx-pod.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>22. kubectl patch<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Description: <\/strong>kubectl patch is used to modify specific fields of a resource using a JSON or YAML patch.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Example:<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"># Patch the image of a container in a deployment<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>kubectl patch deployment nginx-deployment -p &#8216;{&#8220;spec&#8221;:{&#8220;template&#8221;:{&#8220;spec&#8221;:{&#8220;containers&#8221;:[{&#8220;name&#8221;:&#8221;nginx&#8221;,&#8221;image&#8221;:&#8221;nginx:1.21.1&#8243;}]}}}}&#8217;<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Explanation: <\/strong>This command patches the image of the nginx container in the nginx-deployment to use the nginx:1.21.1 image.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>23. kubectl rollout history<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Description: <\/strong>kubectl rollout history displays the rollout history of a deployment.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Example:<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"># Display rollout history of a deployment<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>kubectl rollout history deployment\/nginx-deployment<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Explanation:<\/strong> This command shows a revision history of changes to the nginx-deployment, including the revision number, trigger, and status.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>24. kubectl edit -n<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Description: <\/strong>kubectl edit -n allows you to edit resources in a specific namespace.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Example:<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"># Edit a deployment in a specific namespace<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>kubectl edit deployment\/nginx-deployment -n development<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Explanation: <\/strong>This command opens the deployment nginx-deployment for editing in the development namespace.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>25. kubectl rollout pause\/resume -n<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Description<\/strong>: kubectl rollout pause\/resume -n pauses or resumes a rollout in a specific namespace.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Example:<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"># Pause a deployment rollout in a specific namespace<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>kubectl rollout pause deployment\/nginx-deployment -n staging<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"># Resume a deployment rollout in a specific namespace<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>kubectl rollout resume deployment\/nginx-deployment -n staging<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Explanation: <\/strong>These commands pause or resume the rollout of the nginx-deployment in the staging namespace.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>26. kubectl apply -f dir\/<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Description:<\/strong> kubectl apply -f dir\/ applies all resources in a directory.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Example:<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"># Apply all resources in a directory<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>kubectl apply -f .\/manifests\/<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Explanation:<\/strong> This command applies all Kubernetes resource manifests found in the manifests\/ directory.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>27. kubectl scale &#8211;replicas=<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Description: <\/strong>kubectl scale &#8211;replicas= scales the number of replicas of a deployment, replicaset, or statefulset to a specific value.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Example:<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"># Scale a deployment to 5 replicas<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>kubectl scale deployment nginx-deployment &#8211;replicas=5<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Explanation: <\/strong>This command scales the number of replicas of the nginx-deployment to 5.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>28. kubectl rollout undo &#8211;to-revision=<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Description:<\/strong> kubectl rollout undo &#8211;to-revision= rolls back a deployment to a specific revision.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Example:<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"># Roll back a deployment to a specific revision<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>kubectl rollout undo deployment\/nginx-deployment &#8211;to-revision=3<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Explanation: <\/strong>This command rolls back the nginx-deployment to revision 3.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>29. kubectl delete -f<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Description:<\/strong> kubectl delete -f deletes resources defined in a YAML or JSON file.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Example:<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"># Delete resources defined in a YAML file<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>kubectl delete -f deployment.yaml<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Explanation:<\/strong> This command deletes all resources defined in the deployment.yaml file.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>30. kubectl rollout history -n<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Description:<\/strong> kubectl rollout history -n displays the rollout history of a deployment in a specific namespace.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Example:<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"># Display rollout history of a deployment in a specific namespace<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>kubectl rollout history deployment\/nginx-deployment -n production<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Explanation:<\/strong> This command shows the rollout history of the nginx-deployment in the production namespace.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>31. kubectl proxy<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Description:<\/strong> kubectl proxy creates a proxy server between your machine and Kubernetes API server. It allows you to access the Kubernetes API from your local machine.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Example:<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"># Start a proxy server<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>kubectl proxy<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Explanation: <\/strong>This command starts a proxy server on your local machine, enabling you to interact with the Kubernetes API using tools like curl or through the Kubernetes dashboard.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>32. kubectl rollout status -w<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Description: <\/strong>kubectl rollout status -w continuously checks the status of a rollout until it&#8217;s complete.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Example:<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"># Continuously monitor the status of a deployment rollout<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>kubectl rollout status deployment\/nginx-deployment -w<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Explanation: This command continuously monitors the status of the nginx-deployment rollout until it&#8217;s complete, updating the status in real-time.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>33. kubectl explain<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Description:<\/strong> kubectl explain provides documentation for Kubernetes resources and their fields.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Example:<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"># Display documentation for a specific resource<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>kubectl explain pod.spec.containers<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Explanation:<\/strong> This command displays detailed documentation for the fields of a specific Kubernetes resource, in this case, the containers field within the spec section of a Pod.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>34. kubectl rollout pause\/resume -w<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Description:<\/strong> kubectl rollout pause\/resume -w pauses or resumes a rollout and waits until it&#8217;s complete.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Example:<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"># Pause a deployment rollout and wait until it&#8217;s paused<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>kubectl rollout pause deployment\/nginx-deployment -w<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"># Resume a deployment rollout and wait until it&#8217;s resumed<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>kubectl rollout resume deployment\/nginx-deployment -w<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Explanation: <\/strong>These commands pause or resume the rollout of the nginx-deployment and wait until the operation is complete before exiting.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>35. kubectl diff<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Description: <\/strong>kubectl diff shows a diff between the current live object configuration and the configuration that would be applied.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Example:<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"># Show the diff between current and proposed configuration<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>kubectl diff -f deployment.yaml<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Explanation: <\/strong>This command compares the current live configuration in the cluster with the proposed changes defined in the deployment.yaml file, showing the differences before applying the changes.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>36. kubectl auth can-i<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Description: <\/strong>kubectl auth can-i checks whether the current user has the specified permissions.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Example:<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"># Check if the current user can create deployments<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>kubectl auth can-i create deployments<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Explanation:<\/strong> This command checks whether the current user has permission to create deployments in the Kubernetes cluster.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p class=\"wp-block-paragraph\">These Kubernetes commands provide further functionality and flexibility in managing Kubernetes clusters and resources efficiently. Incorporate them into your workflow as needed to streamline your Kubernetes operations.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction: Welcome to our comprehensive guide on Kubernetes commands! Kubernetes has become the de facto standard for container orchestration, empowering developers and operations teams to efficiently manage containerized applications at scale. However, mastering Kubernetes commands can be a daunting task due to its vast ecosystem and extensive feature set. In this blog, we&#8217;ll break down [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":3819,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[216],"tags":[252,253,11,254],"class_list":["post-3818","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-kubernetes-basic","tag-kubernetes-commands","tag-kubernetes-debugging","tag-kubernetes-deployment","tag-kubernetes-lab-practice"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Mastering Kubernetes: A Comprehensive Guide to Every Command - code2deploy.com<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/blog.code2deploy.com\/mastering-kubernetes-a-comprehensive-guide-to-every-command\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Mastering Kubernetes: A Comprehensive Guide to Every Command - code2deploy.com\" \/>\n<meta property=\"og:description\" content=\"Introduction: Welcome to our comprehensive guide on Kubernetes commands! Kubernetes has become the de facto standard for container orchestration, empowering developers and operations teams to efficiently manage containerized applications at scale. However, mastering Kubernetes commands can be a daunting task due to its vast ecosystem and extensive feature set. In this blog, we&#8217;ll break down [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/blog.code2deploy.com\/mastering-kubernetes-a-comprehensive-guide-to-every-command\/\" \/>\n<meta property=\"og:site_name\" content=\"code2deploy.com\" \/>\n<meta property=\"article:published_time\" content=\"2024-03-11T18:16:27+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-03-11T18:16:28+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/blog.code2deploy.com\/wp-content\/uploads\/2024\/03\/kubernetes-commands.png\" \/>\n\t<meta property=\"og:image:width\" content=\"695\" \/>\n\t<meta property=\"og:image:height\" content=\"357\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"enam\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"enam\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"10 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/blog.code2deploy.com\\\/mastering-kubernetes-a-comprehensive-guide-to-every-command\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/blog.code2deploy.com\\\/mastering-kubernetes-a-comprehensive-guide-to-every-command\\\/\"},\"author\":{\"name\":\"enam\",\"@id\":\"https:\\\/\\\/code2deploy.com\\\/blog\\\/#\\\/schema\\\/person\\\/e46930c19b999a87f12566fa8357481b\"},\"headline\":\"Mastering Kubernetes: A Comprehensive Guide to Every Command\",\"datePublished\":\"2024-03-11T18:16:27+00:00\",\"dateModified\":\"2024-03-11T18:16:28+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/blog.code2deploy.com\\\/mastering-kubernetes-a-comprehensive-guide-to-every-command\\\/\"},\"wordCount\":2243,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/code2deploy.com\\\/blog\\\/#\\\/schema\\\/person\\\/e46930c19b999a87f12566fa8357481b\"},\"image\":{\"@id\":\"https:\\\/\\\/blog.code2deploy.com\\\/mastering-kubernetes-a-comprehensive-guide-to-every-command\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/code2deploy.com\\\/blog\\\/wp-content\\\/uploads\\\/2024\\\/03\\\/kubernetes-commands.png\",\"keywords\":[\"kubernetes commands\",\"kubernetes debugging\",\"Kubernetes deployment\",\"kubernetes lab practice\"],\"articleSection\":[\"Kubernetes Basic\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/blog.code2deploy.com\\\/mastering-kubernetes-a-comprehensive-guide-to-every-command\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/blog.code2deploy.com\\\/mastering-kubernetes-a-comprehensive-guide-to-every-command\\\/\",\"url\":\"https:\\\/\\\/blog.code2deploy.com\\\/mastering-kubernetes-a-comprehensive-guide-to-every-command\\\/\",\"name\":\"Mastering Kubernetes: A Comprehensive Guide to Every Command - code2deploy.com\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/code2deploy.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/blog.code2deploy.com\\\/mastering-kubernetes-a-comprehensive-guide-to-every-command\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/blog.code2deploy.com\\\/mastering-kubernetes-a-comprehensive-guide-to-every-command\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/code2deploy.com\\\/blog\\\/wp-content\\\/uploads\\\/2024\\\/03\\\/kubernetes-commands.png\",\"datePublished\":\"2024-03-11T18:16:27+00:00\",\"dateModified\":\"2024-03-11T18:16:28+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/blog.code2deploy.com\\\/mastering-kubernetes-a-comprehensive-guide-to-every-command\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/blog.code2deploy.com\\\/mastering-kubernetes-a-comprehensive-guide-to-every-command\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/blog.code2deploy.com\\\/mastering-kubernetes-a-comprehensive-guide-to-every-command\\\/#primaryimage\",\"url\":\"https:\\\/\\\/code2deploy.com\\\/blog\\\/wp-content\\\/uploads\\\/2024\\\/03\\\/kubernetes-commands.png\",\"contentUrl\":\"https:\\\/\\\/code2deploy.com\\\/blog\\\/wp-content\\\/uploads\\\/2024\\\/03\\\/kubernetes-commands.png\",\"width\":695,\"height\":357,\"caption\":\"kubernetes commands\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/blog.code2deploy.com\\\/mastering-kubernetes-a-comprehensive-guide-to-every-command\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/code2deploy.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Mastering Kubernetes: A Comprehensive Guide to Every Command\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/code2deploy.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/code2deploy.com\\\/blog\\\/\",\"name\":\"code2deploy.com\\\/blog\",\"description\":\"TechOps\",\"publisher\":{\"@id\":\"https:\\\/\\\/code2deploy.com\\\/blog\\\/#\\\/schema\\\/person\\\/e46930c19b999a87f12566fa8357481b\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/code2deploy.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/code2deploy.com\\\/blog\\\/#\\\/schema\\\/person\\\/e46930c19b999a87f12566fa8357481b\",\"name\":\"enam\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/d864e2f082f4499f8f1b33f004ec166eea77b9e94738553b120b6dca2410f203?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/d864e2f082f4499f8f1b33f004ec166eea77b9e94738553b120b6dca2410f203?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/d864e2f082f4499f8f1b33f004ec166eea77b9e94738553b120b6dca2410f203?s=96&d=mm&r=g\",\"caption\":\"enam\"},\"logo\":{\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/d864e2f082f4499f8f1b33f004ec166eea77b9e94738553b120b6dca2410f203?s=96&d=mm&r=g\"},\"sameAs\":[\"https:\\\/\\\/code2deploy.com\\\/blog\"],\"url\":\"https:\\\/\\\/code2deploy.com\\\/blog\\\/author\\\/enam\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Mastering Kubernetes: A Comprehensive Guide to Every Command - code2deploy.com","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/blog.code2deploy.com\/mastering-kubernetes-a-comprehensive-guide-to-every-command\/","og_locale":"en_US","og_type":"article","og_title":"Mastering Kubernetes: A Comprehensive Guide to Every Command - code2deploy.com","og_description":"Introduction: Welcome to our comprehensive guide on Kubernetes commands! Kubernetes has become the de facto standard for container orchestration, empowering developers and operations teams to efficiently manage containerized applications at scale. However, mastering Kubernetes commands can be a daunting task due to its vast ecosystem and extensive feature set. In this blog, we&#8217;ll break down [&hellip;]","og_url":"https:\/\/blog.code2deploy.com\/mastering-kubernetes-a-comprehensive-guide-to-every-command\/","og_site_name":"code2deploy.com","article_published_time":"2024-03-11T18:16:27+00:00","article_modified_time":"2024-03-11T18:16:28+00:00","og_image":[{"width":695,"height":357,"url":"https:\/\/blog.code2deploy.com\/wp-content\/uploads\/2024\/03\/kubernetes-commands.png","type":"image\/png"}],"author":"enam","twitter_card":"summary_large_image","twitter_misc":{"Written by":"enam","Est. reading time":"10 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/blog.code2deploy.com\/mastering-kubernetes-a-comprehensive-guide-to-every-command\/#article","isPartOf":{"@id":"https:\/\/blog.code2deploy.com\/mastering-kubernetes-a-comprehensive-guide-to-every-command\/"},"author":{"name":"enam","@id":"https:\/\/code2deploy.com\/blog\/#\/schema\/person\/e46930c19b999a87f12566fa8357481b"},"headline":"Mastering Kubernetes: A Comprehensive Guide to Every Command","datePublished":"2024-03-11T18:16:27+00:00","dateModified":"2024-03-11T18:16:28+00:00","mainEntityOfPage":{"@id":"https:\/\/blog.code2deploy.com\/mastering-kubernetes-a-comprehensive-guide-to-every-command\/"},"wordCount":2243,"commentCount":0,"publisher":{"@id":"https:\/\/code2deploy.com\/blog\/#\/schema\/person\/e46930c19b999a87f12566fa8357481b"},"image":{"@id":"https:\/\/blog.code2deploy.com\/mastering-kubernetes-a-comprehensive-guide-to-every-command\/#primaryimage"},"thumbnailUrl":"https:\/\/code2deploy.com\/blog\/wp-content\/uploads\/2024\/03\/kubernetes-commands.png","keywords":["kubernetes commands","kubernetes debugging","Kubernetes deployment","kubernetes lab practice"],"articleSection":["Kubernetes Basic"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/blog.code2deploy.com\/mastering-kubernetes-a-comprehensive-guide-to-every-command\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/blog.code2deploy.com\/mastering-kubernetes-a-comprehensive-guide-to-every-command\/","url":"https:\/\/blog.code2deploy.com\/mastering-kubernetes-a-comprehensive-guide-to-every-command\/","name":"Mastering Kubernetes: A Comprehensive Guide to Every Command - code2deploy.com","isPartOf":{"@id":"https:\/\/code2deploy.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/blog.code2deploy.com\/mastering-kubernetes-a-comprehensive-guide-to-every-command\/#primaryimage"},"image":{"@id":"https:\/\/blog.code2deploy.com\/mastering-kubernetes-a-comprehensive-guide-to-every-command\/#primaryimage"},"thumbnailUrl":"https:\/\/code2deploy.com\/blog\/wp-content\/uploads\/2024\/03\/kubernetes-commands.png","datePublished":"2024-03-11T18:16:27+00:00","dateModified":"2024-03-11T18:16:28+00:00","breadcrumb":{"@id":"https:\/\/blog.code2deploy.com\/mastering-kubernetes-a-comprehensive-guide-to-every-command\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/blog.code2deploy.com\/mastering-kubernetes-a-comprehensive-guide-to-every-command\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/blog.code2deploy.com\/mastering-kubernetes-a-comprehensive-guide-to-every-command\/#primaryimage","url":"https:\/\/code2deploy.com\/blog\/wp-content\/uploads\/2024\/03\/kubernetes-commands.png","contentUrl":"https:\/\/code2deploy.com\/blog\/wp-content\/uploads\/2024\/03\/kubernetes-commands.png","width":695,"height":357,"caption":"kubernetes commands"},{"@type":"BreadcrumbList","@id":"https:\/\/blog.code2deploy.com\/mastering-kubernetes-a-comprehensive-guide-to-every-command\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/code2deploy.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Mastering Kubernetes: A Comprehensive Guide to Every Command"}]},{"@type":"WebSite","@id":"https:\/\/code2deploy.com\/blog\/#website","url":"https:\/\/code2deploy.com\/blog\/","name":"code2deploy.com\/blog","description":"TechOps","publisher":{"@id":"https:\/\/code2deploy.com\/blog\/#\/schema\/person\/e46930c19b999a87f12566fa8357481b"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/code2deploy.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/code2deploy.com\/blog\/#\/schema\/person\/e46930c19b999a87f12566fa8357481b","name":"enam","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/d864e2f082f4499f8f1b33f004ec166eea77b9e94738553b120b6dca2410f203?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/d864e2f082f4499f8f1b33f004ec166eea77b9e94738553b120b6dca2410f203?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/d864e2f082f4499f8f1b33f004ec166eea77b9e94738553b120b6dca2410f203?s=96&d=mm&r=g","caption":"enam"},"logo":{"@id":"https:\/\/secure.gravatar.com\/avatar\/d864e2f082f4499f8f1b33f004ec166eea77b9e94738553b120b6dca2410f203?s=96&d=mm&r=g"},"sameAs":["https:\/\/code2deploy.com\/blog"],"url":"https:\/\/code2deploy.com\/blog\/author\/enam\/"}]}},"_links":{"self":[{"href":"https:\/\/code2deploy.com\/blog\/wp-json\/wp\/v2\/posts\/3818","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/code2deploy.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/code2deploy.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/code2deploy.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/code2deploy.com\/blog\/wp-json\/wp\/v2\/comments?post=3818"}],"version-history":[{"count":1,"href":"https:\/\/code2deploy.com\/blog\/wp-json\/wp\/v2\/posts\/3818\/revisions"}],"predecessor-version":[{"id":3820,"href":"https:\/\/code2deploy.com\/blog\/wp-json\/wp\/v2\/posts\/3818\/revisions\/3820"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/code2deploy.com\/blog\/wp-json\/wp\/v2\/media\/3819"}],"wp:attachment":[{"href":"https:\/\/code2deploy.com\/blog\/wp-json\/wp\/v2\/media?parent=3818"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/code2deploy.com\/blog\/wp-json\/wp\/v2\/categories?post=3818"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/code2deploy.com\/blog\/wp-json\/wp\/v2\/tags?post=3818"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}