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

相关文章:

  • 2026 HDU 春季十连测
  • 企业年会知识竞赛互动环节设计指南:提升参与感与团队凝聚力
  • 如何保证模型结构化输出
  • OpenClaw邮件处理机器人:Qwen3-14b_int4_awq实现的智能分类与回复
  • 多智能体强化学习—QPLEX:优势分解与协同决策的深度解析
  • 微信立减金回收价格公示,如何避坑 - 猎卡回收公众号
  • WebSocket实现实时通知
  • Python自动化调色:DaVinci Resolve API实战指南与场景应用
  • 支持多语种的知识竞赛软件有哪些?顶伯等主流工具功能对比
  • 3步革命性自动化:Win11Debloat如何智能重塑你的Windows体验
  • OpenClaw邮件自动化:Qwen3-4B处理每日百封邮件实战
  • CMU 15-445 Project1 通关秘籍:手把手教你实现可扩展哈希表(附完整测试用例)
  • 2026年智能书籍要点总结App避坑攻略:Top5解析,别让伪效率工具浪费你的时间
  • 魔兽争霸III终极优化指南:WarcraftHelper插件让你的经典游戏焕发第二春 [特殊字符]
  • 从Excel到Markdown:3分钟让你的Obsidian表格整齐如初
  • 三电平有源电力滤波器方案:全套软硬件资料,基于DSP28335,可实现直接量产
  • 记录
  • GAMES101【lecture5-8】精讲:从光栅化到着色,图形学核心流程实战解析
  • ElevenLabs、Descript、EasyDubbing,谁更适合做 YouTube/Tiktok 多语言内容?
  • 20252912 2024-2025-2 《网络攻防实践》实验五
  • 5 种在安卓手机 / 平板与电脑间同步音乐的方法
  • Qwen2-VL-2B-Instruct结合YOLOv8:实现视频流实时分析与描述
  • 基于51单片机的TB6600步进电机驱动程序
  • 利用Python脚本实现PubChem SID/CID到SMILES的批量映射与数据增强
  • 软件测试人员转型AI大模型开发:零基础学习路线图
  • BabelDOC终极指南:如何用开源工具实现PDF文档无损翻译?
  • 2026年4月玻璃幕墙公司找哪家,钢结构/钢构/幕墙/管桁架/轻钢构/钢结构幕墙/玻璃幕墙/重钢构,玻璃幕墙公司哪家好 - 品牌推荐师
  • 终极USB设备安全弹出指南:告别“设备正在使用“的烦恼
  • 用Keil5和SX1276搞LoRa距离实测:从30米机房到1000米操场,我的避坑记录
  • OpenClaw隐私保护方案:千问3.5-9B本地处理敏感数据