Skip to content

1. kubectl-neat介绍

消除Kubernetes 清单中的混乱,使其更具可读性

2. neat部署

2.1 通过插件部署

bash
[root@kube-master ~]# kubectl krew install neat
Updated the local copy of plugin index.
  New plugins available:
    * cautious
    * cnf
    * cond
    * dpm
    * jfs
    * kueue
    * track
Installing plugin: neat
Installed plugin: neat
\
 | Use this plugin:
 | 	kubectl neat
 | Documentation:
 | 	https://github.com/itaysk/kubectl-neat
/
WARNING: You installed plugin "neat" from the krew-index plugin repository.
   These plugins are not audited for security by the Krew maintainers.
   Run them at your own risk.
[root@kube-master ~]# kubectl krew install neat
Updated the local copy of plugin index.
  New plugins available:
    * cautious
    * cnf
    * cond
    * dpm
    * jfs
    * kueue
    * track
Installing plugin: neat
Installed plugin: neat
\
 | Use this plugin:
 | 	kubectl neat
 | Documentation:
 | 	https://github.com/itaysk/kubectl-neat
/
WARNING: You installed plugin "neat" from the krew-index plugin repository.
   These plugins are not audited for security by the Krew maintainers.
   Run them at your own risk.

2.2 通过二进制部署

官档,https://github.com/itaysk/kubectl-neat

#下载
https://github.com/itaysk/kubectl-neat/releases/download/v2.0.4/kubectl-neat_linux_amd64.tar.gz

#解压,放到/path/bin,并添加权限
#下载
https://github.com/itaysk/kubectl-neat/releases/download/v2.0.4/kubectl-neat_linux_amd64.tar.gz

#解压,放到/path/bin,并添加权限

3. neat使用

bash
#查看pod
[root@kube-master ~]# kubectl get pod
NAME                                      READY   STATUS    RESTARTS        AGE
old-demo-687c6ccd99-2rzwr                 1/1     Running   25 (170m ago)   33d

#查看deploy
[root@kube-master ~]# kubectl get deployments.apps
NAME                     READY   UP-TO-DATE   AVAILABLE   AGE
old-demo                 2/2     2            2           74d


#生成yaml
kubectl get deployments.apps old-demo -oyaml > test-neat.yaml

#通过kubectl-neat 过滤
kubectl-neat -f test-neat.yaml > new-neat.yaml
#查看pod
[root@kube-master ~]# kubectl get pod
NAME                                      READY   STATUS    RESTARTS        AGE
old-demo-687c6ccd99-2rzwr                 1/1     Running   25 (170m ago)   33d

#查看deploy
[root@kube-master ~]# kubectl get deployments.apps
NAME                     READY   UP-TO-DATE   AVAILABLE   AGE
old-demo                 2/2     2            2           74d


#生成yaml
kubectl get deployments.apps old-demo -oyaml > test-neat.yaml

#通过kubectl-neat 过滤
kubectl-neat -f test-neat.yaml > new-neat.yaml