Fix readme
This commit is contained in:
parent
76c40e1d91
commit
33a2086f41
|
@ -1,7 +1,9 @@
|
||||||
# KLS
|
# KLS
|
||||||
|
|
||||||
## Description
|
## Description
|
||||||
`kls` is a cli tool for managing kubernetes cluster resources. Inspired by `lf` and `ranger` file managers.
|
`kls` is a cli tool for managing kubernetes cluster resources. Inspired by `lf` and `ranger` file managers.
|
||||||
It is lightweight and easy to customize
|
It is lightweight and easy to customize
|
||||||
|
|
||||||
## Key bindings for kubectl
|
## Key bindings for kubectl
|
||||||
- `1` - get yaml of resource
|
- `1` - get yaml of resource
|
||||||
- `2` - describe resource
|
- `2` - describe resource
|
||||||
|
@ -12,13 +14,13 @@ It is lightweight and easy to customize
|
||||||
|
|
||||||
You can customize these bindings or add extra bindings in `KEY_BINDINGS` variable of `kls` (in a row #4).
|
You can customize these bindings or add extra bindings in `KEY_BINDINGS` variable of `kls` (in a row #4).
|
||||||
|
|
||||||
Also you can add additional columns for different api resources in `EXTRA_COLUMNS` variable (in a row #13).
|
|
||||||
|
|
||||||
![kls in action](./images/kls.gif)
|
![kls in action](./images/kls.gif)
|
||||||
|
|
||||||
## Dependencies
|
## Dependencies
|
||||||
- `python3`
|
- `python3`
|
||||||
- `kubectl`
|
- `kubectl`
|
||||||
- `batcat`
|
- `batcat`
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
Download latest `kls`:
|
Download latest `kls`:
|
||||||
```
|
```
|
||||||
|
|
12
kls
12
kls
|
@ -10,15 +10,6 @@ KEY_BINDINGS = { # can be extended
|
||||||
"KEY_DC": 'kubectl -n {namespace} delete {api_resource} {resource}' # delete key
|
"KEY_DC": 'kubectl -n {namespace} delete {api_resource} {resource}' # delete key
|
||||||
}
|
}
|
||||||
|
|
||||||
EXTRA_COLUMNS = { # By default, only the NAME column is displayed. Any api resource can be added here
|
|
||||||
"pods": ',STATUS:.status.phase,NODE:.spec.nodeName,AGE:.metadata.creationTimestamp',
|
|
||||||
"nodes": ',STATUS:.status.conditions[-1].type,CAPACITY_CPU:.status.capacity.cpu,CAPACITY_MEM:.status.capacity.memory',
|
|
||||||
"services": ',TYPE:.spec.type,CLUSTER_IP:.spec.clusterIP',
|
|
||||||
"ingresses": ',HOSTS:.spec.rules[*].host',
|
|
||||||
"deployments": ',DESIRED_REPLICAS:.spec.replicas,READY_REPLICAS:.status.readyReplicas',
|
|
||||||
"persistentvolumeclaims": ',SIZE:.spec.resources.requests.storage,STORAGE_CLASS:.spec.storageClassName'
|
|
||||||
}
|
|
||||||
|
|
||||||
TOP_API_RESOURCES = ["pods", "services", "ingresses", "secrets", "nodes", "deployments", "statefulsets", "daemonsets",
|
TOP_API_RESOURCES = ["pods", "services", "ingresses", "secrets", "nodes", "deployments", "statefulsets", "daemonsets",
|
||||||
"configmaps", "persistentvolumeclaims", "storageclasses"] # which api resources are on the top of menu?
|
"configmaps", "persistentvolumeclaims", "storageclasses"] # which api resources are on the top of menu?
|
||||||
|
|
||||||
|
@ -63,8 +54,7 @@ def draw_menu(menu: Menu):
|
||||||
def update_menu3():
|
def update_menu3():
|
||||||
MENUS[2].rows = []
|
MENUS[2].rows = []
|
||||||
if namespace() and api_resource():
|
if namespace() and api_resource():
|
||||||
columns = EXTRA_COLUMNS.get(api_resource(), "")
|
command = f"-n {namespace()} get {api_resource()} --no-headers"
|
||||||
command = f"-n {namespace()} get {api_resource()} --no-headers -o custom-columns=NAME:.metadata.name{columns}"
|
|
||||||
MENUS[2].rows = kubectl(command)
|
MENUS[2].rows = kubectl(command)
|
||||||
MENUS[2].filtered_row_index = 0 # reset the selected row index before redrawing
|
MENUS[2].filtered_row_index = 0 # reset the selected row index before redrawing
|
||||||
draw_menu(MENUS[2])
|
draw_menu(MENUS[2])
|
||||||
|
|
Loading…
Reference in New Issue