Fix readme

This commit is contained in:
Digital Studium 2024-04-24 06:56:29 +03:00
parent 76c40e1d91
commit 33a2086f41
2 changed files with 5 additions and 13 deletions

View File

@ -1,7 +1,9 @@
# KLS
## Description
`kls` is a cli tool for managing kubernetes cluster resources. Inspired by `lf` and `ranger` file managers.
It is lightweight and easy to customize
## Key bindings for kubectl
- `1` - get yaml of 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).
Also you can add additional columns for different api resources in `EXTRA_COLUMNS` variable (in a row #13).
![kls in action](./images/kls.gif)
## Dependencies
- `python3`
- `kubectl`
- `batcat`
## Installation
Download latest `kls`:
```

12
kls
View File

@ -10,15 +10,6 @@ KEY_BINDINGS = { # can be extended
"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",
"configmaps", "persistentvolumeclaims", "storageclasses"] # which api resources are on the top of menu?
@ -63,8 +54,7 @@ def draw_menu(menu: Menu):
def update_menu3():
MENUS[2].rows = []
if namespace() and api_resource():
columns = EXTRA_COLUMNS.get(api_resource(), "")
command = f"-n {namespace()} get {api_resource()} --no-headers -o custom-columns=NAME:.metadata.name{columns}"
command = f"-n {namespace()} get {api_resource()} --no-headers"
MENUS[2].rows = kubectl(command)
MENUS[2].filtered_row_index = 0 # reset the selected row index before redrawing
draw_menu(MENUS[2])