From 9b738c6a307daea5743f708d5565735795387446 Mon Sep 17 00:00:00 2001 From: fragolinux Date: Sun, 12 Nov 2023 19:59:01 +0100 Subject: [PATCH] added flux suspended resources retrieval plugin (#1584) * added flux suspended resources retrieval plugin using this plugin, you can press Shift-S in "kustomizations" and "helmreleases" k9s sections to get a list of all suspended resources... a temporary patch till k9s will allow custom columns based on .spec in its views... * Create rm-ns.yml to test: create an "undeletable" namespace, with wrong finalizers: ``` apiVersion: v1 kind: Namespace metadata: name: test spec: finalizers: - foregroundDeletion ``` apply to cluster: `kubectl create -f test.yaml` go in NS view in k9s, then select the test NS and press CTRL-D to delete it... it will stay in terminating state, because of the finalizers... now press "n", and confirm, to remove the finalizers... the NS should now be gone... do NOT run on the "all+" ns, it will crash k9s... --- plugins/get_suspended.yml | 23 +++++++++++++++++++++++ plugins/rm-ns.yml | 13 +++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 plugins/get_suspended.yml create mode 100644 plugins/rm-ns.yml diff --git a/plugins/get_suspended.yml b/plugins/get_suspended.yml new file mode 100644 index 0000000000..a5270a27b9 --- /dev/null +++ b/plugins/get_suspended.yml @@ -0,0 +1,23 @@ +# credits: https://github.com/fluxcd/flux2/discussions/2494 + get-suspended-helmreleases: + shortCut: Shift-S + confirm: false + description: Suspended Helm Releases + scopes: + - helmrelease + command: sh + background: false + args: + - -c + - "kubectl get --all-namespaces helmreleases.helm.toolkit.fluxcd.io -o json | jq -r '.items[] | select(.spec.suspend==true) | [.metadata.namespace,.metadata.name,.spec.suspend] | @tsv' | less" + get-suspended-kustomizations: + shortCut: Shift-S + confirm: false + description: Suspended Kustomizations + scopes: + - kustomizations + command: sh + background: false + args: + - -c + - "kubectl get --all-namespaces kustomizations.kustomize.toolkit.fluxcd.io -o json | jq -r '.items[] | select(.spec.suspend==true) | [.metadata.name,.spec.suspend] | @tsv' | less" diff --git a/plugins/rm-ns.yml b/plugins/rm-ns.yml new file mode 100644 index 0000000000..14a2a251d8 --- /dev/null +++ b/plugins/rm-ns.yml @@ -0,0 +1,13 @@ +plugin: + # remove finalizers from a stuck namespace + rm-ns: + shortCut: n + confirm: true + description: Remove NS Finalizers + scopes: + - namespace + command: sh + background: false + args: + - -c + - "kubectl get namespace $NAME -o json | jq '.spec.finalizers=[]' | kubectl replace --raw /api/v1/namespaces/$NAME/finalize -f - > /dev/null"