Skip to content

Commit

Permalink
added flux suspended resources retrieval plugin (derailed#1584)
Browse files Browse the repository at this point in the history
* 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...
  • Loading branch information
fragolinux authored Nov 12, 2023
1 parent 7244e89 commit 9b738c6
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
23 changes: 23 additions & 0 deletions plugins/get_suspended.yml
Original file line number Diff line number Diff line change
@@ -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 changes: 13 additions & 0 deletions plugins/rm-ns.yml
Original file line number Diff line number Diff line change
@@ -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"

0 comments on commit 9b738c6

Please sign in to comment.