其他分享
首页 > 其他分享> > Kubent

Kubent

作者:互联网

Kubent 介绍

Kubent 全称Kube No Trouble是一个简单的工具,主要用于检查k8s集群中是否使用废弃的API版本

Kubent工具可以根据部署资源的进行检测,检测已弃用的API,

特别支持以下方式进行检测:

Kubent 安装

可以手动去GitHub上下载

  1. https://github.com/doitintl/kube-no-trouble/releases/latest

我这里将kubent下载到我下载服务器上 (随着文章时间以及版本更新,不确保为最新版)

  1. [root@k8s-01 tmp]# wget https://d.frps.cn/file/tools/kubent/kubent-0.5.1-linux-amd64.tar.gz

  2. [root@k8s-01 tmp]# tar xf kubent-0.5.1-linux-amd64.tar.gz

  3. [root@k8s-01 tmp]# mv kubent /usr/local/bin/

使用方法

kubent需要通过config文件,读取k8s集群信息。如果我们 /root/.kube/config中包含多个集群信息,可以通过 -k参数指定配置文件。否则默认读取config文件

  1. [root@k8s-01 tmp]# kubent -k /root/.kube/config_abcdocker

  2. 12:57AM INF >>> Kube No Trouble `kubent` <<<

  3. 12:57AM INF version 0.5.1 (git sha a762ff3c6b5622650b86dc982652843cc2bd123c)

  4. 12:57AM INF Initializing collectors and retrieving data

  5. 12:57AM INF Target K8s version is 1.23.5

  6. 12:57AM INF Retrieved 35 resources from collector name=Cluster

  7. 12:57AM INF Retrieved 0 resources from collector name="Helm v2"

  8. 12:57AM INF Retrieved 150 resources from collector name="Helm v3"

  9. 12:57AM INF Loaded ruleset name=custom.rego.tmpl

  10. 12:57AM INF Loaded ruleset name=deprecated-1-16.rego

  11. 12:57AM INF Loaded ruleset name=deprecated-1-22.rego

  12. 12:57AM INF Loaded ruleset name=deprecated-1-25.rego

  13. __________________________________________________________________________________________

  14. >>> Deprecated APIs removed in 1.25 <<<

  15. ------------------------------------------------------------------------------------------

  16. KIND NAMESPACE NAME API_VERSION REPLACE_WITH (SINCE)

  17. PodSecurityPolicy <undefined> psp.flannel.unprivileged policy/v1beta1 <removed> (1.21.0)

  18. PodSecurityPolicy cattle-monitoring-system rancher-monitoring-alertmanager policy/v1beta1 <removed> (1.21.0)

  19. PodSecurityPolicy cattle-monitoring-system rancher-monitoring-crd-manager policy/v1beta1 <removed> (1.21.0)

  20. PodSecurityPolicy cattle-monitoring-system rancher-monitoring-grafana policy/v1beta1 <removed> (1.21.0)

  21. PodSecurityPolicy cattle-monitoring-system rancher-monitoring-kube-state-metrics policy/v1beta1 <removed> (1.21.0)

  22. PodSecurityPolicy cattle-monitoring-system rancher-monitoring-operator policy/v1beta1 <removed> (1.21.0)

  23. PodSecurityPolicy cattle-monitoring-system rancher-monitoring-patch-sa policy/v1beta1 <removed> (1.21.0)

  24. PodSecurityPolicy cattle-monitoring-system rancher-monitoring-prometheus policy/v1beta1 <removed> (1.21.0)

  25. PodSecurityPolicy cattle-monitoring-system rancher-monitoring-prometheus-adapter policy/v1beta1 <removed> (1.21.0)

  26. PodSecurityPolicy cattle-monitoring-system rancher-monitoring-prometheus-node-exporter policy/v1beta1 <removed> (1.21.0)

Deprecated APIs removed in 1.25下面就会显示当前k8s集群中已经废弃的apiserver

更多kubent命令

  1. $./kubent -h

  2. Usage of ./kubent:

  3. -a, --additional-kind strings additional kinds of resources to report in Kind.version.group.com format

  4. -c, --cluster enable Cluster collector (default true)

  5. -x, --context string kubeconfig context

  6. -e, --exit-error exit with non-zero code when issues are found

  7. -f, --filename strings manifests to check, use - for stdin

  8. --helm2 enable Helm v2 collector (default true)

  9. --helm3 enable Helm v3 collector (default true)

  10. -k, --kubeconfig string path to the kubeconfig file

  11. -l, --log-level string set log level (trace, debug, info, warn, error, fatal, panic, disabled) (default "info")

  12. -o, --output string output format - [text|json] (default "text")

  13. -t, --target-version string target K8s version in SemVer format (autodetected by default)

  14. -v, --version prints the version of kubent and exits

github地址https://github.com/doitintl/kube-no-trouble

标签:57AM,Kubent,monitoring,--,kubent,12,INF
来源: https://www.cnblogs.com/cheyunhua/p/16449301.html