Skip to content

Commit

Permalink
Support for custom plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
mmontes11 committed Dec 25, 2022
1 parent f7893c8 commit ca24872
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 10 deletions.
31 changes: 21 additions & 10 deletions kubernetes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -128,17 +128,28 @@ K9S_THEME=${K9S_THEME:-nord}
K9S_THEME_URL=https://raw.githubusercontent.com/derailed/k9s/$K9S_VERSION/skins/$K9S_THEME.yml
curl -Lo $USER_HOME/.config/k9s/skin.yml $K9S_THEME_URL

K9S_PLUGINS=(
flux
watch_events
)
K9S_PLUGIN_FILE=plugin.yml
mkdir -p $USER_HOME/.config/k9s
K9S_PLUGIN_CONFIG=$USER_HOME/.config/k9s/plugin.yml
for i in "${!K9S_PLUGINS[@]}"; do
K9S_PLUGIN="${K9S_PLUGINS[$i]}"
K9S_PLUGIN_URL=https://raw.githubusercontent.com/derailed/k9s/master/plugins/$K9S_PLUGIN.yml

function install_k9s_plugin() {
K9S_PLUGIN_URL="$1"
K9S_PLUGIN_CONFIG="$2"
K9S_PLUGIN_FILE=plugin.yml

curl -Lo $K9S_PLUGIN_FILE $K9S_PLUGIN_URL
cat $K9S_PLUGIN_FILE >> $K9S_PLUGIN_CONFIG
done
rm $K9S_PLUGIN_FILE
rm $K9S_PLUGIN_FILE
}
K9S_PLUGINS=(
# oficial
"https://raw.githubusercontent.com/derailed/k9s/master/plugins/flux.yml"
"https://raw.githubusercontent.com/derailed/k9s/master/plugins/watch_events.yml"
# custom
"https://raw.githubusercontent.com/mmontes11/k8s-scripts/main/plugins/flux.yaml"
"https://raw.githubusercontent.com/mmontes11/k8s-scripts/main/plugins/cert-manager.yaml"
)

for i in "${!K9S_PLUGINS[@]}"; do
K9S_PLUGIN_URL="${K9S_PLUGINS[$i]}"
install_k9s_plugin "$K9S_PLUGIN_URL" "$K9S_PLUGIN_CONFIG"
done
36 changes: 36 additions & 0 deletions plugins/cert-manager.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
plugin:
secret-inspect:
shortCut: Shift-I
confirm: false
description: Inspect secret
scopes:
- secrets
command: bash
background: false
args:
- -c
- "cmctl inspect secret --context $CONTEXT -n $NAMESPACE $NAME |& less"

cert-status:
shortCut: Shift-S
confirm: false
description: Certificate status
scopes:
- certificates
command: bash
background: false
args:
- -c
- "cmctl status certificate --context $CONTEXT -n $NAMESPACE $NAME |& less"

cert-renew:
shortCut: Shift-R
confirm: false
description: Certificate renew
scopes:
- certificates
command: bash
background: false
args:
- -c
- "cmctl renew --context $CONTEXT -n $NAMESPACE $NAME |& less"
12 changes: 12 additions & 0 deletions plugins/flux.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
plugin:
reconcile-helmrepo:
shortCut: Shift-R
confirm: false
description: Flux reconcile
scopes:
- helmrepositories
command: bash
background: false
args:
- -c
- "flux --context $CONTEXT reconcile source helm -n $NAMESPACE $NAME |& less"

0 comments on commit ca24872

Please sign in to comment.