0% found this document useful (0 votes)
3 views

Kubernetes Useful commands

The document provides a comprehensive list of Kubernetes commands categorized by functionality, including managing pods, deployments, services, ConfigMaps, secrets, namespaces, nodes, persistent volumes, contexts, debugging resources, jobs, and cron jobs. Each command is accompanied by a brief description of its purpose. This serves as a quick reference guide for users working with Kubernetes.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Kubernetes Useful commands

The document provides a comprehensive list of Kubernetes commands categorized by functionality, including managing pods, deployments, services, ConfigMaps, secrets, namespaces, nodes, persistent volumes, contexts, debugging resources, jobs, and cron jobs. Each command is accompanied by a brief description of its purpose. This serves as a quick reference guide for users working with Kubernetes.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Kubernetes Commands

Working with Pods


kubectl get pods -> # Lists all pods in the current namespace

kubectl get pods -A -> # Lists all pods across all namespaces

kubectl describe pod -> # Displays detailed info about a specific pod

kubectl delete pod -> # Deletes a specific pod

kubectl logs -> # Displays logs for a specific pod

kubectl exec -it -- /bin/sh -> # Executes a shell inside a running pod

Working with Deployments


kubectl get deployments -> # Lists all deployments

kubectl create deployment --image= -> # Creates a deployment

kubectl scale deployment --replicas= -> # Scales a deployment

kubectl rollout status deployment -> # Checks rollout status

kubectl rollout undo deployment -> # Rolls back the last deployment

Working with Services


kubectl get services -> # Lists all services

kubectl describe svc -> # Displays detailed info about a service

kubectl expose deployment --port= --type= -> # Exposes a


deployment as a service

kubectl delete svc -> # Deletes a specific service


Working with ConfigMaps and Secrets
kubectl create configmap --from-literal=key=value -> # Creates a
ConfigMap

kubectl get configmaps -> # Lists all ConfigMaps

kubectl describe configmap -> # Describes a ConfigMap

kubectl create secret generic --from-literal=key=value -> # Creates a


secret

kubectl get secrets -> # Lists all secrets

kubectl describe secret -> # Describes a secret

Working with Namespaces


kubectl get namespaces -> # Lists all namespaces

kubectl create namespace -> # Creates a new namespace

kubectl delete namespace -> # Deletes a namespace

kubectl config set-context --current --namespace= -> # Sets default


namespace for current context

Managing Nodes
kubectl get nodes -> # Lists all nodes in the cluster

kubectl describe node -> # Displays detailed info about a node

kubectl drain -> # Safely evicts pods from a node (for maintenance)

kubectl cordon -> # Marks node as unschedulable

kubectl uncordon -> # Marks node as schedulable again


Working with Persistent Volumes (PV) and Claims (PVC)
kubectl get pv -> # Lists all persistent volumes

kubectl get pvc -> # Lists all persistent volume claims

kubectl describe pv -> # Displays info about a persistent volume

kubectl describe pvc -> # Displays info about a persistent volume


claim

kubectl d T elete pvc -> # Deletes a specific PVC

Configuring and Viewing Contexts


kubectl config get-contexts -> # Lists all available contexts

kubectl config use-context -> # Switches to a specific context

kubectl config current-context -> # Displays the current context

kubectl config delete-context -> # Deletes a specific context

Debugging Resources
kubectl describe -> # Describes any Kubernetes resource

kubectl logs -> # Displays logs of a pod

kubectl logs -f -> # Follows pod logs in real-time

kubectl get events -> # Lists cluster events

kubectl debug -> # Debugs a running pod

Managing Jobs and CronJobs


kubectl get jobs -> # Lists all jobs

kubectl delete job -> # Deletes a specific job

kubectl get cronjobs -> # Lists all cronjobs


kubectl delete cronjob -> # Deletes a specific cronjob

Applying and Deleting Manifests


kubectl apply -f -> # Applies configuration from a YAML file

kubectl delete -f -> # Deletes resources defined in a YAML file

kubectl diff -f -> # Shows differences before applying a YAML file

You might also like