当前位置: 首页 > 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.cnnetsun.cn/news/1854464.html

相关文章:

  • HagiCode Desktop 混合分发架构解析:如何用 PP 加速大文件下载桌
  • 救命!中小机房U位管理终于有救了,小白也能躺平运维
  • 第7篇:嵌入式芯片运算核心:ALU_MAC_FPU的工作原理与性能差异
  • 多租户下的系统业务开发过程探讨蓝
  • Typecho完美实现回复可见功能
  • Qwen-Image-2512-Pixel-Art-LoRA 对比测试:与Stable Diffusion基础模型生成效果差异分析
  • 【限时开源】我们刚交付的跨云大模型编排框架CloudFusion已脱敏发布——支持异构GPU拓扑感知与SLA动态协商(仅开放前500名下载)
  • MTK3339 GPS驱动:嵌入式原始报文捕获与RMC解析增强方案
  • SVL轻量向量库:嵌入式C++零堆分配向量运算实践
  • 深入解析perf工具与火焰图:从基础使用到高级性能分析
  • MPU6050-DMP轻量驱动:嵌入式姿态解算的确定性实现
  • 【技术干货】AI 编码代理行为优化:Andrej Karpathy Skills 工程实践指南
  • SWSPI软件SPI协议栈原理与嵌入式工程实践
  • MAX31850 OneWire库深度解析:高精度温度传感嵌入式实践
  • UtilsBoards:ESP32/ESP8266跨平台WiFi与I2C统一接口库
  • CSS如何对表单输入框获取焦点时实现标签上浮过渡
  • Kubernetes网络管理
  • 贾子 TMM元规则:形式化证明与AI评估引擎工程实现
  • 、SEATA分布式事务——XA模式厮
  • 微信小程序的的生鲜销售管理系统
  • CYBER-VISION零号协议入门指南:一键部署,开启智能助盲新篇章
  • IceCMS开源内容管理系统,多端适配资源站
  • 2025最权威的十大降重复率工具横评
  • 孤能子视角:AI“创新-幻觉“工程化框架
  • uniapp真机调试实战:从自定义基座到原生插件集成
  • YOLOv11多模态融合新突破:RGB+红外线(IR)双输入结合HCF-Net的DASI模块,小目标检测性能显著提升!
  • Docker 极简实战:大模型开发工程师的必备指南
  • LLM API工单打标:5大主流方式与核心争议
  • k3s 实战指南 - 利用 Traefik 实现高效微服务部署
  • 3步掌握猫抓资源嗅探:从网页视频到本地文件的完整下载方案