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

WPF新手村教程(七)—— 终章(MVVM架构初见杀)

前言

在使用 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/582020/

相关文章:

  • 一体化数字引擎 驱动机械设备非标项目精益盈
  • 2026/4/3 函数模板与类模板
  • Google Stitch + MCP:AI 时代的“设计即代码“新范式
  • 今天使用trae进行代码开发的一点点小感触
  • 3步解锁图表数据:用计算机视觉将图像转化为结构化数据的实战秘籍
  • 3大核心价值:Tiktokenizer如何解决AI开发中的令牌管理难题
  • 新能源/电力系统论文中的应用及盲审注意事项
  • 分析2026年天津法律服务,宋春娇律师交通事故简单案件处理能力哪家强 - mypinpai
  • 2026年天津热门律师推荐,宋春娇律师交通事故服务态度靠谱吗 - myqiye
  • 2026无机水磨石厂家品牌推荐,红舵建材性价比超高 - 工业推荐榜
  • 项目经理的最高境界,是学会“睁一只眼闭一只眼”
  • 德希科技在线 COD 传感器
  • 杭州做工贸企业管理能力提升培训的公司价格怎样 - 工业设备
  • 新手福音:用快马将前端面试考点变成可运行的学习项目
  • 5步完美配置ComfyUI IPAdapter CLIP Vision模型:从入门到精通实战指南
  • 3个关键步骤:用RuoYi-Vue-Plus构建企业级分布式管理系统
  • 强制性国标 GB 26572-2025 实施在即,电子产业链合规挑战与应对
  • Visa推出全新服务,推动争议解决流程现代化升级
  • 为什么DeepSeek-R1适合本地部署?隐私安全实战分析
  • 新手必看!Seed-Coder-8B-Base环境配置与简单调用指南
  • 2026年连接器上料难题破解:汽车产线适配方案详解 - 品牌2026
  • 3步构建智能化学研究助手:从环境配置到功能验证全指南
  • 基于多模态图像融合与深度学习算法的轴承故障诊断模型——GADF+Swin-CNN-GAM与GA...
  • 如何选购靠谱的维修维保服务外包团队,看这篇就够 - 工业品牌热点
  • 场景深耕,生态共生——视程空间,让边缘算力真正落地千行百业
  • 颠覆性知识管理系统:Obsidian Projects如何引发学术研究效率革命
  • semi-utils智能批处理引擎:照片水印效率革命终极指南
  • 出现io.netty.util.IllegalReferenceCountException: refCnt: 0, decrement: 1的原因及解决办法
  • AI辅助数据库设计:让快马平台的Kimi模型成为你的课程设计智能顾问
  • 零基础入门:借助快马AI理解并生成你的第一个软件安装包