Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to set up a serious Kubernetes terminal

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains "how to set up a serious Kubernetes terminal". The content of the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to set a proper Kubernetes terminal".

Kubernetes prepares excellent CLI. For basic operations, it works very well. Las, complexity increases when you need to perform an operation quickly.

The Kubernetes community has built various Web-based tools to monitor your cluster-kube ops views, grafana, and so on. However, having a complete end device will quickly speed up the resolution of the root cause of the problem. It constitutes the basic component of the Swiss Army knife.

The following is a short list of the open source tools I have applied to the OSX terminal. When used together, they allow me to skip the kubernetes cluster, quickly resolve problems, and monitor behavior. I deleted a lot of small utilities and insisted on using tools that I could use every day.

Before using any tool...

Before using these tools, I strongly recommend that you install zsh. It is an excellent open source wrapper around standard OSX terminals. It has rich features and intuitive features, and the plug-ins you can install are great. Some of the tools listed assume that you have installed ZSH.

K9s

I began to be strong. K9s is the backing of the CLI tool for Kubernetes clustering. You can SSH directly to pod, view logs, delete resources, and so on with a single keystroke. It provides excellent access to the most common actions you perform. This is the most important thing for any engineer who uses kubernetes.

Kubectx

It is very rare for us to have only one cluster. The switch between these is very simple.

Kubectl config use-context my-context

However, there are some prerequisites for doing so:

Before running, you need to know the name of the cluster.

There is another similar set-context command that can crash you.

Kubectx provides a simpler alternative. If you run kubectx separately, it lists all contexts in the .kube / config file. You can then provide the name of the context you are interested in:

Kubectx my-context

You don't have to remember all the contexts, you don't need to check the files manually, and you don't need to get the wrong commands. Beautiful and simple. When used in conjunction with K9s, you can navigate a lot from CLI with minimal keystroke.

Editor: I initially said that K9s does not support switching between contexts. Fernand Galiana's excellent response points out that using the: ctx command, this is possible.

Kubens

After the content can be seen everywhere, you may want to mine a specific namespace. Again, it is common to have multiple namespaces in a cluster. Well, ahmetb (the gentleman who brought you kubectx) also put kubens together. Like kubectx, it applies only to namespaces.

Kubens kube-system

Now, by default, all commands are run against the kube-system namespace. You can also run kubens without anything else to see the list of namespaces.

Kube-ps1

Therefore, you can switch between context and namespaces. But how do you know which one you are currently targeting? It's painful to keep checking. Currently, to find out, you need to run:

Kubenskubectxkubectl

To remove this issue, ps1 is a zsh plug-in that automatically shows you your current context and namespace:

> I'm pointing at my minikube context and the default namespace

Now you can view the namespace and context to indicate without running any commands. It is also highly configurable-if you are only interested in namespaces or context, you can turn it off, or you can disable the entire functionality using kubeoff.

Popeye

Now, go to some different places. Popeye will automatically scan the resources in the repository and highlight obvious problems. This is a very new tool and I find it very useful. If you are going to do some spring cleaning in your cluster, starting with popeye will give you some clear instructions that need to be fixed.

Stern

Have you ever used kubectl logs? Have you noticed that you can only track logs in one Pod at a time? Well, don't worry! Stern is a tool that allows you to extract logs from multiple Pod based on very flexible queries.

I often talk about kubernetes,DevOps and so on on my Twitter account.

Thank you for your reading, the above is the content of "how to set a serious Kubernetes terminal". After the study of this article, I believe you have a deeper understanding of how to set a serious Kubernetes terminal, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report