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...
mine
fragolinux 2023-11-12 19:59:01 +01:00 committed by GitHub
parent f37d472c5b
commit 91de8e1182
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 36 additions and 0 deletions

23
plugins/get_suspended.yml Normal file
View File

@ -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"

13
plugins/rm-ns.yml Normal file
View File

@ -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"