{"id":13497513,"url":"https://github.com/doitintl/kube-no-trouble","last_synced_at":"2025-05-12T13:22:43.300Z","repository":{"id":37095608,"uuid":"254161684","full_name":"doitintl/kube-no-trouble","owner":"doitintl","description":"Easily check your clusters for use of deprecated APIs","archived":false,"fork":false,"pushed_at":"2025-05-05T11:09:50.000Z","size":931,"stargazers_count":3458,"open_issues_count":30,"forks_count":162,"subscribers_count":18,"default_branch":"master","last_synced_at":"2025-05-08T03:49:25.716Z","etag":null,"topics":["cluster","gke","hacktoberfest","k8s","kube","kubernetes"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/doitintl.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2020-04-08T17:55:01.000Z","updated_at":"2025-05-07T17:33:18.000Z","dependencies_parsed_at":"2023-02-15T07:40:45.042Z","dependency_job_id":"3108a624-99db-47dd-a575-afebaa8e0b6a","html_url":"https://github.com/doitintl/kube-no-trouble","commit_stats":{"total_commits":350,"total_committers":17,"mean_commits":20.58823529411765,"dds":"0.36571428571428577","last_synced_commit":"84d2b106a4e1e64549367e2096ccc12ab30d0555"},"previous_names":[],"tags_count":123,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doitintl%2Fkube-no-trouble","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doitintl%2Fkube-no-trouble/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doitintl%2Fkube-no-trouble/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doitintl%2Fkube-no-trouble/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/doitintl","download_url":"https://codeload.github.com/doitintl/kube-no-trouble/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253745277,"owners_count":21957337,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cluster","gke","hacktoberfest","k8s","kube","kubernetes"],"created_at":"2024-07-31T20:00:32.366Z","updated_at":"2025-05-12T13:22:43.271Z","avatar_url":"https://github.com/doitintl.png","language":"Go","funding_links":[],"categories":["Go","Tools","Kubernetes","Tools and Libraries","kubernetes","Diagnostics \u0026 Troubleshooting","OPS","Repositories"],"sub_categories":["Examples","Kubernetes security posture management","Miscellaneous"],"readme":"![Kubent (Kube-No-Trouble) logo](./docs/imgs/kubent-logo.svg)\n\n__*Easily check your clusters for use of deprecated APIs*__\n\nKubernetes 1.16 is slowly starting to roll out, not only across various managed\nKubernetes offerings, and with that come a lot of API deprecations[1][1].\n\n*Kube No Trouble (__`kubent`__)* is a simple tool to check whether you're using\nany of these API versions in your cluster and therefore should upgrade your\nworkloads first, before upgrading your Kubernetes cluster.\n\nThis tool will be able to detect deprecated APIs depending on how you deploy\nyour resources, as we need the original manifest to be stored somewhere. In\nparticular following tools are supported:\n- **file**    - local manifests in YAML or JSON\n- **kubectl** - uses the `kubectl.kubernetes.io/last-applied-configuration` annotation\n- **Helm v3** - uses Helm manifests stored as Secrets or ConfigMaps directly in individual namespaces\n\n[1]: https://kubernetes.io/blog/2019/07/18/api-deprecations-in-1-16/\n\n**Additional resources:**\n- Blog post on K8s deprecated APIs and introduction of kubent: [Kubernetes: Deprecated APIs aka Introducing Kube-No-Trouble][2]\n\n[2]: https://stepan.wtf/kubernetes-deprecated-apis-introducing-kubent/\n\n## Install\n\nRun the following command in your terminal to install `kubent` using a shell script:\n\n```sh\nsh -c \"$(curl -sSL https://git.io/install-kubent)\"\n```\n\n*(Unless specified the script will download latest version and unpack to `/usr/local/bin/`).*\n\n\u003e Note: Do not run random scripts from strangers on the internet. Read what the above script does first.\n\n### Manual Installation\n\nYou can download the\n[latest release](https://github.com/doitintl/kube-no-trouble/releases/latest)\nfor your cpu architectures and operating system. You can then place it on your path.\n\nWe currently maintain, the following operating systems and cpu architectures:\n\n- Linux amd64\n- Linux arm64\n- Darwin amd64\n- Darwin arm64\n- Windows amd64\n\n*Historically Windows on arm, has not received the best support. If this changes we may add it.*\n\n### Third-Party Installation\n\nPlease note that third-party installation methods are maintained by the community.\n**The packages may not always be up-to-date with the latest releases of** `kubent`.\n\n#### Homebrew\n\n`kubent` is available as a [formula](https://formulae.brew.sh/formula/kubent)\non [Homebrew](https://brew.sh/). If you're using macOS or Linux, you can run\nthe following command to install `kubent`:\n\n```sh\nbrew install kubent\n```\n\n#### Scoop\n`kubent` is available for [Scoop](https://scoop.sh/) as an [app](https://bjansen.github.io/scoop-apps/main/kubent/).\nInstall `kubent` by running:\n\n```powershell\nscoop install kubent\n```\n\n## Usage\n\nConfigure Kubectl's current context to point to your cluster, `kubent` will\nlook for the kube `.config` file in standard locations (you can point it to custom\nlocation using the `-k` switch).\n\n**`kubent`** will collect resources from your cluster and report on found issues.\n\n*Please note that you need to have sufficient permissions to read Secrets in the\ncluster in order to use `Helm*` collectors.*\n\n```sh\n$./kubent\n6:25PM INF \u003e\u003e\u003e Kube No Trouble `kubent` \u003c\u003c\u003c\n6:25PM INF Initializing collectors and retrieving data\n6:25PM INF Retrieved 103 resources from collector name=Cluster\n6:25PM INF Retrieved 0 resources from collector name=\"Helm v3\"\n6:25PM INF Loaded ruleset name=deprecated-1-16.rego\n6:25PM INF Loaded ruleset name=deprecated-1-20.rego\n__________________________________________________________________________________________\n\u003e\u003e\u003e 1.16 Deprecated APIs \u003c\u003c\u003c\n------------------------------------------------------------------------------------------\nKIND         NAMESPACE     NAME                    API_VERSION\nDeployment   default       nginx-deployment-old    apps/v1beta1\nDeployment   kube-system   event-exporter-v0.2.5   apps/v1beta1\nDeployment   kube-system   k8s-snapshots           extensions/v1beta1\nDeployment   kube-system   kube-dns                extensions/v1beta1\n__________________________________________________________________________________________\n\u003e\u003e\u003e 1.20 Deprecated APIs \u003c\u003c\u003c\n------------------------------------------------------------------------------------------\nKIND      NAMESPACE   NAME           API_VERSION\nIngress   default     test-ingress   extensions/v1beta1\n```\n\n### Arguments\n\nYou can list all the configuration options available using `--help` switch:\n```sh\n$./kubent -h\nUsage of ./kubent:\n  -A, --additional-annotation strings   additional annotations that should be checked to determine the last applied config\n  -a, --additional-kind strings         additional kinds of resources to report in Kind.version.group.com format\n  -c, --cluster                         enable Cluster collector (default true)\n  -x, --context string                  kubeconfig context\n  -e, --exit-error                      exit with non-zero code when issues are found\n  -f, --filename strings                manifests to check, use - for stdin\n      --helm3                           enable Helm v3 collector (default true)\n  -k, --kubeconfig string               path to the kubeconfig file\n  -l, --log-level string                set log level (trace, debug, info, warn, error, fatal, panic, disabled) (default \"info\")\n  -o, --output string                   output format - [text|json|csv] (default \"text\")\n  -O, --output-file string        output file, use - for stdout (default \"-\")\n  -t, --target-version string           target K8s version in SemVer format (autodetected by default)\n  -v, --version                         prints the version of kubent and exits\n```\n- *`--additional-annotation`*\n  Check additional annotations for the last applied configuration. This can be useful if a resource was applied\n  with a tool other than kubectl. The flag can be used multiple times.\n\n- *`-a, --additional-kind`*\n  Tells `kubent` to flag additional custom resources when found in the specified version. The flag can be used multiple\n  times. The expected format is full *Kind.version.group.com* form - e.g. `-a ManagedCertificate.v1.networking.gke.io`.\n\n- *`-x, --context`*\n  Select context from kubeconfig file (`current-context` from the file is used by default).\n\n- *`-k, --kubeconfig`*\n  Path to kubeconfig file to use. This takes precedence over `KUBECONFIG` environment variable, which is also supported\n  and can contain multiple paths, and default `~/.kube/config`.\n\n- *`-t, --target-version`*\n  `kubent` will try to detect K8S cluster version and display only relevant findings. This flag allows to override this\n  version for scenarios like use in CI with the file collector only, when detection from an actual cluster is not possible.\n  Expected format is `major.minor[.patch]`, e.g. `1.16` or `1.16.3`.\n\n### Docker Image\n\nWe also publish official container image, which can be found at:\n`ghcr.io/doitintl/kube-no-trouble:latest` (also available tagged with each\nindividual release version).\n\nTo run locally, you'll need to provide credentials, e.g. by sharing your\nkubectl config:\n\n```sh\n$ docker run -it --rm \\\n    -v \"${HOME}/.kube/config:/.kubeconfig\" \\\n    ghcr.io/doitintl/kube-no-trouble:latest \\\n    -k /.kubeconfig\n```\n\nYou can use `kubectl run` to run inside a K8S cluster, as a one-off. In that\ncase the credentials will be picked up via the pod's service account from the\nenvironment, but you'll want to grant relevant permissions first (see\n[docs/k8s-sa-and-role-example.yaml](docs/k8s-sa-and-role-example.yaml)):\n\n```sh\n$ kubectl run kubent --restart=Never --rm -i --tty \\\n    --image ghcr.io/doitintl/kube-no-trouble:latest \\\n    --overrides='{\"spec\": {\"serviceAccount\": \"kubent\"}}'\n```\n\n### Use in CI\n\n#### Exit codes\n\n`kubent` will by default return `0` exit code if the program succeeds, even if\nit finds deprecated resources, and non-zero exit code if there is an error\nduring runtime. Because all info output goes to stderr, it's easy to check in\nshell if any issues were found:\n\n```shell\ntest -z \"$(kubent)\"                 # if stdout output is empty, means no issues were found\n                                    # equivalent to [ -z \"$(kubent)\" ]\n```\n\nIt's actually better so split this into two steps, in order to differentiate\nbetween runtime error and found issues:\n\n```shell\nif ! OUTPUT=\"$(kubent)\"; then       # check for non-zero return code first\n  echo \"kubent failed to run!\"\nelif [ -n \"${OUTPUT}\" ]; then       # check for empty stdout\n  echo \"Deprecated resources found\"\nfi\n```\n\nYou can also use `--exit-error` (`-e`) flag, which will make kubent to exit\nwith non-zero return code (`200`) in case any issues are found.\n\nAlternatively, use the json output and smth. like `jq` to check if the result is\nempty:\n\n```\nkubent -o json | jq -e 'length == 0'\n```\n\n#### Scanning all files in directory\n\nIf you want to scan all files in a given directory, you can use the following\nshell snippet:\n\n```shell\nFILES=($(ls *.yaml)); kubent ${FILES[@]/#/-f} --helm3=false -c=false\n```\n\n## Development\n\nThe simplest way to build `kubent` is:\n\n```sh\n# Clone the repository\ngit clone https://github.com/doitintl/kube-no-trouble.git\ncd kube-no-trouble/\n# Build\ngo build -o bin/kubent ./...\n```\n\nOtherwise there's `Makefile`\n```sh\n$ make\nmake\nall                            Clean, build and pack\nhelp                           Prints list of tasks\nbuild                          Build binary\ngenerate                       Go generate\nrelease-artifacts              Create release artifacts\nclean                          Clean build artifacts\n```\n\n## Issues and Contributions\n\nPlease open any issues and/or PRs against github.com/doitintl/kube-no-trouble repository. See our [contribution guide](.github/CONTRIBUTING.md) for more details\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdoitintl%2Fkube-no-trouble","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdoitintl%2Fkube-no-trouble","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdoitintl%2Fkube-no-trouble/lists"}