公众号关注 「奇妙的 Linux 世界」
设为「星标」,每天带你玩转 Linux !
Kubernetes 是一个强大的容器编排平台,用于自动化复杂应用程序的部署、管理和扩展。它通常带有kubectl客户端工具,允许用户使用 CLI(命令行界面)与 Kubernetes 集群进行交互。
多年来,kubectl一直与开源社区开发的工具相结合,以改善用户体验。我们将在这里列出五种与 Kubernetes 一起工作的最强大和最有效的工具。
要测试以下工具,我建议您使用kind[1]构建一个 Kubernetes 游乐场。这是一种在本地使用集群并在完成后进行清理的简单方法。
# install kind
brew install kind
# create cluster
kind create cluster --name playground --image kindest/node:v1.21.14
1. K9s
一个非常有用的终端 UI,K9s[2]绝对是我的首选。非常易于使用,直观,它会持续监视集群,并允许您通过命名空间、服务、部署等轻松探索 pod。单击即可进入 pod、检查日志、描述、编辑或端口转发。我将它与我 kubectl 照常运行的另一个 shell 结合使用,以便我可以从两个接口中获得最大收益。
brew install k9s
![033d7d8e8b2cf6a824c8f19e18851516.png](https://i-blog.csdnimg.cn/blog_migrate/d37acd17a0b42e325187c4136cc00fcc.png)
2. Popeye
用于清理 Kubernetes 集群的彩色工具,Popeye是一个开源工具,可查找任何不一致、生成报告并对集群进行评级。
# Install
brew install derailed/popeye/popeye
# Run
popeye
![7b3b598384aba3fc396edf2c688a1623.png](https://i-blog.csdnimg.cn/blog_migrate/84687653b37c32afcc346950ce7e1790.png)
3. Kube-bench
Kube-bench 是另一个方便的工具,可以检查您的 Kubernetes 集群是否已安全部署。您可以这里[3]找到项目存储库。
# Run kube-bench as a job and inspect the logs
curl https://raw.githubusercontent.com/aquasecurity/kube-bench/main/job.yaml | kubectl apply -f -
# get the logs, replace <kube-bench-95cf7> with your pod id
kubectl logs kube-bench-95cf7 -f
运行后,只需选择 pod 并检查日志。同样,您可以在处理集群时使用 K9s 快速观察集群。
![f4a927e07e6539d3bb5124457cf23e48.png](https://i-blog.csdnimg.cn/blog_migrate/46c146e50f0b6ac11d9c608c7004b717.png)
4. Kubectx、Kubens 和 fzf
您正在处理许多集群,dev/stg/prod,还有本地,云……让我们使用kubectx和 kubens 在不同的上下文和命名空间之间快速切换。此外,fzf提供了一种在选项之间切换的交互方式,无需编写或记住上下文或命名空间。
# Install kubectx, kubens, fzf
brew install kubectx fzf
# Switch between namespaces
kubens
![864117012533e5fcf31fb2e74a707872.png](https://i-blog.csdnimg.cn/blog_migrate/f0054cf5f64a0297ed5c70b5bef075b3.png)
5. Stern
一个不可或缺的日志聚合器,Stern[4]将帮助您收集来自不同 pod 的日志并通过颜色区分它们。
# Install
brew install stern
# stern <keyword>
stern deploy
在这个例子中,我们有 3 个副本deploy-demo。我们可以通过选择带有关键字的 pod 来聚合日志deploy。如图所示,每个 pod 对应不同的颜色。
![c68f0d0056c1f5112735d7c45e265984.png](https://i-blog.csdnimg.cn/blog_migrate/1fef82575fbdbf1056041879fdb82711.png)
再推荐一个:Bat
如果您想直接从 shell 快速检查文件(尤其是 yaml), Bat[5]非常有用。Bat 支持主题和其他非常好的功能,例如git集成,可以去探索一下!
# Install bat
brew install bat
# Explore themes
bat --list-themes
# Bat a file
bat deployment.yaml
![fe4743bceaf4f916ffe204a365b6f735.png](https://i-blog.csdnimg.cn/blog_migrate/17c5d39970fdd05164c021b115650622.png)
本文译自: 5 Tools That Will Boost Your Productivity with Kubernetes[6]作者:Giuseppe Laguteta
引用链接
[1]
kind: https://kind.sigs.k8s.io/
[2]K9s: https://github.com/derailed/k9s
[3]这里: https://github.com/aquasecurity/kube-bench
[4]Stern: https://github.com/wercker/stern
[5]Bat: https://github.com/sharkdp/bat
[6]5 Tools That Will Boost Your Productivity with Kubernetes: https://medium.com/@glaguteta/5-tools-that-will-boost-your-productivity-with-kubernetes-1ecaf5477f6d
本文转载自:「云原生技术社区」,原文:https://url.hi-linux.com/bElFk,版权归原作者所有。欢迎投稿,投稿邮箱: editor@hi-linux.com。
最近,我们建立了一个技术交流微信群。目前群里已加入了不少行业内的大神,有兴趣的同学可以加入和我们一起交流技术,在 「奇妙的 Linux 世界」 公众号直接回复 「加群」 邀请你入群。
你可能还喜欢
点击下方图片即可阅读
阿里开源,超强大的 Kubernetes 本地调试工具 Kt-Connect 使用指南
点击上方图片,『美团|饿了么』外卖红包天天免费领
更多有趣的互联网新鲜事,关注「奇妙的互联网」视频号全了解!