I like to read about and see how people set up their environments and any tools, tips, and tricks they use to be more productive when working with Kubernetes and Istio. What follows is a collection of 5 tips and tools that I use daily, and I think it makes me more productive with Kubernetes and Istio. 1. Switching between Kubernetes contexts If you're working with a local Kubernetes instance and one or more cloud instances of Kubernetes, you will at some point need to switch between contexts. Kubernetes CLI ( ) has commands available that allow you to work with different contexts: kubectl current-context get-contexts rename-context delete-context set-context use-context Assuming you know the name of the Kubernetes context you want to switch to, you can use the following command: kubectl use-context [CONTEXT-NAME] In case you are working with multiple clusters and you don't know the context names, you would need to list the contexts first, and then run the use-context command like this: $ kubectl get-contexts CURRENT NAME CLUSTER AUTHINFO NAMESPACE * docker-desktop docker-desktop docker-desktop minikube minikube minikube cloudc crdambvg43d user-crdambvg43d $ kubectl use-context minikube Luckily, there's an easier way to do this. I am using a tool called that allows you to list and switch to different Kubernetes context quickly. To list the context, you can run like this: kubectx kubectx $ kubectx docker-desktop minikub cloudc Switching to another context is as simple as this: $ kubectx [CONTEXT-NAME] 2. Switching between Kubernetes namespaces Another quite common thing you do when working with Kubernetes is to work with resources from multiple namespaces. For example, you might want to list pods in one namespace, check on services in another etc. My workflow here is to use the flag that is supported on the Kubernetes CLI. For example, to get all pods in the namespace called , you can run . By default, if you don't provide the namespace flag, the default Kubernetes namespace is used - which is appropriately named . --namespace test kubectl get pods -n test default This default value can be changed in the kubeconfig file - you could, for example, set the default namespace to be or or any other namespace. That way you don't need to use flag when querying for resources. However, the command to change this is awkward: test kube-system --namespace $ kubectl config contexts.my-context.namespace my-namespace set The command above modifies namespace field in the context and changes it to . This means if you switch to and run for example, you would only see pods from the namespace. my-context my-namespace my-context kubectl get pods my-namespace Together with the tool, you also get a tool called - it helps you list and switch to different namespaces. kubectx kubens $ kubens default docker kube-node-lease kube-public kube-system Setting a default namespace for selected context is also quick and easy: $ kubens default Context modified. Active namespace is . "docker-desktop" "default" 3. Alias the Kubernetes CLI This is a straightforward tip. If you are working with Kubernetes you will be typing a lot, and you will get tired of typing the whole name at some point. You might be thinking it's only seven characters, but it adds up. kubectl The tip here is to alias to something shorter, for example: kubectl k $ k=kubectl $ k get po NAME READY STATUS RESTARTS AGE mypod 1/1 Running 18 43h alias Ideally, you would put the alias in your , so it gets set each time you open your terminal. k=kubectl bash_profile 4. Get a terminal inside the Kubernetes cluster When accessing services and pods running inside the cluster, you either need to expose them, so they are accessible from the public internet or you run a kube proxy or forward ports between your local machine and services running inside the cluster. However, sometimes you want to run plain curl command without exposing any services or forwarding ports. To do so, I use a function that gets loaded as part of my bash profile that runs a pod with image inside the cluster and gives me access to the terminal. That way, I can run curl against services and IPs inside the cluster. I call the function and use it like this: radial/busyboxplus:curl kbash $ kbash If you don 't see a command prompt, try pressing enter. [ root@curl:/ ]$ From the prompt, I can run curl against internal Kubernetes DNS names or IP addresses. To exit, just type and if you want to attach back to the pod, run and it will attach to the existing pod. I have this function defined as part of my as well. exit kbash dotfiles 5. Quickly open Grafana/Jaeger/Kiali (or anything else) If you plan on working with Istio service mesh you will probably use Grafana/Jaeger/Kiali at some point. Accessing these services requires you to get the pod name first and then set up a port forward to that pod and finally open the browser to the forwarded address. The commands are quite long to type out each time: $ kubectl get pods --namespace istio-system -l -o jsonpath= grafana-6fb9f8c5c7-hrcqp $ kubectl --namespace istio-system port-forward grafana-6fb9f8c5c7-hrcqp 3000:3000 $ open http://localhost:3000 "app=grafana" "{.items[0].metadata.name}" The easier and faster way is to create functions or aliases for each of the services. For example, I have the following set up for Grafana/Jaeger/Kiali in one of the files that get loaded as part of my bash profile: GRAFANA_POD=$(kubectl get pods --namespace istio-system -l -o jsonpath= ) JAEGER_POD=$(kubectl get pod -n istio-system -l app=jaeger -o jsonpath= ) KIALI_POD=$(kubectl -n istio-system get pod -l app=kiali -o jsonpath= ) grafana= jaeger= kiali= #!/bin/bash export "app=grafana" "{.items[0].metadata.name}" export '{.items[0].metadata.name}' export '{.items[0].metadata.name}' alias "kubectl --namespace istio-system port-forward 3000:3000 & open http://localhost:3000" $GRAFANA_POD alias "kubectl --namespace istio-system port-forward 16686:16686 & open http://localhost:16686" $JAEGER_POD alias "kubectl --namespace istio-system port-forward 20001:20001 & open http://localhost:20001" $KIALI_POD Now if I want to open Jaeger, I can run and it will get the pod name, create the port-forward and open the browser. jaeger If you have other services running inside the cluster you are frequently opening, you can set up the aliases the same way.