DEV Community

Cover image for Top 10 Kubernetes Commands
Hasan Elsherbiny
Hasan Elsherbiny

Posted on

12 7 7 7 7

Top 10 Kubernetes Commands

in our previous article we have discussed what is Kubernetes
in this article we will go through the most important commands you need to know when you are dealing with K8

Check version

Check the version of kubectl and the Kubernetes cluster.

kubectl version
Enter fullscreen mode Exit fullscreen mode

get pods

List all pods in the current namespace.

kubectl get pods
Enter fullscreen mode Exit fullscreen mode

get nodes

List all nodes in the cluster

kubectl get nodes
Enter fullscreen mode Exit fullscreen mode

get deployments

List all deployments in the current namespace.

kubectl get deployments
Enter fullscreen mode Exit fullscreen mode

describe pod

Get detailed information about a specific pod.

kubectl describe pod [pod_name]
Enter fullscreen mode Exit fullscreen mode

get logs

View the logs of a specific pod.

kubectl logs [pod_name]
Enter fullscreen mode Exit fullscreen mode

apply

Apply a configuration file to create or update a resource (e.g., pod, service, deployment).

kubectl apply -f [filename]
Enter fullscreen mode Exit fullscreen mode

Execute

Execute a command in a running pod.

kubectl exec -it [pod_name] -- [command]
Enter fullscreen mode Exit fullscreen mode

scale deployment

Scale the number of replicas for a deployment.

kubectl scale deployment [deployment_name] --replicas=[num_replicas]
Enter fullscreen mode Exit fullscreen mode

Delete resource

Delete a resource by specifying its type and name.

kubectl delete [resource_type] [resource_name]
Enter fullscreen mode Exit fullscreen mode

these are commands you need to get started but for sure you will need more commands

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

Top comments (2)

Collapse
 
aminiyehia1 profile image
Amini Yehia

thanks for this list

Collapse
 
hasanelsherbiny profile image
Hasan Elsherbiny

you welcome

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

Instrument, monitor, fix: a hands-on debugging session

Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.

Tune in to the full event

DEV is partnering to bring live events to the community. Join us or dismiss this billboard if you're not interested. ❤️