当前位置: 首页 > 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/621232/

相关文章:

  • 智能宠物喂食器项目复盘:那些硬件选型与软件调试中踩过的坑
  • 别再手动拼中间件了!用Go Kratos框架5分钟搞定一个带链路追踪的微服务
  • 2026年热门的陕汽中心库多家厂家对比分析 - 品牌宣传支持者
  • RCE绕过新思路:0xGame中dc计算器漏洞利用全解析(附GTFOBins实战指南)
  • 全自动铺布机选购指南:核心指标与品牌实力评估
  • ESP32轻量级Sonos控制库:UPnP协议嵌入式实现
  • 保姆级教程:用Python+Pytorch复现MSCNN-1D模型,搞定CWRU轴承故障诊断(附完整代码)
  • 小程序黑白棋AI:从零实现一个简单的游戏AI
  • Android逆向实战:火柴人联盟v1.14.1去广告与内购破解全流程解析(附smali修改技巧)
  • arcgis在1:500cass中的应用
  • Cinema 4D 手指关节绑定实战:从模型导入到动画控制
  • ingress在一个网站下部署两个前端项目,通过路由前缀区分
  • 2026年热门的地磅/防爆地磅优质厂家汇总推荐 - 品牌宣传支持者
  • 保姆级教程:在Vivado 2023.1中手把手配置Xilinx 7系列FPGA的PCIe硬核IP
  • QT开发避坑:QSlider滑块值变化处理的两种方式,别再只用valueChanged了
  • TimeKAN:基于频率分解的时间序列预测新范式,ICLR 2025亮点解析
  • MCP 实践(二)Streamable HTTP:统一端点与动态流式传输的架构演进
  • GD32单片机低功耗模式深度解析:从理论到源码实战
  • 2026Q2精密非标定制塑料成型机怎么选:精密非标定制塑料成型机/连续式挤压成型机/非标塑料成型机/高速吸塑机/选择指南 - 优质品牌商家
  • texlive环境下实现times字体的一个组合命令
  • 5分钟解锁B站缓存视频:m4s-converter让你的收藏永不消失
  • 2026年家用浴花合规生产企业盘点:变色浴花/四色浴球/四色浴花/回弹压缩沙发/多功能压缩沙发/多色浴花/大号浴球/选择指南 - 优质品牌商家
  • Celery 实战解析:构建高效Python分布式任务队列系统
  • 用Wireshark抓包,带你亲历OSPF邻居从‘相亲’到‘结婚’的7个状态
  • Langchain项目实战:用PostgreSQL的PGVector插件存向量,比专用向量数据库省了多少钱?
  • 2026年320千瓦充电桩厂家排行:充电桩那个牌子好/充电桩销售/充电桩销售/充电站投建/兆瓦充电桩/兆瓦充电桩/选择指南 - 优质品牌商家
  • 多功能空调控制系统的设计(有完整资料)
  • YOLOv5实战:无人机巡检图片差异对比与违建标记(附完整代码)
  • Tauri 2.0 Shell插件避坑指南:预设参数覆盖、权限配置与Command.create的正确姿势
  • Redis 实现接口幂等性的三种高效策略