Table of Contents
Kubernetes Commands
Here are some commonly used basic kubectl
(Kubernetes Command-Line Tool) commands when working with Kubernetes:
- Check Kubernetes Cluster:
kubectl cluster-info
- List All Running Resources:
kubectl get all
- List a Specific Resource Type (e.g., Pods):
kubectl get pods
- List a Specific Resource in Detail:
kubectl describe pod <pod-name>
- Create a New Resource (e.g., Pod):
kubectl apply -f <configuration-file.yaml>
- Update a Specific Resource:
kubectl apply -f <updated-configuration-file.yaml>
- Delete a Specific Resource (e.g., Pod):
kubectl delete pod <pod-name>
- Show Logs of a Pod:
kubectl logs <pod-name>
- Access an Interactive Shell to a Pod (Exec):
kubectl exec -it <pod-name> -- /bin/sh
- Port Forwarding to a Specific Resource:
kubectl port-forward <pod-name> 8080:80
- Watch the Status of a Specific Resource:
kubectl get pod <pod-name> --watch
- Open an Editor to Update a Kubernetes Resource:
kubectl edit <resource-type> <resource-name>
- List Resources in a Specific Namespace:
kubectl get pods --namespace=<namespace-name>
- List Resources with a Specific Label:
kubectl get pods -l <label-name>=<label-value>
These commands are used for basic Kubernetes management. kubectl
has many other options and use cases, so it’s important to check the guides and documentation related to the kubectl
command for more information.