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

相关文章:

  • 【华为云】JupyterLab中高效解压文件夹的完整指南
  • 从零到一:在UniApp原生插件中集成并调用第三方硬件SDK
  • 知识星球内容保存指南:3步实现PDF永久归档
  • Vue.Draggable如何解决现代Web应用中的拖拽交互难题?
  • 实时行情系统设计:从协议选择到高可用架构,再到数据源选型泵
  • 品牌推荐: 打破进口垄断!国产中压玻璃柱品牌值得关注 - 品牌推荐大师1
  • cv_resnet101_face-detection_cvpr22papermogface 在.NET生态中的集成:通过ONNX Runtime调用模型
  • SRWE:解锁Windows窗口无限可能的实时编辑神器
  • AI原生交付的“奇点临界点”已至:Gartner最新评估显示,2026年Q2前未完成AI-Native CD迁移的企业将丧失73%的A/B测试响应优势——你现在行动还剩多少窗口期?
  • WordPress AI评论插件V1.3:智能互动与自动化管理实战指南
  • 2026年工业锅炉搭配:解读行业三大核心趋势 - 速递信息
  • 多任务学习避坑指南:从‘负迁移’到高效协同,我的模型调优心得
  • 揭秘!两款神级托福APP如何帮你逆袭?多次元托福APPvs 托福Easy姐深度测评 - 速递信息
  • [Uni-app] 微信小程序圆环进度条实现与优化指南
  • 一句话出全套商品图,这才是电商人该用的 AI 神器
  • 如何彻底解决Cursor AI试用限制:免费解锁Pro功能的完整技术方案
  • 龙芯k - 走马观碑组MPU驱动移植窖
  • STM32G474的SPI Flash数据掉电保存实战:以W25Q32存储传感器历史数据为例
  • 深入STM32G474中断机制:用SysTick和EXTI中断实现一个精准的按键消抖与长按短按识别
  • 无锡迈腾WEG电机选购指南:科学选型与避坑全攻略 - 速递信息
  • Hunyuan-MT Pro API安全防护:防滥用与限流策略
  • AAV三质粒比例优化指南|如何选择合适的GMP级PEI转染试剂【曼博生物-Polysciences中国独家提供商】 - 上海曼博生物
  • 小白友好:通义千问1.8B Docker部署避坑指南
  • Beyond Compare 5终极激活方案:三步解决文件对比工具授权问题
  • 别只盯着错误日志!用这3个工具提前诊断你的Stable Diffusion WebUI部署环境
  • 购买龙门去哪个网站?购买立加去哪个网站?购买卧加去哪个网站? - 品牌推荐大师1
  • Aegisub完全指南:如何快速掌握专业字幕编辑的5个核心技巧
  • C++的std--is_nothrow_swapable与异常安全保证在移动操作中的检查
  • 我用AI Agent 20分钟造了一个全栈产品经理,覆盖前端+后端+AI大模型,产品从0到1全搞定!
  • 2026年南京手术床选购指南:三招教你挑对高性价比产品 - 精选优质企业推荐榜