Fix README.md

This commit is contained in:
Digital Studium 2024-04-20 15:25:53 +03:00
parent 12696c7063
commit 7a8c1cc59a
2 changed files with 17 additions and 16 deletions

View File

@ -1,11 +1,12 @@
# KLS
## Description
`kls` is a cli tool for managing kubernetes cluster resources. Inspired by `lf` and `ranger` file managers. Written on python curses.
## Hotkeys
## Key bindings
- `1` - get yaml of resource
- `2` - describe resource
- `3` - edit resource
- `4` - logs of pod
- `Esc` - exit filter mode or exit `kls`
![kls in action](./images/kls.gif)
## Dependencies

30
kls
View File

@ -38,21 +38,6 @@ api_resource = MENUS[1].selected_row
resource = lambda: MENUS[2].selected_row().split()[0]
def update_menu3():
if namespace() and api_resource():
columns_dict = {"pods": 'NAME:.metadata.name,STATUS:.status.phase,NODE:.spec.nodeName',
"services": 'NAME:.metadata.name,TYPE:.spec.type,CLUSTER_IP:.spec.clusterIP',
"ingresses": 'NAME:.metadata.name,HOSTS:.spec.rules[*].host',
"persistentvolumeclaims": 'NAME:.metadata.name,SIZE:.spec.resources.requests.storage,STORAGE_CLASS:.spec.storageClassName'}
columns = columns_dict.get(api_resource(), 'NAME:.metadata.name')
MENUS[2].rows = kubectl(f"-n {namespace()} get {api_resource()} --no-headers -o custom-columns={columns}")
MENUS[2].rows = [x for x in MENUS[2].rows if x] # это нужно для удаления пустых значений из листа
else:
MENUS[2].rows = []
MENUS[2].filtered_row_index = 0 # перед перерисовкой сбрасываем выбранную строку на 0
draw_menu(MENUS[2])
def draw_row(window, text, y, x, selected=False):
window.addstr(y, x, text, curses.A_REVERSE | curses.A_BOLD if selected else curses.A_NORMAL)
window.clrtoeol()
@ -71,6 +56,21 @@ def draw_menu(menu):
draw_row(menu.win, f"/{menu.filter}" if menu.filter else "", curses.LINES - 5, 2) # рисуем строку поиска
def update_menu3():
if namespace() and api_resource():
columns_dict = {"pods": 'NAME:.metadata.name,STATUS:.status.phase,NODE:.spec.nodeName',
"services": 'NAME:.metadata.name,TYPE:.spec.type,CLUSTER_IP:.spec.clusterIP',
"ingresses": 'NAME:.metadata.name,HOSTS:.spec.rules[*].host',
"persistentvolumeclaims": 'NAME:.metadata.name,SIZE:.spec.resources.requests.storage,STORAGE_CLASS:.spec.storageClassName'}
columns = columns_dict.get(api_resource(), 'NAME:.metadata.name')
MENUS[2].rows = kubectl(f"-n {namespace()} get {api_resource()} --no-headers -o custom-columns={columns}")
MENUS[2].rows = [x for x in MENUS[2].rows if x] # это нужно для удаления пустых значений из листа
else:
MENUS[2].rows = []
MENUS[2].filtered_row_index = 0 # перед перерисовкой сбрасываем выбранную строку на 0
draw_menu(MENUS[2])
def run_command(key):
if key == "4" and api_resource() != "pods":
return