Top 10 Kubernetes CLI commands that are frequently used by DevOps engineers

Top 10 Kubernetes CLI commands that are frequently used by DevOps engineers

·

1 min read

Kubernetes Command-Line Interface (kubectl) is a powerful tool for managing and interacting with Kubernetes clusters. Here are the top 10 Kubernetes CLI commands that are frequently used by DevOps engineers and administrators:

  1. View Cluster Info: View basic information about your cluster, including the current context and cluster details.

     kubectl cluster-info
    
  2. List Pods: List all the pods running in a particular namespace.

     kubectl get pods -n <namespace>
    
  3. List Services: List all the services running in a particular namespace.

     kubectl get services -n <namespace>
    
  4. Deploy an Application: Deploy an application from a YAML file.

     kubectl apply -f <deployment.yaml>
    
  5. Scale a Deployment: Scale the number of replicas for a deployment.

     kubectl scale deployment/<deployment-name> --replicas=<replica-count>
    
  6. Port Forwarding: Forward a local port to a pod for debugging or testing.

     kubectl port-forward <pod-name> <local-port>:<pod-port>
    
  7. Logs: View the logs of a pod.

     kubectl logs <pod-name>
    
  8. Exec into a Container: Open a shell inside a running container for troubleshooting.

     kubectl exec -it <pod-name> -- /bin/sh
    
  9. Rollout Status: Check the status of a deployment rollout.

     kubectl rollout status deployment/<deployment-name>
    
  10. Delete Resources: Delete resources such as pods, services, or deployments.

    kubectl delete pod/<pod-name>