From fc899eec129498f6c4e8a7cfcb034f19e1206647 Mon Sep 17 00:00:00 2001 From: Digital Studium Date: Tue, 23 Apr 2024 21:16:34 +0300 Subject: [PATCH] Add exec/delete --- README.md | 4 +++- kls | 8 +++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index dbbddf5..d83b212 100644 --- a/README.md +++ b/README.md @@ -7,10 +7,12 @@ It is lightweight and easy to customize - `2` - describe resource - `3` - edit resource - `4` - logs of pod +- `5` - exec to pod +- `delete` - delete resource 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 #11). +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 diff --git a/kls b/kls index d44d70d..db19a86 100755 --- a/kls +++ b/kls @@ -5,11 +5,13 @@ KEY_BINDINGS = { # can be extended "1": 'kubectl -n {namespace} get {api_resource} {resource} -o yaml | batcat -l yaml --paging always --style numbers', "2": 'kubectl -n {namespace} describe {api_resource} {resource} | batcat -l yaml --paging always --style numbers', "3": 'kubectl -n {namespace} edit {api_resource} {resource}', - "4": 'kubectl -n {namespace} logs {resource} | batcat -l log --paging always --style numbers' + "4": 'kubectl -n {namespace} logs {resource} | batcat -l log --paging always --style numbers', + "5": 'kubectl -n {namespace} exec -it {resource} sh', + "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', + "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', @@ -85,7 +87,7 @@ def update_menu3(): def run_command(key): - if not (key == "4" and api_resource() != "pods"): + if not (key == "4" and api_resource() != "pods") and not (key == "5" and api_resource() != "pods"): curses.def_prog_mode() # save the previous terminal state curses.endwin() # without this, there are problems after exiting vim command = KEY_BINDINGS[key].format(namespace=namespace(), api_resource=api_resource(), resource=resource())