Kubectl commands to list services, deployments and pods from namespace
To list services, pods and deployments resources from kubernetes namespace use the kubectl get
command with --namespace=my-namespace
(short -n
)
# Set the "current" namespace for context
kubectl config set-context --current --namespace=my-namespace
# Get commands with basic output
kubectl get services # List all services in the namespace
kubectl get pods --all-namespaces # List all pods in all namespaces
kubectl get pods -o wide # List all pods in the current namespace, with more details
kubectl get deployment my-dep # List a particular deployment
kubectl get pods # List all pods in the namespace
kubectl get pods -n my-namespace # List all pods in the "my-namespace" namespace (in namespace not set)
kubectl get pod my-pod -o yaml # Get a pod's YAML
Reference - https://kubernetes.io/docs/reference/kubectl/cheatsheet/
Shared with from Codever.
👉 Use the Copy to mine
functionality to copy this snippet to your own personal collection and easy manage
your code snippets.
Codever is open source on Github ⭐🙏