Useful Kubernets commands
Get all namespaces:
kubectl get ns
#=> returns all the namespacesGet all resources:
kubectl get all
#=> returns all the resources under default namespace
kubectl get pods -n yourawesomenamespace
#=> returns all the resources under yourawesomenamespaceGet pods:
kubectl get pods
#=> returns all the pods under default namespace
kubectl get pods -n yourawesomenamespace
#=> returns all the pods under yourawesomenamespaceK8s contexts:
kubectl config get-contexts
#=> returns all the available clusters
kubectl config use-context yourawesomecontext
#=> switches to yourawesomecontext
kubectl config set-context yourawesomecontext --namespace=yourawesomenamespace
# modifies context to use yourawesomenamespace as default namespaceK8s port forward:
kubectl port-forward podname-43cc3323f -n yourawesomenamespace 5000:5000
#=> here podname-43cc3323f is a sample pod name. Left side of the port number (5000)
#=> exposes local machine port number, right side port number belongs to podname-43cc3323fk8s describe pods:
kubectl describe pods podname-43cc3323f -n yourawesomenamespace
#=> here podname-43cc3323f is a sample pod name.k8s pod logs:
kubectl logs podname-43cc3323f -n yourawesomenamespace
#=> here podname-43cc3323f is a sample pod name.k8s get ingress:
kubectl get ing -n yourawesomenamespace
#=> here podname-43cc3323f is a sample pod name.