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

K8s Commands

The document provides a comprehensive list of Kubernetes commands for managing nodes, pods, deployments, services, ConfigMaps, secrets, namespaces, contexts, resource quotas, rollouts, labels, persistent volumes, and deleting resources. Each section includes commands for listing, describing, and manipulating various Kubernetes resources. This serves as a quick reference guide for users to efficiently interact with a Kubernetes cluster.

Uploaded by

Nikita Prajapati
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

K8s Commands

The document provides a comprehensive list of Kubernetes commands for managing nodes, pods, deployments, services, ConfigMaps, secrets, namespaces, contexts, resource quotas, rollouts, labels, persistent volumes, and deleting resources. Each section includes commands for listing, describing, and manipulating various Kubernetes resources. This serves as a quick reference guide for users to efficiently interact with a Kubernetes cluster.

Uploaded by

Nikita Prajapati
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Kubernetes Commands

Nodes:
List all nodes in the cluster.
$kubectl get nodes
Show detailed information about a node.
$kubectl describe node <node-name>

Pods:
List all pods in the current namespace.
$kubectl get pods
Show detailed information about a pod.
$kubectl describe pod <pod-name>
Print the logs from a pod.
$kubectl logs <pod-name>
Access a shell inside a running pod.
$kubectl exec -it <pod-name> -- /bin/sh

Deployments:
List all deployments.
$kubectl get deployments
Show detailed information about a deployment.
$kubectl describe deployment <deployment-name>
Scale the number of replicas in a deployment.
$kubectl scale deployment <deployment-name> --replicas=<num>

Services:
List all services in the current namespace.
$kubectl get services
Show detailed information about a service.
$kubectl describe service <service-name>

1
ConfigMaps and Secrets:
List all ConfigMaps.
$kubectl get configmaps
List all secrets.
$kubectl get secrets

Namespaces:
List all namespaces.
$kubectl get namespaces
Create a new namespace.
$kubectl create namespace <namespace-name>

Contexts:
List all contexts.
$kubectl config get-contexts
Set the current context.
$kubectl config use-context <context-name>

Resource Quotas and Limits:


List all resource quotas.
$kubectl get resourcequotas
Show detailed information about a resource quota.
$kubectl describe resourcequota <resourcequota-name>

Rollouts and Rollbacks:


Check the status of a rollout.
$kubectl rollout status deployment/<deployment-name>
View rollout history.
$kubectl rollout history deployment/<deployment-name>
Rollback to a previous deployment revision.
$kubectl rollout undo deployment/<deployment-name>

Labels and Selectors:


List pods with a specific label.
$kubectl get pods -l <label-key>=<label-value>

2
Add a label to a pod.
$kubectl label pod <pod-name> <key>=<value>

Persistent Volumes and Persistent Volume Claims:


List all persistent volumes.
$kubectl get pv
List all persistent volume claims.
$kubectl get pvc

Deleting Resources:
Delete a pod.
$kubectl delete pod <pod-name>
Delete a deployment.
$kubectl delete deployment <deployment-name>
Delete a service.
$kubectl delete service <service-name>

You might also like