Skip to content

Commit

Permalink
Readme (#20)
Browse files Browse the repository at this point in the history
* First draft

* Readme
  • Loading branch information
maheshrayas authored Apr 27, 2022
1 parent 5830ec3 commit cb62aa4
Show file tree
Hide file tree
Showing 6 changed files with 112 additions and 8 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/check_deprecated.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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: |
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
104 changes: 101 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -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)

<h1 align="center">
<p align="center">Kube-depre</p>
</h1>

<div align="center">
<a href="hhttps://github.com/anzx/platform-secret-management/actions/workflows/ci.yaml" alt="Build"><img src="https://github.com/maheshrayas/kube-depre/actions/workflows/ci.yaml/badge.svg" /></a>
<a href="https://codecov.io/gh/maheshrayas/kube-depre" alt="Lint"><img src="https://codecov.io/gh/maheshrayas/kube-depre/branch/main/graph/badge.svg?token=VF6UCCDNXI" /></a>
</div>


## 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 <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 <KUBECONFIG>


-o, --output <OUTPUT>
-o csv. Default is table Output format table, csv [default: table] [possible values:
table, junit, csv]

-t, --target-version <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)
Binary file added docs/img/github_action.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 7 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>,
/// 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<String>,
/// 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<String>,
/// supply --debug to print the debug information
#[clap(short, long, parse(from_occurrences))]
debug: usize,
}
Expand Down

0 comments on commit cb62aa4

Please sign in to comment.