DEV Community

Cover image for Mastering Kubernetes: Top 10 Commands You Should Know
Wallace Freitas
Wallace Freitas

Posted on • Updated on

Mastering Kubernetes: Top 10 Commands You Should Know

Kubernetes is essential for container orchestration. Here are the top 10 most used Kubernetes commands to help you manage your clusters efficiently:

kubectl get: Display a list of resources in your cluster.

🌱 kubectl get pods
Enter fullscreen mode Exit fullscreen mode

kubectl describe: Show detailed information about a specific resource, including events and status.

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

kubectl logs: Retrieve and display the logs from a container within a pod.

🌱 kubectl logs [pod_name]
Enter fullscreen mode Exit fullscreen mode

kubectl apply: Apply a configuration file to create or update resources.

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

kubectl delete: Remove resources from your cluster by name, type, or label selector.

🌱 kubectl delete pod [pod_name]
Enter fullscreen mode Exit fullscreen mode

kubectl exec: Execute a command directly inside a running container.

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

kubectl config: View and modify kubeconfig files, which define cluster access settings.

🌱 kubectl config view
Enter fullscreen mode Exit fullscreen mode

kubectl scale: Adjust the number of replicas for a deployment, replica set, or stateful set.

🌱 kubectl scale --replicas=[number] deployment/[deployment_name]
Enter fullscreen mode Exit fullscreen mode

kubectl port-forward: Forward one or more local ports to a port on a pod, allowing access to internal services.

🌱 kubectl port-forward [pod_name] [local_port]:[pod_port]
Enter fullscreen mode Exit fullscreen mode

kubectl rollout: Manage the rollout of a deployment, including checking status and undoing changes.

🌱 kubectl rollout status deployment/[deployment_name]
Enter fullscreen mode Exit fullscreen mode

What are your favorite Kubernetes commands? Share in the comments!

Top comments (0)