当前位置: 首页 > news >正文

Linux I/O 演进史:从管道到零拷贝,一篇串起个服务端核心原语俅

前言

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

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

安装

插件方式安装

kubectl krew install neat

## 作为 kubectl 插件安装,使用方式为:

kubectl neat

二进制方式安装

## 版本选择:

## 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 内容...级臀对池

http://www.jsqmd.com/news/613343/

相关文章:

  • 重装 Office 必看:Win10/Win11 完美卸载 Office 2021(附视频)
  • 2026汕头整体家居定制选型指南:满足这3个硬指标才算靠谱 - 精选优质企业推荐榜
  • 为什么Windows用户需要Apple-Mobile-Drivers-Installer?1分钟解决iPhone USB网络共享问题
  • 免费开源小说阅读器ReadCat:如何在广告泛滥的时代找回纯粹的阅读体验?
  • 设计一个安全的时效性遥控协议:对抗重放攻击
  • SiameseUIE效果实测:中文OCR后文本(含错别字)仍保持82%+抽取准确率
  • Zotero文献去重终极指南:如何快速清理重复条目提升研究效率
  • League-Toolkit:英雄联盟客户端全能效率引擎
  • 2026 年最新云南职业装十大品牌推荐及解析 - 十大品牌榜
  • AI系统静默失效:传统监控无法检测的隐形威胁
  • 多相机协同拍照原理底层刨析
  • GitHub加速插件终极指南:3分钟彻底告别下载缓慢的烦恼
  • Win10 多余账户怎么删?官方步骤 + 完整备份提醒,一次成功
  • 3大突破!multi-download让浏览器批量下载效率提升300%的实战指南
  • Vue 和 React 的核心渲染机制 对比
  • RFID智能保管柜-RFID智能保管柜源头生产厂家 - 聚澜智能
  • 向华为学习——解读华为战略执行全解码从规划到行动的DSTE与BLM模型集成应用方案【附全文阅读】
  • 掌握精准控制:AccelStepper步进电机库全攻略
  • 2026Q2 温州财税代理记账口碑 TOP6 工商注册资质代办中小企业优选品牌 - 品牌智鉴榜
  • 终极指南:3步快速配置Microsoft Word APA第7版参考文献格式
  • 驱动仓库清理黑科技:Driver Store Explorer让Windows系统轻装上阵
  • 我让 Claude 和 Codex 同时审计 个模块,它们只在 个上达成共识一
  • AI到底会不会导致大规模失业?一次性把所有问题讲透!(深度好文)
  • Pixel Couplet Gen 惊艳像素春联作品集:AI与传统文化的创意碰撞
  • 学Simulink——基于SVPWM的过调制(Overmodulation)策略扩展电压输出能力
  • 【递归、搜索与回溯算法】专题三——穷举vs暴搜vs深搜vs回溯vs剪枝
  • 30天试用限制如何破局?IDM开源重置工具的技术实现与合规使用指南
  • 2026汕头装修全屋定制选型指南:满足这3个硬指标才算靠谱 - 精选优质企业推荐榜
  • 3大引擎驱动:COMET如何重构翻译质量评估体系
  • 好影教育靠谱吗?实力铸就口碑,打造影视后期培训标杆品牌 - 资讯焦点