简体   繁体   中英

Easily detect deprecated resources on Kubernetes

We've just received an e-mail from GCP informing us that our clusters are currently using deprecated Beta APIs and that we need to upgrade to the newest API version.

We have 3 clusters running multiple resources in multiple namespaces so it would be a bit painful having to go through all of them detecting which ones are obsolete.

The ones we control such as services, deployments, horizontalpodautoscalers, poddisruptionbudgets etc, those ones are already updated.

But we have many services whose manifest files are automatically generated such as Spinnaker services generated by Halyard, or ElasticSearch generated by Elastic Operator, etc.

Is there any way to filter all resources by the API version, or any way to detect deprecated resources across all namespaces?

In order to view which API are supported by your cluster

# Print out supported API's in the cluster
kubectl api-versions

In order to view deprecated API, you can use this tool.
it's exactly what you asked for, it will print list of resources with the deprecated API's.

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

# sample output from the official docs:


$./kubent
6:25PM INF >>> Kube No Trouble `kubent` <<<
6:25PM INF Initializing collectors and retrieving data
6:25PM INF Retrieved 103 resources from collector name=Cluster
6:25PM INF Retrieved 132 resources from collector name="Helm v2"
6:25PM INF Retrieved 0 resources from collector name="Helm v3"
6:25PM INF Loaded ruleset name=deprecated-1-16.rego
6:25PM INF Loaded ruleset name=deprecated-1-20.rego
_____________________________________________________________________
>>> 1.16 Deprecated APIs <<<
---------------------------------------------------------------------
KIND         NAMESPACE     NAME                    API_VERSION
Deployment   default       nginx-deployment-old    apps/v1beta1
Deployment   kube-system   event-exporter-v0.2.5   apps/v1beta1
Deployment   kube-system   k8s-snapshots           extensions/v1beta1
Deployment   kube-system   kube-dns                extensions/v1beta1
_____________________________________________________________________
>>> 1.20 Deprecated APIs <<<
---------------------------------------------------------------------
KIND      NAMESPACE   NAME           API_VERSION
Ingress   default     test-ingress   extensions/v1beta1

Installing kubent

# install `kubent`
sh -c "$(curl -sSL 'https://git.io/install-kubent')"

Running kubent

kubent

在此处输入图像描述


Additional Similar tools:

kdave checks for any deprecated or removed apiVersions in the cluster and exports them in a Prometheus metrics format. It collects these apiVersions from the deployed helm releases It allows you to have visibility and answer these questions

  • How many applications in the cluster use deprecated apiVersions
  • How many applications in the cluster use removed apiVersions
  • Will the deprecated apiVersions be removed in the next release or next two releases
  • What are the replacement apiVersions for these deprecated or removed apiVersions

kdave https://github.com/wayfair-incubator/kdave and the k8s-used-api-versionshttps://github.com/wayfair-incubator/k8s-used-api-versions

https://www.linkedin.com/pulse/kubernetes-used-api-versions-operator-ahmed-elbakry/ https://www.linkedin.com/pulse/kubernetes-deprecated-api-versions-exporter-ahmed-elbakry/

Has anyone used kdave? I keep getting errors while running locally using their cli

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM