{"id":1692,"date":"2019-05-13T05:09:13","date_gmt":"2019-05-13T05:09:13","guid":{"rendered":"http:\/\/kusuaks7\/?p=1297"},"modified":"2023-07-13T08:48:49","modified_gmt":"2023-07-13T08:48:49","slug":"key-kubernetes-commands","status":"publish","type":"post","link":"https:\/\/www.experfy.com\/blog\/bigdata-cloud\/key-kubernetes-commands\/","title":{"rendered":"Key Kubernetes Commands"},"content":{"rendered":"<h2 id=\"fb96\">Up and running with\u00a0K8s<\/h2>\n<p id=\"a889\">Kubernetes is the premier technology for deploying and managing large apps. In this article, we\u2019ll get up and running with K8s on your local machine. Then you\u2019ll Deploy your first app. Finally, you\u2019ll see the top K8s commands to know.<\/p>\n<p id=\"48cc\">If you\u2019re new to Kubernetes, check out my <a href=\"https:\/\/www.experfy.com\/blog\/key-kubernetes-concepts\">previous article<\/a>\u00a0to learn fundamental K8s concepts.<\/p>\n<p id=\"eaba\">Let\u2019s set sail!<\/p>\n<figure id=\"4c85\" data-scroll=\"native\"><canvas width=\"75\" height=\"50\"><\/canvas><img decoding=\"async\" style=\"width: 700px; height: 467px;\" src=\"https:\/\/cdn-images-1.medium.com\/max\/2560\/1*BQDzKm8qO9ZMzB6CTpbQDw.jpeg\" data-src=\"https:\/\/cdn-images-1.medium.com\/max\/2560\/1*BQDzKm8qO9ZMzB6CTpbQDw.jpeg\" \/><\/figure>\n<p style=\"text-align: center;\">Lots of containers on a\u00a0ship.<\/p>\n<h3 id=\"d167\"><strong>Running K8s\u00a0Locally<\/strong><\/h3>\n<p id=\"5b92\">Until recently, M<a href=\"https:\/\/kubernetes.io\/docs\/setup\/minikube\/\" target=\"_blank\" rel=\"noopener noreferrer\" data-href=\"https:\/\/kubernetes.io\/docs\/setup\/minikube\/\" data->inikube<\/a>\u00a0was the primary means of creating a local, single-node Kubernetes cluster. It works on Mac, Windows, and Linux. Minikube runs inside a virtual environment with drivers for many different virtual environments. It also has an extensive API. However, when using Minikube with VirtualBox, I found it to be slow and buggy.<\/p>\n<p id=\"d374\">If you are playing with K8s locally on a Mac or Windows machine, I recommend you use the K8s version that comes with Docker Desktop. It uses HyperKit as its virtual environment. I found it to be a breath of fresh air.<\/p>\n<p id=\"fb70\">If you\u2019re using a Linux machine with K8s locally, check out\u00a0<a href=\"https:\/\/microk8s.io\/\" target=\"_blank\" rel=\"noopener noreferrer\" data-href=\"https:\/\/microk8s.io\/\" data->MicroK8s<\/a>. It\u2019s lightweight and uses a\u00a0<em>snap<\/em>\u00a0instead of a virtual environment.<\/p>\n<p id=\"f9d1\">For this article, I\u2019m running K8s v1.13.0 from Docker Desktop CE,\u00a0<em>Edge<\/em>version in April 2019.<\/p>\n<figure id=\"89f5\"><canvas width=\"75\" height=\"52\"><\/canvas><img decoding=\"async\" src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*NRqhARFnml7ZJNFbYUZW2Q.png\" data-src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*NRqhARFnml7ZJNFbYUZW2Q.png\" \/><\/figure>\n<p id=\"1150\">To install and start K8s on a Mac, first, download Docker Desktop with K8s\u00a0<a href=\"https:\/\/www.docker.com\/products\/docker-desktop\" target=\"_blank\" rel=\"noopener noreferrer\" data-href=\"https:\/\/www.docker.com\/products\/docker-desktop\" data->here<\/a>.<\/p>\n<p id=\"e6e8\">Once installed, go to your apps and start Docker. Install and start K8s by selecting\u00a0<em>Preferences<\/em>\u00a0from the Docker<em>\u00a0<\/em>icon at the top of your screen.<\/p>\n<p style=\"text-align: center;\"><img decoding=\"async\" src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*yQ_JyEQVRIl0tZo86r1hXQ.png\" data-height=\"36\" data-image-id=\"1*yQ_JyEQVRIl0tZo86r1hXQ.png\" data-width=\"54\" \/><\/p>\n<p id=\"bc22\">Select the\u00a0<em>Kubernetes<\/em>\u00a0tab and check the\u00a0<em>Enable Kubernetes<\/em>\u00a0box.<\/p>\n<figure id=\"a7bd\"><canvas width=\"75\" height=\"57\"><\/canvas><img decoding=\"async\" src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*Ehp_EIELZlTyZClEFp_7Zg.png\" data-src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*Ehp_EIELZlTyZClEFp_7Zg.png\" \/><\/figure>\n<p id=\"840c\">Agree to install Kubernetes. It might take a minute or two to fire up. Click on the Docker dropdown and you should see\u00a0<em>Kubernetes is starting<\/em>\u00a0and then eventually,\u00a0<em>Kubernetes is running<\/em>.<\/p>\n<figure id=\"c2d4\"><img decoding=\"async\" src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*xHzaIHp-C6kpyB4AiYF1iA.png\" data-height=\"97\" data-image-id=\"1*xHzaIHp-C6kpyB4AiYF1iA.png\" data-width=\"282\" \/><\/figure>\n<p id=\"b686\">If you see two green circles, then you\u2019re set! If you don\u2019t see two green circles, Google and\u00a0<a href=\"https:\/\/stackoverflow.com\/\" target=\"_blank\" rel=\"noopener noreferrer\" data-href=\"https:\/\/stackoverflow.com\/\" data->Stack Overflow<\/a>\u00a0are a developer\u2019s best friends.<\/p>\n<h3 id=\"338b\">Your First K8s\u00a0App<\/h3>\n<p id=\"354c\">Let\u2019s make a\u00a0<em>hello world<\/em>\u00a0Deployment that will pull a Docker image for a node.js app. Our app will display\u00a0<em>Hello World<\/em>\u00a0in the browser. In production, you\u2019ll do things differently. This exercise is the first few steps to get your feet wet.<\/p>\n<p id=\"e617\">With K8s running, enter the following command in your terminal:<\/p>\n<p id=\"b4b3\"><code>kubectl create deployment hello-node --image=gcr.io\/hello-minikube-zero-install\/hello-node<\/code><\/p>\n<p id=\"6370\">We\u2019re using the\u00a0<code>kubectl<\/code>\u00a0API to create a deployment named\u00a0<em>hello-node\u00a0<\/em>that uses a Docker image stored in the\u00a0<a href=\"https:\/\/console.cloud.google.com\/gcr\/images\/hello-minikube-zero-install\/GLOBAL\/hello-node?gcrImageListsize=30\" target=\"_blank\" rel=\"noopener noreferrer\" data-href=\"https:\/\/console.cloud.google.com\/gcr\/images\/hello-minikube-zero-install\/GLOBAL\/hello-node?gcrImageListsize=30\" data->Google Container Registry<\/a>. We\u2019re using the Docker container from\u00a0<a href=\"https:\/\/kubernetes.io\/docs\/tutorials\/hello-minikube\/\" target=\"_blank\" rel=\"noopener noreferrer\" data-href=\"https:\/\/kubernetes.io\/docs\/tutorials\/hello-minikube\/\" data->the official Kubernetes\u00a0<em>Hello Minikube<\/em>\u00a0tutoria<\/a>l.<\/p>\n<p id=\"08aa\">Here are the contents of the Dockerfile:<\/p>\n<div id=\"a0ce\" style=\"background: #eee; border: 1px solid #ccc; padding: 5px 10px;\"><span style=\"font-family: courier new,courier,monospace;\">FROM node:6.14.2<br \/>\nEXPOSE 8080<br \/>\nCOPY server.js .<br \/>\nCMD node server.js<\/span><\/div>\n<p id=\"04f7\">We\u2019re using an official node.js image, copying the contents of\u00a0<em>server.js,\u00a0<\/em>exposing port 8080, and running the\u00a0<em>server.js<\/em>\u00a0program with node. For more on Docker files, check out my article\u00a0<a href=\"https:\/\/towardsdatascience.com\/learn-enough-docker-to-be-useful-b0b44222eef5\" target=\"_blank\" rel=\"noopener noreferrer\" data-href=\"https:\/\/towardsdatascience.com\/learn-enough-docker-to-be-useful-b0b44222eef5\" data->here<\/a>.<\/p>\n<p id=\"7209\">Here\u2019s the\u00a0<em>server.js<\/em>\u00a0app code:<\/p>\n<p><span style=\"font-family: courier new,courier,monospace;\"><code><strong>var http = require('http');<\/strong><\/code><\/span><\/p>\n<div style=\"background: #eee; border: 1px solid #ccc; padding: 5px 10px;\"><span style=\"font-family: courier new,courier,monospace;\">var handleRequest = function(request, response) {<br \/>\nconsole.log(&#8216;Received request for URL: &#8216; + request.url);<br \/>\nresponse.writeHead(200);<br \/>\nresponse.end(&#8216;Hello World!&#8217;);<\/span><br \/>\n};<br \/>\n<span style=\"font-family: courier new,courier,monospace;\">var www = http.createServer(handleRequest);<br \/>\nwww.listen(8080);<\/span><\/div>\n<p id=\"4de4\">This code will create a server that listens on port 8080. When the server receives a request, it writes a helpful message to the console and returns \u201cHello World!\u201d.<\/p>\n<p id=\"cfde\">After running the\u00a0<em>kubectl create<\/em>\u00a0command, you should see a message in your terminal that your Deployment has been created. Your app won\u2019t be ready to use right away, though. K8s needs to pull the Docker image and spin up your container.<\/p>\n<p id=\"48f7\">You can view the status of all K8s resources with\u00a0<code>kubectl get all<\/code>. It will take a few minutes to pull the image and spin up the container, so you\u2019ll probably enter this command a few times. You can peak behind the curtain and see what K8s is doing with\u00a0<code>kubectl get events<\/code>.<\/p>\n<p id=\"3358\">When you see\u00a0<em>1<\/em>\u00a0Pod is showing\u00a0<em>Available<\/em>, you\u2019re good to go.<\/p>\n<figure id=\"19ee\"><img decoding=\"async\" style=\"width: 700px; height: 47px;\" src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*o3oNtgnAbCU47L3nIAln0g.png\" data-action=\"zoom\" data-action-value=\"1*o3oNtgnAbCU47L3nIAln0g.png\" data-height=\"60\" data-image-id=\"1*o3oNtgnAbCU47L3nIAln0g.png\" data-width=\"878\" \/><\/figure>\n<p id=\"bc68\">To make the Pod accessible to the world outside the K8s cluster, you need to expose the Pod as a Service. Create a Service with the command\u00a0<code>kubectl expose deployment hello-node --type=LoadBalancer --port=8080<\/code>.<\/p>\n<p id=\"8542\">You specified the name of the Cluster, the type of Service, and the port for it to use. Not all Service types create an IP that can be accessed from the outside world, but\u00a0<em>LoadBalancer\u00a0<\/em>does.<\/p>\n<p id=\"d3c3\">You should be able to see that the Service has been created by entering\u00a0<code>kubectl get services<\/code>\u00a0in your shell.<\/p>\n<p id=\"39fd\">Assuming you\u2019re running K8s locally, navigate your browser to\u00a0<a href=\"http:\/\/www.experfy.com:8080\/\" target=\"_blank\" rel=\"noopener noreferrer\" data-href=\"http:\/\/www.experfy.com:8080\/\" data->http:\/\/www.experfy.com:8080\/<\/a>\u00a0and you should see the message \u201cHello World!\u201d.<\/p>\n<figure id=\"e9d2\"><canvas width=\"75\" height=\"75\"><\/canvas><img decoding=\"async\" style=\"width: 700px; height: 718px;\" src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*vfZYZ9HlKInCRJWpHGwkZQ.jpeg\" data-src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*vfZYZ9HlKInCRJWpHGwkZQ.jpeg\" \/><\/figure>\n<p style=\"text-align: center;\">Hello World!<\/p>\n<p id=\"f3e2\">Instead of creating and specifying your whole Deployment and Service via the command line, you could have specified them in a YAML file. Using a file has several advantages, including reusability and documentation. We\u2019ll cover YAML specification files in depth in future articles, so follow\u00a0<a href=\"https:\/\/medium.com\/@jeffhale\" target=\"_blank\" rel=\"noopener noreferrer\" data-href=\"https:\/\/medium.com\/@jeffhale\" data->me<\/a>\u00a0to make sure you don\u2019t miss them.<\/p>\n<p id=\"d510\">Now let\u2019s check out popular K8s commands.<\/p>\n<h3 id=\"5939\">kubectl<\/h3>\n<figure id=\"4b31\"><canvas width=\"75\" height=\"47\"><\/canvas><img decoding=\"async\" style=\"width: 640px; height: 426px;\" src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*APP1DfEr9oyYIEbKRf9l_A.jpeg\" data-src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*APP1DfEr9oyYIEbKRf9l_A.jpeg\" \/><\/figure>\n<p style=\"text-align: center;\">Cubes<\/p>\n<p id=\"dcfb\"><a href=\"https:\/\/kubernetes.io\/docs\/reference\/kubectl\/overview\/\" target=\"_blank\" rel=\"noopener noreferrer\" data-href=\"https:\/\/kubernetes.io\/docs\/reference\/kubectl\/overview\/\" data-><em>kubectl<\/em><\/a><em>\u200a<\/em>\u2014\u200apronounced \u201ccube control\u201d<strong><em>\u200a\u2014\u200a<\/em><\/strong>is the<em>\u00a0<\/em>command line tool for K8s. Here\u2019s how it works:<\/p>\n<ul>\n<li id=\"322f\">A\u00a0<em>kubectl<\/em>\u00a0command performs an action such as\u00a0<em>get<\/em>,\u00a0<em>create<\/em>, or\u00a0<em>describe.<\/em><\/li>\n<li id=\"8f40\">The action is performed on a<em>\u00a0<\/em>resource such as a Deployment, StatefulSet, or Service.<\/li>\n<li id=\"8dc5\"><em>kubectl<\/em>\u00a0commands follow this format:<\/li>\n<\/ul>\n<p id=\"a245\"><code>kubectl an_action a_resource a_resource_name --flags<\/code><\/p>\n<p id=\"d8cd\">Names and flags are optional in many cases.<\/p>\n<figure id=\"4212\"><canvas width=\"75\" height=\"55\"><\/canvas><img decoding=\"async\" src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*k5kgX0aqTtXReURcx6sN5g.jpeg\" data-src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*k5kgX0aqTtXReURcx6sN5g.jpeg\" \/><\/figure>\n<p style=\"text-align: center;\">Flags<\/p>\n<p id=\"36fe\">For example, to get information about all existing Pods you could run this common command:\u00a0<code>kubectl get pods<\/code>.<\/p>\n<p id=\"ba0f\">Tip: If you want to avoid typing\u00a0<em>kubectl<\/em>\u00a0a bajilllion times, make a Bash alias. With\u00a0<code>alias k='kubectl'<\/code>\u00a0you can just type\u00a0<code>k<\/code>\u00a0instead of\u00a0<code>kubectl<\/code>. I show how to make Bash aliases on a Mac in\u00a0<a href=\"https:\/\/towardsdatascience.com\/10-git-commands-you-should-know-df54bea1595c\" target=\"_blank\" rel=\"noopener noreferrer\" data-href=\"https:\/\/towardsdatascience.com\/10-git-commands-you-should-know-df54bea1595c\" data->this article<\/a>.<\/p>\n<p id=\"7f7b\">Without further ado, here are the most common K8s resources and their shortcuts.<\/p>\n<h3 id=\"8117\">Top 11 kubectl Resources<\/h3>\n<p id=\"27f8\"><code>pods, po<br \/>\nnodes, no<br \/>\ndeployments, deploy<br \/>\nreplicasets, rs<br \/>\ndaemonsets, ds<br \/>\nstatefulsets, sts<br \/>\njobs<br \/>\ncronjobs, cj<br \/>\nservices, svc<br \/>\npersistentvolumes, pv<br \/>\npersistentvolumeclaims, pvc<\/code><\/p>\n<p id=\"e772\">If you are fuzzy about these resources, check out\u00a0 my <a href=\"https:\/\/www.experfy.com\/blog\/key-kubernetes-concepts\">previous article<\/a>\u00a0on K8s concepts. Two other names to know are\u00a0<em>all\u00a0<\/em>and\u00a0<em>events<\/em>.<\/p>\n<p id=\"c7d0\">Unsurprisingly,\u00a0<code>all<\/code>\u00a0is used to refer to all existing resources.\u00a0<code>kubectl get all<\/code>shows essential information about running Pods, Services, Deployments, and ReplicaSets. This command is super handy.<\/p>\n<p id=\"f91b\">Likewise,\u00a0<code>kubectl get events<\/code>\u00a0shows a history of events. It\u2019s like a log at the K8s level instead of at the container level.<\/p>\n<p id=\"4aea\">If you want to see more\u00a0<em>kubectl<\/em>\u00a0resources, check out the official docs\u00a0<a href=\"https:\/\/kubernetes.io\/docs\/reference\/kubectl\/overview\/\" target=\"_blank\" rel=\"noopener noreferrer\" data-href=\"https:\/\/kubernetes.io\/docs\/reference\/kubectl\/overview\/\" data->here<\/a>. Now let\u2019s look at actions to apply to our resources.<\/p>\n<h3 id=\"1c79\">Top 7 kubectl\u00a0Actions<\/h3>\n<p id=\"bcd8\"><code>help<\/code>\u200a\u2014\u200aget help<br \/>\n<code>get<\/code>\u200a\u2014\u200adisplay information about a resource or resources<br \/>\n<code>describe<\/code>\u200a\u2014\u200adisplay detailed information about a resource or resources<br \/>\n<code>logs<\/code>\u200a\u2014\u200ashow the logs for a container<br \/>\n<code>exec<\/code>\u2014 enter a running process in a container<br \/>\n<code>apply\u00a0<\/code>\u2014create or alter a resource<br \/>\n<code>delete<\/code>\u200a\u2014\u200adelete a resource or resources<\/p>\n<p id=\"9146\">Let\u2019s look at each command briefly.<\/p>\n<h4 id=\"09c5\"><strong>help<\/strong><\/h4>\n<p id=\"9ca9\">Type\u00a0<code>--help<\/code>\u00a0after a command for help with that command. For example,\u00a0<code>kubectl get pods --help<\/code>.<\/p>\n<h4 id=\"c95a\"><strong>get<\/strong><\/h4>\n<p id=\"49e0\"><code>kubectl get all<\/code>\u00a0shows essential information about running Pods, Services, Deployments, and ReplicaSets. It\u2019s the go-to command to check the status of things. You can use\u00a0<code>get<\/code>\u00a0with individual objects and add the\u00a0<code>--watch<\/code>\u00a0flag to observe real-time updates.<\/p>\n<h4 id=\"a6b2\"><strong>describe<\/strong><\/h4>\n<p id=\"b379\"><code>kubectl describe all<\/code>\u00a0shows lots of detailed information about pretty much everything related to your Cluster. You can use\u00a0<code>describe<\/code>\u00a0with individual objects, too. It\u2019s helpful when debugging.<\/p>\n<h4 id=\"ba66\"><strong>logs<\/strong><\/h4>\n<p id=\"55c8\"><code>logs<\/code>\u00a0requires a Pod name. My &#8220;hello world\u201d app shows the logs for my Pod with the command\u00a0<code>kubectl logs hello-node-7f5b6bd6b8-gr7m7<\/code>. Use the flag\u00a0<code>-c my-container<\/code>\u00a0to specify a container when multiple are in a Pod. Use the\u00a0<code>--previous<\/code>\u00a0flag to get info about a container that is no longer running.<\/p>\n<figure id=\"f9b3\"><canvas width=\"75\" height=\"55\"><\/canvas><img decoding=\"async\" src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*buyYVUJAnKo-eLadb7x14Q.jpeg\" data-src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*buyYVUJAnKo-eLadb7x14Q.jpeg\" \/><\/figure>\n<p style=\"text-align: center;\">Wish my logs looked like\u00a0this.<\/p>\n<h4 id=\"2272\"><strong>exec<\/strong><\/h4>\n<p id=\"545e\"><code>exec<\/code>\u00a0helps you debug a container process. It allows you to execute a process within the container through a psuedo-terminal with\u00a0<code>-it<\/code>. For example, to enter the container in\u00a0<em>my_pod<\/em>\u00a0and run Bash, enter\u00a0<code>kubectl exec -it my_pod bash<\/code>.<\/p>\n<h4 id=\"71c4\"><strong>apply<\/strong><\/h4>\n<p id=\"1288\">Using\u00a0<code>apply<\/code>\u00a0with a YAML or JSON file is the recommended way to create or alter a resource. If a resource doesn\u2019t exist,\u00a0<code>apply<\/code>\u00a0will create it. If it does exist,\u00a0<code>apply<\/code>\u00a0will alter it.\u00a0<code>apply<\/code>\u00a0can add Services to an applicable resource, or automate horizontal scaling of a Deployment by adding Pods.<\/p>\n<p id=\"9143\">Note that you coud use\u00a0<code>create<\/code>\u00a0to make a Deployment and\u00a0<code>expose<\/code>\u00a0to make a Service\u2014 that\u2019s what we did above. However, using a YAML file with\u00a0<code>apply<\/code>\u00a0is a better option for documentation and reuse. We\u2019ll cover that method a future article. See a discussion of best practices for creating resources\u00a0<a href=\"https:\/\/medium.com\/google-cloud\/kubernetes-best-practices-8d5cd03446e2\" target=\"_blank\" rel=\"noopener noreferrer\" data-href=\"https:\/\/medium.com\/google-cloud\/kubernetes-best-practices-8d5cd03446e2\" data->here<\/a>.<\/p>\n<p id=\"cf8f\"><code>apply<\/code>\u00a0is your SwissArmy knife for creating and updating resources.<\/p>\n<figure id=\"00bd\"><canvas width=\"75\" height=\"47\"><\/canvas><img decoding=\"async\" src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*uS13pOF-KghRaGV86ZHQcA.jpeg\" data-src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*uS13pOF-KghRaGV86ZHQcA.jpeg\" \/><\/figure>\n<p style=\"text-align: center;\">SwissArmy knife<\/p>\n<h4 id=\"1886\"><strong>delete<\/strong><\/h4>\n<p id=\"5c3a\"><code>kubectl delete pod my_pod<\/code>\u00a0deletes the Pod named\u00a0<em>my_pod.<\/em><\/p>\n<p id=\"162d\">To delete all resources of the same type pass the\u00a0<code>--all<\/code>\u00a0flag. For example, you can delete all ReplicaSets with\u00a0<code>kubectl delete rs --all<\/code>. Note that if you try this, the ReplicaSets will restart if you don\u2019t delete your Deployment first.<\/p>\n<p id=\"897f\">Now you\u2019ve seen the key K8s commands. As you become a Kubernetes n\u0335i\u0335n\u0335j\u0335a\u0335 peaceful warrior, you\u2019ll acquire others. A full list of\u00a0<em>kubectl<\/em>\u00a0actions can be found\u00a0<a href=\"https:\/\/kubernetes.io\/docs\/reference\/generated\/kubectl\/kubectl-commands\" target=\"_blank\" rel=\"noopener noreferrer\" data-href=\"https:\/\/kubernetes.io\/docs\/reference\/generated\/kubectl\/kubectl-commands\" data->here<\/a>. Here\u2019s a quick recap of the key commands.<\/p>\n<h3 id=\"7eda\">Recap<\/h3>\n<h4 id=\"9d44\"><strong>Top 11 resources with shortcuts:<\/strong><\/h4>\n<p id=\"82da\"><code>pods, po<br \/>\nnodes, no<br \/>\ndeployments, deploy<br \/>\nreplicasets, rs<br \/>\ndaemonsets, ds<br \/>\nstatefulsets, sts<br \/>\njobs<br \/>\ncronjobs, cj<br \/>\nservices, svc<br \/>\npersistentvolumes, pv<br \/>\npersistentvolumeclaims, pvc<\/code><\/p>\n<h4 id=\"9b23\"><strong>Top 7\u00a0actions:<\/strong><\/h4>\n<p id=\"2a00\"><code>--help<\/code>\u200a\u2014\u200aget help about a resource<br \/>\n<code>get<\/code>\u200a\u2014\u200adisplay information about a resource or resources.<br \/>\n<code>describe<\/code>\u200a\u2014\u200adisplay detailed information about a resource or resources.<br \/>\n<code>logs<\/code>\u200a\u2014\u200ashow the logs for a container.<br \/>\n<code>exec<\/code>\u2014 enter a running process in a container.<br \/>\n<code>apply\u00a0<\/code>\u2014create or alter a resource.<br \/>\n<code>delete<\/code>\u200a\u2014\u200adelete a resource or resources.<\/p>\n<p id=\"1048\">To go deeper, if you\u2019re into lists, check out this\u00a0<a href=\"https:\/\/cheatsheet.dennyzhang.com\/cheatsheet-kubernetes-A4\" target=\"_blank\" rel=\"noopener noreferrer\" data-href=\"https:\/\/cheatsheet.dennyzhang.com\/cheatsheet-kubernetes-A4\" data->longer cheatsheet<\/a>.<\/p>\n<p id=\"da07\">As you explore K8s, be sure to spend some time with the official\u00a0<a href=\"https:\/\/kubernetes.io\/docs\" target=\"_blank\" rel=\"noopener noreferrer\" data-href=\"https:\/\/kubernetes.io\/docs\" data->Kubernetes docs<\/a>. They are detailed and can be overwhelming when starting out, but they are uncommonly well written.<\/p>\n<h3 id=\"384e\">Wrap<\/h3>\n<p id=\"082b\">I hope you found this article useful. You saw how to set up K8s and run your first K8s app. Also, you saw how to inspect, create, and delete your K8 resources with common commands.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Kubernetes is the premier technology for deploying and managing large apps. In this article, we&rsquo;ll get up and running with K8s on your local machine. &nbsp;You will know how to set up K8s and run your first K8s app. Also, you will know how to inspect, create, and delete your K8 resources with common commands. Then you&rsquo;ll deploy your first app. Finally, you&rsquo;ll see the top K8s commands to know.<\/p>\n","protected":false},"author":369,"featured_media":2708,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"content-type":"","footnotes":""},"categories":[187],"tags":[94],"ppma_author":[2134],"class_list":["post-1692","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-bigdata-cloud","tag-data-science"],"authors":[{"term_id":2134,"user_id":369,"is_guest":0,"slug":"jeff-hale","display_name":"Jeff Hale","avatar_url":"https:\/\/secure.gravatar.com\/avatar\/?s=96&d=mm&r=g","user_url":"","last_name":"Hale","first_name":"Jeff","job_title":"","description":"Jeff Hale is a co-founder of Rebel Desk, where he oversees technology, finance, and operations for this company. He&nbsp;is an experienced entrepreneur who has managed technology, operations, and finances for several companies.&nbsp;"}],"_links":{"self":[{"href":"https:\/\/www.experfy.com\/blog\/wp-json\/wp\/v2\/posts\/1692","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.experfy.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.experfy.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.experfy.com\/blog\/wp-json\/wp\/v2\/users\/369"}],"replies":[{"embeddable":true,"href":"https:\/\/www.experfy.com\/blog\/wp-json\/wp\/v2\/comments?post=1692"}],"version-history":[{"count":3,"href":"https:\/\/www.experfy.com\/blog\/wp-json\/wp\/v2\/posts\/1692\/revisions"}],"predecessor-version":[{"id":29178,"href":"https:\/\/www.experfy.com\/blog\/wp-json\/wp\/v2\/posts\/1692\/revisions\/29178"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.experfy.com\/blog\/wp-json\/wp\/v2\/media\/2708"}],"wp:attachment":[{"href":"https:\/\/www.experfy.com\/blog\/wp-json\/wp\/v2\/media?parent=1692"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.experfy.com\/blog\/wp-json\/wp\/v2\/categories?post=1692"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.experfy.com\/blog\/wp-json\/wp\/v2\/tags?post=1692"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.experfy.com\/blog\/wp-json\/wp\/v2\/ppma_author?post=1692"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}