diff --git a/.github/workflows/check_deprecated.yaml b/.github/workflows/check_deprecated.yaml index 002115b..29110e8 100644 --- a/.github/workflows/check_deprecated.yaml +++ b/.github/workflows/check_deprecated.yaml @@ -10,7 +10,7 @@ jobs: name: Test runs-on: ubuntu-latest steps: - # Delete the previous comments + # Delete the previous comments created by github-action[bot] - name: pr-deleter uses: maheshrayas/action-pr-comment-delete@v1 with: @@ -20,6 +20,7 @@ jobs: user: 'github-actions[bot]' issue: '${{github.event.number}}' - uses: actions/checkout@v2 + # Install kube-depre and run it against the manifest file dir - name: Check kubedepre id: kubedepre run: | diff --git a/Cargo.lock b/Cargo.lock index 5e8d02a..913c1ae 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -910,7 +910,7 @@ dependencies = [ [[package]] name = "kube-depre" -version = "0.1.0" +version = "0.1.8" dependencies = [ "anyhow", "async-trait", diff --git a/Cargo.toml b/Cargo.toml index 7a289d5..3ab431b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "kube-depre" -version = "0.1.0" +version = "0.1.9" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/README.md b/README.md index fe5baf9..6537d0e 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,102 @@ -# Kube-depre -[![GitHub Actions Workflow](https://github.com/maheshrayas/kube-depre/actions/workflows/ci.yaml/badge.svg)](https://github.com/anzx/platform-secret-management/actions/workflows/ci.yaml) -[![codecov](https://codecov.io/gh/maheshrayas/kube-depre/branch/main/graph/badge.svg?token=VF6UCCDNXI)](https://codecov.io/gh/maheshrayas/kube-depre) \ No newline at end of file + +

+

Kube-depre

+

+ +
+ + +
+ + +## Motivation + +Given that kubernetes frequently deprecates apiVersions, we want to check for the resources with deprecated apiVersions in cluster or files or as a part of Continous Integration pipeline (Github Actions) so that we can update the apiVersion in manifest before the cluster is upgraded. + +`kube-depre` is a simple CLI tool that allows us to find such deprecated apiVersion in Kubernetes cluster, or in files and as well integrated with github actions to report the Deprecated Apis as a comment on Pull Request. + +## Installation + +Supports only Linux and Mac + +1. Download from the [Release](https://github.com/maheshrayas/kube-depre/releases) + +OR + +2. curl -L https://raw.githubusercontent.com/maheshrayas/kube-depre/main/release/install.sh | sh - + + +## How to use + +### CLI Supported Args + +```bash +kube-depre 0.1.8 + +USAGE: + kube-depre [OPTIONS] + +OPTIONS: + -d, --debug + supply --debug to print the debug information + + -f, --file + supply -f or --file "Manifest file directory". if -f not supplied, it will by default + query the cluster + + -h, --help + Print help information + + -k, --kubeconfig + + + -o, --output + -o csv. Default is table Output format table, csv [default: table] [possible values: + table, junit, csv] + + -t, --target-version + list of deprecated apis in a specific kubernetes version, -t 1.22 if -t not supplied, it + will query for versions : 1.16, 1.22, 1.25, 1.26 + + -V, --version + Print version information +``` + +### Commands + +#### Check for deprecated APIs in cluster + +```bash +# check for list for depreacted Apis in the cluster in K8s 1.22 and output will be printed on terminal +./kube-depre -t 1.22 + +or +# check for list for depreacted Apis in the cluster in K8s 1.22 and output will be in csv format +./kube-depre -t 1.22 -o csv + +# check for list for depreacted Apis in the cluster in K8s version 1.16,1.22,1.24,1.25 and output will be in csv format +./kube-depre -o csv + +``` + +#### Check for deprecated APIs in files + +```bash +# check for list for depreacted Apis in the supplied file directory in K8s 1.22 and output will be printed on terminal +./kube-depre -t 1.22 -f $(pwd)/tests/data + +or +# check for list for depreacted Apis in the supplied file directory in K8s 1.22 and output will be in csv format +./kube-depre -t 1.22 -o csv -f $(pwd)/tests/data + +# check for list for depreacted Apis in the supplied file directory in K8s version 1.16,1.22,1.24,1.25 and output will be in csv format +./kube-depre -o csv -f $(pwd)/tests/data + +``` + +#### Check for deprecated APIs as a part of Pull request in Github + +Refer github [workflow](./github/workflows/check_deprecated.yaml) on how to scan kubernetes manifests in github repo and comment on PR with list of Deprecated APIs. + +![](./docs/img/github_action.png) \ No newline at end of file diff --git a/docs/img/github_action.png b/docs/img/github_action.png new file mode 100644 index 0000000..b7ae630 Binary files /dev/null and b/docs/img/github_action.png differ diff --git a/src/main.rs b/src/main.rs index e18bd2e..ce38551 100644 --- a/src/main.rs +++ b/src/main.rs @@ -9,16 +9,21 @@ const K8_VERSIONS: [&str; 4] = ["1.16", "1.22", "1.25", "1.26"]; #[derive(Parser)] #[clap(author, version, about, long_about = None)] struct Sunset { + /// list of deprecated apis in a specific kubernetes version, -t 1.22 + /// if -t not supplied, it will query for versions : 1.16, 1.22, 1.25, 1.26 #[clap(long = "target-version", short = 't')] target_version: Option, - /// Output format table, junit, csv + /// -o csv. Default is table + /// Output format table, csv #[clap(long = "output", short = 'o', arg_enum,default_value_t = Output::Table)] output: Output, #[clap(long, short)] kubeconfig: Option, - /// Scrape the cluster for deprecated apis, + /// supply -f or --file "Manifest file directory". + /// if -f not supplied, it will by default query the cluster #[clap(long, short)] file: Option, + /// supply --debug to print the debug information #[clap(short, long, parse(from_occurrences))] debug: usize, }