{"id":16926,"date":"2023-10-05T00:35:24","date_gmt":"2023-10-05T00:35:24","guid":{"rendered":"https:\/\/www.appservgrid.com\/paw92\/?p=16926"},"modified":"2023-10-05T00:35:39","modified_gmt":"2023-10-05T00:35:39","slug":"kubernetes-cheatsheet-essential-commands-and-concepts-for-efficient-container-orchestration","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw92\/index.php\/2023\/10\/05\/kubernetes-cheatsheet-essential-commands-and-concepts-for-efficient-container-orchestration\/","title":{"rendered":"Kubernetes Cheatsheet: Essential Commands and Concepts for Efficient Container Orchestration"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\"><strong>Kubernetes Cheatsheet<\/strong><\/h2>\n\n\n\n<p><strong>Kubernetes Basics:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>kubectl version<\/strong>: Check the Kubernetes client and server versions.<\/li>\n\n\n\n<li><strong>kubectl cluster-info<\/strong>: View cluster details.<\/li>\n\n\n\n<li><strong>kubectl get pods<\/strong>: List all pods in the current namespace.<\/li>\n\n\n\n<li><strong>kubectl get nodes<\/strong>: List all nodes in the cluster.<\/li>\n\n\n\n<li><strong>kubectl describe pod [pod-name]<\/strong>: Get detailed information about a pod.<\/li>\n<\/ul>\n\n\n\n<p><strong>Creating and Managing Resources:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>kubectl create -f [yaml-file]<\/strong>: Create a resource from a YAML file.<\/li>\n\n\n\n<li><strong>kubectl apply -f [yaml-file]<\/strong>: Apply changes to a resource.<\/li>\n\n\n\n<li><strong>kubectl delete [resource-type] [resource-name]<\/strong>: Delete a resource.<\/li>\n\n\n\n<li><strong>kubectl edit [resource-type] [resource-name]<\/strong>: Edit a resource in the default text editor.<\/li>\n\n\n\n<li><strong>kubectl get [resource-type]<\/strong>: List resources of a specific type.<\/li>\n\n\n\n<li><strong>kubectl logs [pod-name]<\/strong>: View logs of a pod.<\/li>\n<\/ul>\n\n\n\n<p><strong>Scaling:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>kubectl scale deployment [deployment-name] &#8211;replicas=[num-replicas]<\/strong>: Scale a deployment.<\/li>\n\n\n\n<li><strong>kubectl autoscale deployment [deployment-name] &#8211;min=[min-replicas] &#8211;max=[max-replicas]<\/strong>: Autoscale a deployment.<\/li>\n<\/ul>\n\n\n\n<p><strong>Networking:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>kubectl expose [resource-type] [resource-name] &#8211;port=[port] &#8211;target-port=[target-port] &#8211;type=[service-type]:<\/strong>Expose a resource as a service.<\/li>\n\n\n\n<li><strong>kubectl get svc:<\/strong>&nbsp;List services.<\/li>\n\n\n\n<li><strong>kubectl port-forward [pod-name] [local-port]:[pod-port]:<\/strong>&nbsp;Forward ports from a local machine to a pod.<\/li>\n<\/ul>\n\n\n\n<p><strong>Configuration:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>kubectl config view:<\/strong>&nbsp;View the current configuration.<\/li>\n\n\n\n<li><strong>kubectl config use-context [context-name]:<\/strong>&nbsp;Set the current context.<\/li>\n<\/ul>\n\n\n\n<p><strong>Pods:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>kubectl exec -it [pod-name] &#8212; [command]:<\/strong>&nbsp;Execute a command in a pod.<\/li>\n\n\n\n<li><strong>kubectl run [pod-name] &#8211;image=[image-name]:<\/strong>&nbsp;Create a new pod running a specific image.<\/li>\n<\/ul>\n\n\n\n<p><strong>Namespaces:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>kubectl create namespace [namespace-name]:<\/strong>&nbsp;Create a new namespace.<\/li>\n\n\n\n<li><strong>kubectl get namespaces:<\/strong>&nbsp;List namespaces.<\/li>\n\n\n\n<li><strong>kubectl config set-context &#8211;current &#8211;namespace=[namespace-name]:<\/strong>&nbsp;Set the default namespace.<\/li>\n<\/ul>\n\n\n\n<p><strong>Secrets and ConfigMaps:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>kubectl create secret generic [secret-name] &#8211;from-literal=[key]=[value]:<\/strong>&nbsp;Create a secret.<\/li>\n\n\n\n<li><strong>kubectl create configmap [configmap-name] &#8211;from-literal=[key]=[value]:<\/strong>&nbsp;Create a ConfigMap.<\/li>\n\n\n\n<li><strong>kubectl describe secret [secret-name]:<\/strong>&nbsp;View secret details.<\/li>\n\n\n\n<li><strong>kubectl describe configmap [configmap-name]:<\/strong>&nbsp;View ConfigMap details.<\/li>\n<\/ul>\n\n\n\n<p><strong>Storage:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>kubectl get pv:<\/strong>&nbsp;List persistent volumes.<\/li>\n\n\n\n<li><strong>kubectl get pvc:<\/strong>&nbsp;List persistent volume claims.<\/li>\n<\/ul>\n\n\n\n<p><strong>Advanced Troubleshooting:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>kubectl describe [resource-type] [resource-name]:<\/strong>&nbsp;Get detailed information about a resource.<\/li>\n\n\n\n<li><strong>kubectl top [resource-type] [resource-name]:<\/strong>&nbsp;Display resource usage statistics.<\/li>\n<\/ul>\n\n\n\n<p><em>Remember<\/em>&nbsp;to replace placeholders like [resource-type], [resource-name], [pod-name], etc., with your actual resource and object names.<\/p>\n\n\n\n<p>This cheatsheet should help you get started with Kubernetes and serve as a handy reference as you work with containers and orchestration in Kubernetes.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Kubernetes Cheatsheet Kubernetes Basics: Creating and Managing Resources: Scaling: Networking: Configuration: Pods: Namespaces: Secrets and ConfigMaps: Storage: Advanced Troubleshooting: Remember&nbsp;to replace placeholders like [resource-type], [resource-name], [pod-name], etc., with your actual resource and object names. This cheatsheet should help you get started with Kubernetes and serve as a handy reference as you work with containers and &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.appservgrid.com\/paw92\/index.php\/2023\/10\/05\/kubernetes-cheatsheet-essential-commands-and-concepts-for-efficient-container-orchestration\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Kubernetes Cheatsheet: Essential Commands and Concepts for Efficient Container Orchestration&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-16926","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/16926","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/comments?post=16926"}],"version-history":[{"count":1,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/16926\/revisions"}],"predecessor-version":[{"id":16927,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/16926\/revisions\/16927"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/media?parent=16926"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/categories?post=16926"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/tags?post=16926"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}