Image
Image
Image
Up To 50% OFF
Image
On Courses This March!
Image

Kubernetes Cheat Sheet - Kubectl Commands And Objectives

Image

Kubernetes Cheat Sheet - Kubectl Commands And Objectives

What is the Kubernetes cheat sheet? Learn various kubectl cheat sheets and also know Kubernetes commands used in DevOps in brief.
Blog Author
Published on
Jan 18, 2023
Views
3679
Read Time
14 Mins
Table of Content

Tabel of the content

DevOps professionals or freshers in this competitive digital age need to stay updated with Kubernetes. Kubernetes is the trending technology. Many professionals are looking to switch to DevOps to work on Kubernetes.

Kubernetes, also known as Kubectl or K8, provides a tough and native cloud environment. Sometimes, it becomes difficult to remember all the technical terms involved in Kubernetes, so the Kubernetes cheat sheet is important for DevOps professionals. Kubectl Cheat Sheet helps freshers to get a grasp of Kubernetes and make their journey to DevOps easier. 

In this article, we will talk about the Kubernetes cheat sheet required for DevOps programming.

Kubernetes cheat sheet

What is Kubernetes?

Before diving into the Kubernetes cheat sheet, let's understand what Kubernetes means. Kubernetes is software for automatic deployment, scaling, and managing containerised applications. It is open-source software. 

DevOps Certification

Training Course

100% Placement Guarantee

View course
 

Kubectl Cheat Sheet

There are many technical terms in Kubernetes. Let's understand some important terms used regularly in Kubectl.

  • Node (master) - These are physical/virtual servers controlling Kubernetes clusters.
  • Node (worker) - These are physical/virtual servers responsible for workload runs for the given container technology.
  • Cluster - These are the physical/virtual servers where the Kubernetes are installed.
  • Labels - These are user-defined keys - the value pair associated with the pods.
  • Pods - These are a group of volumes and containers that share the same namespace.
  • Service - This is an abstraction where the servers behave as a proxy for the pod's group performing a 'service'. 
  • Master - This is a control plane that provides access points to the admins. This helps them to manage their workloads.

Learn How To Install Kubernetes On Windows

Kubernetes have different kinds of objects. This can be controlled by using their full names or short forms. Let's look at some of the objects.

  • Services
    • EndpointSlice/endpointslices
    • Ingress/ingresses/ing
    • Endpoints/endpoints/ep
    • Service/Services/svc
    • IngressClass/ingressclasses
  • Clusters
    • Binding/bindings
    • ClusterRole/clusterroles
    • APIService/apiservices
    • CertificateSigningRequest/certificate signing requests/CSR
    • FlowSchema/flowschemas
    • Lease/leases
    • ClusterRoleBinding/clusterrolebindings
    • NameSpace/namespaces/ns
    • ComponentStatus/component statuses/cs
    • LocalSubjectAccessReview/localsubjectaccessreviews
    • Node/nodes/no
    • NetworkPolicy/network policies/netpol
    • PriorityLevelConfiguration/prioritylevelconfigurations/
    • PersistentVolume/persistentvolumes
    • Role/roles
    • ResourceQuots/resourcequotas/quota
    • RoleBinding/rolebindings
    • RunTimeClass/runtime classes
    • SelfSubjectAccessReview/selfsubjectaccessreviews
    • SelfSubjectRulesReview/selfsubjectrulesreviews
    • StorageVersion
    • TokenRequest
    • ServiceAccount/service accounts/sa
    • SubjectAccessReview/subjectaccessreviews
    • TokenReview/tokenreviews
  • Config & Storage 
    • CSIDriver/csidrivers
    • Secrets/secrets
    • CSINode/csinodes
    • ConfigMap/configmaps/cm
    • Volume
    • StorageClass/storageclasses/sc
    • VolumeAttachment/volumeattachements
    • PersistentVolumeClaim/persistentvolumeclaims/pvc
    • CSIStoragecapacity
  • Workloads
    • Daemonset/daemonset/ds
    • Container
    • Cronjobcronjobs/cj
    • Pod/pods/PO
    • Deployment/deployment/deploy
    • ReplicationController/replication controllers/RC
    • Replicaset/replicasets/rs
    • Statefulset/stateful sets/sts
  • Metadata
    • Event/events/ev
    • ControllerRevision/controllerrevisions
    • LimitRange/limitranges/limits
    • CustomResourceDefinition/custom resource definitions/crd/crds
    • PodTemplate/pod templates
    • MutatingWebhookConfiguration/mutatingwebhookconfigurations
    • HorizontalPodAutoscaler/horizonatalpodautoscalers/hpa
    • ValidatingWebhookConfiguration/validatingwebhookconfigurations
    • PodDisruptionBudget/pod disruption budgets/PDB
    • PriorityClass/priority classes/pc
    • PodSecurityPolicy/pod security policies/PSP

There are different kinds of Kubernetes commands that professionals in DevOps can use. Let's look at them in brief.

  • Nodes
    • Kubectl get node - It lists all worker nodes.
    • Kubectl top node - It displays the metrics of the given nodes
    • Kubectl delete node - It deletes the specified node in a cluster
    • Kubectl get pods -o wide | grep <node_name> - It lists all the pods with the current namespace.
    • Kubectl describe nodes | grep ALLOCATED -A 5 - It describes all the nodes in verbose.
    • Kubectl label node - It adds a label to the node.
    • Kubectl get no -o wide - It details all the nodes with more information.
    • Kubectl annotate node <node_name> - It adds the annotation to the node.
    • Kubectl uncordon node <node_name> - It marks the specific node into schedule.
  • Namespaces
    • Kubectl get namespace - It provides all the present namespaces in a single cluster.
    • Kubectl create namespace <namespace_name> - It creates a namespace.
    • Kubectl delete namespace <namespace_name> - It deletes a namespace.
    • Kubectl describe namespace <namespace_name> - It provides all the details of a particular namespace mentioned.
    • Kubectl edit namespace <namespace_name> - It helps to edit and update the definition of the mentioned namespace.
  • Pods
    • Kubectl get po - It provides the available in the mentioned namespace.
    • Kubectl delete pod <pod_name> - It deletes the mentioned pod.
    • Kubectl describe pod <pod_name> - It provides all the details of the mentioned pod.
    • Kubectl get pod -n <pod_name> - It arranges all the pods in the provided namespace.
    • Kubectl create pod <pod_name> - It creates a pod with the given name.
    • Kubectl create pod <pod_name> -n<name_space> - It creates a new pod with the given namespace.
  • Services
    • Kubectl get services - It provides one or more services.
    • Kubectl describe services <services_name> - It provides a detailed list of all services.
    • Kubectl delete service <service_name> - It deletes the mentioned service.
    • Kubectl delete service -o wide - It deletes all the services.
  • Deployments 
    • Kubectl get deployment - it lists more than one deployment.
    • Kubectl create deployment <deployment_name> - It creates a new deployment.
    • Kubectl describe deployment <deployment_name> - It provides the details of one or more mentioned deployments.
    • Kubectl delete deployment <deployment_name> - It deletes the mentioned deployment.
  • Events
    • Kubectl get events - It provides all the recent events from the entire resource in the system.
    • Kubectl get events - - field-selector involvedObject.kind! = Pod - It provides all the lists except the events in the pod.
    • Kubectl get events - - field-selector type ! = Normal - It leaves out the normal events from the entire list of events.
  • Logs
    • Kubectl logs <pod_name> - It displays the logs of the mentioned pod.
    • Kubectl logs - -since =1h <pod_name> - It displays the logs of the mentioned pod for one hour.
    • Kubectl logs -c <container_name> <pod_name> - It shows the logs of the mentioned container in the given pod.
    • Kubectl logs - -tail-20 <pod_name> - It shows the last 20 lines of the mentioned log.
    • Kubectl logs <pod_name> pod.log - It saves the log into a file with the extension pod.log.
  • Service Accounts
    • Kubectl describe serviceaccounts - It provides the details of more than one service account.
    • Kubectl get serviceaccounts - It provides all the service accounts.
    • Kubectl delete serviceaccounts <name> - It deletes the mentioned service accounts.
    • Kubectl replace serviceaccounts - It replaces the mentioned service accounts. 

DevOps Certification

Training Course

In Collaboration with IBM

View course
 

Conclusion

For professionals or freshers looking to undergo DevOps course, understanding Kubernetes is important. Kubernetes is an extensible, open-source, and easy-to-use platform for DevOps professionals. There are several codes and commands in Kubernetes. It is not easy to remember all. So, having a Kubectl Cheat Sheet is important. This article discussed several of the important codes and commands for user reference. 

For professionals who are looking to undergo DevOps Online Training, they can enrol themselves in the professional DevOps training at StarAgile. The candidates would get trained by experienced faculties with proper industry exposure. Professionals looking at Kubernetes training can also join StarAgile for expert training. 

Share Article
WhatsappFacebookXLinkedInTelegram
About Author
Karan Gupta

Cloud Engineer

AWS DevOps Engineer with 6 years of experience in designing, implementing, automating and
maintaining the cloud infrastructure on the Amazon Web Services (AWS).
Are you Confused? Let us assist you.
+1
Explore DevOps Certification Training!
Upon course completion, you'll earn a certification and expertise.
ImageImageImageImage

Popular Courses

Gain Knowledge from top MNC experts and earn globally recognised certificates.
50645 Enrolled
2 Days
From USD 699.00
USD
299.00
Next Schedule March 19, 2025
2362 Enrolled
2 Days
From USD 699.00
USD
279.00
Next Schedule March 17, 2025
25970 Enrolled
2 Days
From USD 999.00
USD
545.00
Next Schedule March 15, 2025
20980 Enrolled
2 Days
From USD 999.00
USD
449.00
Next Schedule March 14, 2025
12659 Enrolled
2 Days
From USD 999.00
USD
545.00
Next Schedule March 15, 2025
PreviousNext

Trending Articles

The most effective project-based immersive learning experience to educate that combines hands-on projects with deep, engaging learning.
WhatsApp