Easily check your clusters for use of deprecated APIs
Easily check your clusters for use of deprecated APIs
Easily check your clusters for use of deprecated APIs
Kubernetes 1.16 is slowly starting to roll out, not only across various managed Kubernetes offerings, and with that come a lot of API deprecations1.
Kube No Trouble (kubent) is a simple tool to check whether you're using
any of these API versions in your cluster and therefore should upgrade your
workloads first, before upgrading your Kubernetes cluster.
This tool will be able to detect deprecated APIs depending on how you deploy your resources, as we need the original manifest to be stored somewhere. In particular following tools are supported:
kubectl.kubernetes.io/last-applied-configuration annotationAdditional resources:
Run the following command in your terminal to install kubent using a shell script:
sh -c "$(curl -sSL https://git.io/install-kubent)"(Unless specified the script will download latest version and unpack to /usr/local/bin/).
Note: Do not run random scripts from strangers on the internet. Read what the above script does first.
You can download the latest release for your cpu architectures and operating system. You can then place it on your path.
We currently maintain, the following operating systems and cpu architectures:
Historically Windows on arm, has not received the best support. If this changes we may add it.
Please note that third-party installation methods are maintained by the community.
The packages may not always be up-to-date with the latest releases of kubent.
kubent is available as a formula
on Homebrew. If you're using macOS or Linux, you can run
the following command to install kubent:
brew install kubentkubent is available for Scoop as an app.
Install kubent by running:
scoop install kubentConfigure Kubectl's current context to point to your cluster, kubent will
look for the kube .config file in standard locations (you can point it to custom
location using the -k switch).
kubent will collect resources from your cluster and report on found issues.
Please note that you need to have sufficient permissions to read Secrets in the
cluster in order to use Helm* collectors.
…You can list all the configuration options available using --help switch:
…--additional-annotation
Check additional annotations for the last applied configuration. This can be useful if a resource was applied
with a tool other than kubectl. The flag can be used multiple times.
-a, --additional-kind
Tells kubent to flag additional custom resources when found in the specified version. The flag can be used multiple
times. The expected format is full Kind.version.group.com form - e.g. -a ManagedCertificate.v1.networking.gke.io.
-x, --context
Select context from kubeconfig file (current-context from the file is used by default).
-k, --kubeconfig
Path to kubeconfig file to use. This takes precedence over KUBECONFIG environment variable, which is also supported
and can contain multiple paths, and default ~/.kube/config.
-t, --target-version
kubent will try to detect K8S cluster version and display only relevant findings. This flag allows to override this
version for scenarios like use in CI with the file collector only, when detection from an actual cluster is not possible.
Expected format is major.minor[.patch], e.g. 1.16 or 1.16.3.
We also publish official container image, which can be found at:
ghcr.io/doitintl/kube-no-trouble:latest (also available tagged with each
individual release version).
To run locally, you'll need to provide credentials, e.g. by sharing your kubectl config:
$ docker run -it --rm \
-v "${HOME}/.kube/config:/.kubeconfig" \
ghcr.io/doitintl/kube-no-trouble:latest \
-k /.kubeconfigYou can use kubectl run to run inside a K8S cluster, as a one-off. In that
case the credentials will be picked up via the pod's service account from the
environment, but you'll want to grant relevant permissions first (see
docs/k8s-sa-and-role-example.yaml):
$ kubectl run kubent --restart=Never --rm -i --tty \
--image ghcr.io/doitintl/kube-no-trouble:latest \
--overrides='{"spec": {"serviceAccount": "kubent"}}'kubent will by default return 0 exit code if the program succeeds, even if
it finds deprecated resources, and non-zero exit code if there is an error
during runtime. Because all info output goes to stderr, it's easy to check in
shell if any issues were found:
test -z "$(kubent)" # if stdout output is empty, means no issues were found
# equivalent to [ -z "$(kubent)" ]It's actually better so split this into two steps, in order to differentiate between runtime error and found issues:
if ! OUTPUT="$(kubent)"; then # check for non-zero return code first
echo "kubent failed to run!"
elif [ -n "${OUTPUT}" ]; then # check for empty stdout
echo "Deprecated resources found"
fiYou can also use --exit-error (-e) flag, which will make kubent to exit
with non-zero return code (200) in case any issues are found.
Alternatively, use the json output and smth. like jq to check if the result is
empty:
kubent -o json | jq -e 'length == 0'If you want to scan all files in a given directory, you can use the following shell snippet:
FILES=($(ls *.yaml)); kubent ${FILES[@]/#/-f} --helm3=false -c=falseThe simplest way to build kubent is:
# Clone the repository
git clone https://github.com/doitintl/kube-no-trouble.git
cd kube-no-trouble/
# Build
go build -o bin/kubent ./...Otherwise there's Makefile
$ make
make
all Clean, build and pack
help Prints list of tasks
build Build binary
generate Go generate
release-artifacts Create release artifacts
clean Clean build artifactsPlease open any issues and/or PRs against github.com/doitintl/kube-no-trouble repository. See our contribution guide for more details
No open issues yet, or sync has not completed.