news 2026/4/16 13:29:32

kubectl plugin:neat 的安装与使用

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
kubectl plugin:neat 的安装与使用

前言

在使用kubectl get $KIND -o yaml查看 k8s 资源时,输出结果中包含大量由集群自动生成的元数据(如managedFieldsresourceVersionuid等)。这些信息在实际复用 yaml 清单时需要手动清理,增加了额外的工作量。

使用 kubectl-neat 插件,可以自动移除这些由集群生成的冗余字段,仅保留有意义的内容,使 yaml 更加简洁,方便复用。

安装

插件方式安装

/* by 01130.hk - online tools website : 01130.hk/zh/calcpressure.html */ kubectl krew install neat ## 作为 kubectl 插件安装,使用方式为: kubectl neat

二进制方式安装

/* by 01130.hk - online tools website : 01130.hk/zh/calcpressure.html */ ## 版本选择: ## https://github.com/itaysk/kubectl-neat/releases ## 当前环境为 ubuntu 2404 LTS wget https://github.com/itaysk/kubectl-neat/releases/download/v2.0.4/kubectl-neat_linux_amd64.tar.gz tar xf kubectl-neat_linux_amd64.tar.gz mv ./kubectl-neat /usr/local/bin/ ## 创建别名(这里看个人习惯) vim /root/.bashrc alias kneat='kubectl-neat'

使用

本次使用二进制方式部署,实际上参数是相同的,没区别

root@network-demo:~# kubectl-neat help Usage: kubectl-neat [flags] kubectl-neat [command] ## 示例是通过 kubectl plugin 方式安装,使用二进制安装改成 kubectl-neat 就好 Examples: kubectl get pod mypod -o yaml | kubectl neat kubectl get pod mypod -oyaml | kubectl neat -o json kubectl neat -f - <./my-pod.json kubectl neat -f ./my-pod.json kubectl neat -f ./my-pod.json --output yaml Available Commands: ## 自动补全命令用的 completion Generate the autocompletion script for the specified shell get help Help about any command version Print kubectl-neat version Flags: -f, --file string file path to neat, or - to read from stdin (default "-") -h, --help help for kubectl-neat -o, --output string output format: yaml or json (default "yaml")

命令补全

简单来说就是按两下 tab 后自动补充没拼完的参数

💡 注:其实没啥用...他只能补全命令本身的参数,并不能补全 k8s 相关信息

root@network-demo:~# kubectl-neat completion --help Generate the autocompletion script for kubectl-neat for the specified shell. See each sub-command's help for details on how to use the generated script. Usage: kubectl-neat completion [command] Available Commands: bash Generate the autocompletion script for bash fish Generate the autocompletion script for fish powershell Generate the autocompletion script for powershell zsh Generate the autocompletion script for zsh Flags: -h, --help help for completion Global Flags: -o, --output string output format: yaml or json (default "yaml")
## 当前环境使用 bash root@network-demo:~# hostnamectl Static hostname: network-demo Icon name: computer-vm Chassis: vm Virtualization: kvm Operating System: Ubuntu 24.04.3 LTS Kernel: Linux 6.8.0-88-generic Architecture: x86-64 ## 添加命令补全 echo "source <(kneat completion bash)" >> ~/.bashrc && source ~/.bashrc ## 查看效果 ## 上面说没啥用的地方就在这...实际上能用的参数只有 get(kubectl-neat 自己的参数) ## 当你补全 get 后就会发现他无法识别 k8s 资源 root@network-demo:~# kubectl-neat completion (Generate the autocompletion script for the specified shell) help (Help about any command) get version (Print kubectl-neat version)

使用方式

## 这里我直接将 kubectl get -o yaml 与 kubectl-neat get -o yaml 输出对比 kubectl-neat get -- pods -n deepflow deepflow-server-fc484c85-p67gl -o yaml > deepflow-kneat.yaml kubectl get pods -n deepflow deepflow-server-fc484c85-p67gl -o yaml > deepflow-kubectl.yaml
## 通过 icdiff 输出两个文件的对比结果,这里为了方便大家看,只把删除的内容放上来了 root@network-demo:~# icdiff deepflow-kubectl.yaml deepflow-kneat.yaml creationTimestamp: "2026-01-23T02:24:57Z" generateName: deepflow-server-fc484c85- generation: 1 ownerReferences: - apiVersion: apps/v1 blockOwnerDeletion: true controller: true kind: ReplicaSet name: deepflow-server-fc484c85 uid: 528ab77f-67ba-4099-8771-bfe06ca9ce2f resourceVersion: "4864722" uid: 0d5ff97b-9c48-4abf-be8b-d2b76f7a14d2 nodeAffinity: {} apiVersion: v1 apiVersion: v1 apiVersion: v1 apiVersion: v1 apiVersion: v1 scheme: HTTP successThreshold: 1 timeoutSeconds: 1 protocol: TCP protocol: TCP protocol: TCP protocol: TCP scheme: HTTP periodSeconds: 10 successThreshold: 1 timeoutSeconds: 1 resources: {} securityContext: {} terminationMessagePath: /dev/termination-log terminationMessagePolicy: File dnsConfig: {} dnsPolicy: ClusterFirst enableServiceLinks: true nodeName: network-demo restartPolicy: Always schedulerName: default-scheduler securityContext: {} serviceAccount: deepflow-server terminationGracePeriodSeconds: 30 defaultMode: 420 defaultMode: 420 apiVersion: v1 status: ## 下面是所有 status 内容...
版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
网站建设 2026/4/16 9:04:19

无需LLM评判,用几何方法检测AI幻觉

无需LLM评判&#xff1a;一种检测AI幻觉的几何方法 想象一群正在飞行的鸟。没有领队&#xff0c;没有中央指令。每只鸟都与邻近的鸟对齐——调整方向、匹配速度&#xff0c;通过纯粹的局部协调保持队形。结果是&#xff0c;全局秩序从局部一致性中涌现出来。 现在想象其中一只…

作者头像 李华
网站建设 2026/4/15 18:52:41

基于SpringBoot的健康管理系统的实现与设计

设计背景与意义随着生活节奏加快和慢性病发病率上升&#xff0c;健康管理需求日益增长。传统健康管理存在数据分散、响应滞后等问题&#xff0c;信息化系统成为解决痛点的关键。SpringBoot因其快速开发、微服务支持等特性&#xff0c;成为构建此类系统的理想技术框架。健康管理…

作者头像 李华
网站建设 2026/4/16 11:08:12

【必学收藏】大模型RAG架构解析:语义理解与语义检索的区别与应用

文章解析了RAG架构中语义理解与语义检索的区别与应用。语义检索是基于向量数据库的相似度计算&#xff0c;用于信息召回&#xff1b;语义理解则是模型解析语言的能力&#xff0c;在智能体架构中起核心作用。二者功能不同但相互配合&#xff0c;共同支撑大模型的自然语言处理能力…

作者头像 李华
网站建设 2026/4/12 6:34:07

收藏!裁员潮下程序员破局:2026年高价值赛道锁定大模型应用开发

年底大厂裁员传闻此起彼伏&#xff0c;不少程序员陷入职场焦虑&#xff0c;直呼就业行情触底、机会寥寥。但拨开表象不难发现&#xff0c;行业并非无岗可寻&#xff0c;而是程序员的高价值赛道正在悄然重构——那些停留在传统开发领域、技能单一的从业者逐渐被淘汰&#xff0c;…

作者头像 李华
网站建设 2026/4/16 13:07:34

使用Selenium破解滑动验证码的原理及解决思路

&#x1f345; 点击文末小卡片 &#xff0c;免费获取软件测试全套资料&#xff0c;资料在手&#xff0c;涨薪更快 1、获取页面元素信息&#xff1a; 使用Selenium打开目标网页&#xff0c;并通过相关方法获取滑块、背景图等元素的位置和属性信息。可以使用Selenium提供的定…

作者头像 李华