惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

云风的 BLOG
云风的 BLOG
IT之家
IT之家
D
Docker
博客园 - 叶小钗
A
About on SuperTechFans
博客园_首页
Apple Machine Learning Research
Apple Machine Learning Research
Recorded Future
Recorded Future
Stack Overflow Blog
Stack Overflow Blog
腾讯CDC
V
V2EX
S
SegmentFault 最新的问题
量子位
P
Proofpoint News Feed
酷 壳 – CoolShell
酷 壳 – CoolShell
Latest news
Latest news
大猫的无限游戏
大猫的无限游戏
月光博客
月光博客
有赞技术团队
有赞技术团队
The GitHub Blog
The GitHub Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
I
InfoQ
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
D
DataBreaches.Net
G
GRAHAM CLULEY
P
Proofpoint News Feed
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Microsoft Security Blog
Microsoft Security Blog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Y
Y Combinator Blog
小众软件
小众软件
NISL@THU
NISL@THU
L
Lohrmann on Cybersecurity
aimingoo的专栏
aimingoo的专栏
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
I
Intezer
Last Week in AI
Last Week in AI
T
Threatpost
人人都是产品经理
人人都是产品经理
U
Unit 42
Security Latest
Security Latest
AWS News Blog
AWS News Blog
T
The Blog of Author Tim Ferriss
MongoDB | Blog
MongoDB | Blog
罗磊的独立博客
GbyAI
GbyAI
P
Palo Alto Networks Blog
G
Google Developers Blog
MyScale Blog
MyScale Blog
L
LangChain Blog

Learn Cloud Native

Agentgateway rate limiting for agents | Learn Cloud Native Local development with coding agents on Kubernetes using Signadot | Learn Cloud Native cuenv: one typed file for your whole project | Learn Cloud Native Preflight: AI Code Review Before You Push Anatomy of AI Agents Accessing Google Drive from Next.js Deploying to Fly.io using Dagger and Github Top Cloud-Native & Kubernetes Certifications [2026 Guide] Rapid microservices development with Signadot How to prepare for Istio certified associate exam (ICA) Global Rate Limiting in Istio with Envoy Rate Limit Service My Journey with Istio: From Incubation to Graduation Cilium Network Policy Tutorial: Secure Kubernetes Step by Step Kubernetes Networking: How kube-proxy and iptables Work Istio ServiceEntry: DNS vs. STATIC Resolution & Endpoints Explained Apply an Istio DestinationRule Globally (Mesh-Wide) Istio Rate Limiting: Configure a Local Rate Limiter in Envoy How to expose custom ports on Istio ingress gateway Portainer Tutorial: A Web UI for Kubernetes & Containers Traefik Proxy 2.x and TLS 101 Kubernetes CLI (kubectl) tips you didn't know about Setting up SSL certificates with Istio Gateway ArgoCD Best Practices You Should Know 在 OCI Ampere A1 计算实例上运行 AI Running AI On OCI Ampere A1 Instance How to Deploy Traefik Proxy Using Flux and GitOps Principles Firebase Emulators with Next.js: Local Setup Guide Running Hugo on free Ampere VM (Oracle Cloud Infrastructure) How to use kwatch to detect crashes in Kubernetes clusters Continuous profiling in Kubernetes using Pyroscope Monitoring containers with cAdvisor Creating a Kubernetes cluster in Google Cloud (LAB) Your first Kubernetes Pod and ReplicaSet (LABS) Container Lifecycle Hooks Maybe Convert Wasm Extension Config? GetIstio - CLI, training, and community Attach multiple VirtualServices to Istio Gateway Kubernetes Volumes Explained: Keep Data Beyond the Pod Send a Slack message when Docker images are updated Kubernetes Network Policy Ambassador Container Pattern Start Kubernetes Release Sidecar Container Pattern Kubernetes Init Containers Deploying multiple Istio Ingress Gateways Branch by Abstraction Pattern The Strangler Pattern Kubernetes Development Environment with Skaffold Securing Kubernetes Ingress with Ambassador and Let's Encrypt All About the Ingress Resource How to quarantine Kubernetes pods? Getting started with Kubernetes Horizontal partitioning in MongoDB Docker image tagging scheme Six things to keep in mind when working with Dockerfiles Beginners guide to Docker Beginners guide to gateways and proxies Deploy and Operate Multiple Istio Meshes in one Kubernetes Cluster Managing service meshes with Meshery Circuit Breaking in Istio Explained Build and push your Docker images using Github Actions Kubernetes and Istio service mesh workshop materials Build Netlify-like deployment for React app using Kubernetes pods Six exciting enhancements in Istio 1.4.0 Fallacies of Distributed Systems CAP Theorem Explained Master the Kubernetes CLI (kubectl) - Cheatsheet Minikube Basics and How to Get Started with Kubernetes What are sticky sessions and how to configure them with Istio? Debugging Kubernetes applications using Istio Kubernetes Ingress and Istio Gateway Resource Zero Downtime Releases using Kubernetes and Istio Traffic Mirroring with Istio Service Mesh Expose a Kubernetes service on your own custom domain
5 Tips to Be More Productive with Kubernetes
Peter Jausovec · 2019-08-06 · via Learn Cloud Native

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 (kubectl) has commands available that allow you to work with different contexts:

  • 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 kubectx that allows you to list and switch to different Kubernetes context quickly. To list the context, you can run kubectx like this:

$ kubectx
docker-desktop
minikube
cloudc

Switching to another context is as simple as this:

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 --namespace flag that is supported on the Kubernetes CLI. For example, to get all pods in the namespace called test , you can run kubectl get pods -n test. By default, if you don't provide the namespace flag, the default Kubernetes namespace is used  -  which is appropriately named default.

This default value can be changed in the kubeconfig file  -  you could, for example, set the default namespace to be test or kube-system or any other namespace. That way you don't need to use --namespace flag when querying for resources. However, the command to change this is awkward:

$ kubectl config set contexts.my-context.namespace my-namespace

The command above modifies namespace field in the my-context context and changes it to my-namespace. This means if you switch to my-context and run kubectl get pods for example, you would only see pods from the my-namespace namespace.

Together with the kubectx tool, you also get a tool called kubens -  it helps you list and switch to different namespaces.

$ 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 "docker-desktop" modified.
Active namespace is "default".

3. Alias the Kubernetes CLI 

This is a straightforward tip. If you are working with Kubernetes you will be typing kubectl 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.

The tip here is to alias kubectl to something shorter, k for example:

$ alias k=kubectl
$ k get po
NAME    READY   STATUS    RESTARTS   AGE
mypod   1/1     Running   18         43h

Ideally, you would put the alias k=kubectl in your bash_profile, so it gets set each time you open your terminal.

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 radial/busyboxplus:curl 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 kbash and use it like this:

$ 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 exit and if you want to attach back to the pod, run kbash and it will attach to the existing pod. I have this function defined as part of my dotfiles as well.

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. With older versions of kubectl, accessing these services required 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. With the latest kubectl versions you can port forward to the service itself and you don't need to figure out what the pod name is anymore. Regardless, the commands are quite long to type out each time:

$ kubectl --namespace istio-system port-forward svc/grafana 3000:3000
$ open http://localhost:3000

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:

#!/bin/bash
alias grafana="kubectl --namespace istio-system port-forward svc/grafana 3000:3000 & open http://localhost:3000"
alias jaeger="kubectl --namespace istio-system port-forward svc/jaeger 16686:16686 & open http://localhost:16686"
alias kiali="kubectl --namespace istio-system port-forward svc/kiali 20001:20001 & open http://localhost:20001"

Now if I want to open Jaeger, I can run jaeger and it will set up the port-forward and open the browser.

If you have other services running inside the cluster you are frequently opening, you can set up the aliases the same way.