Mastering Kubernetes: Top 10 Commands You Should Know

Wallace Freitas - Jul 9 - - Dev Community

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!

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Terabox Video Player