kubernates

k8s tips and tricks

Kubernetes tips & tricks, how to change namespace for a cluster

Sam
Introduction In this article, we will explore various tips and tricks for managing Kubernetes (k8s) clusters using kubectl. These commands will help you efficiently handle namespaces, pods, deployments, and custom resource definitions (CRDs). Change the kubectl namespace while keeping the current context intact # change namespace of kubectl while keeping current context kubectl config set-context --current --namespace=default List pods from default namespace kubectl get pods List pods from all namespaces kubectl get pods -A # list pods from all namespaces List pods from a particular namespace kubectl get pods -n mynamespace How to check logs of a pod kubectl logs nginx-pod -n nginix-ns How to check logs of a pod as it gets generated or watch k8s pod logs ## use -f to follow the log as it generated kubectl logs <pod_name> -n <namespace> -f Deleting a Kubernetes deployment using kubectl If you don’t have proper permissions on the cluster, you will encounter an error like this.