From ca248728a054482452e89672c29a45443a402d0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Montes?= Date: Sun, 25 Dec 2022 17:04:16 +0100 Subject: [PATCH] Support for custom plugins --- kubernetes.sh | 31 +++++++++++++++++++++---------- plugins/cert-manager.yaml | 36 ++++++++++++++++++++++++++++++++++++ plugins/flux.yaml | 12 ++++++++++++ 3 files changed, 69 insertions(+), 10 deletions(-) create mode 100644 plugins/cert-manager.yaml create mode 100644 plugins/flux.yaml diff --git a/kubernetes.sh b/kubernetes.sh index 022e1f7..aaa69d9 100755 --- a/kubernetes.sh +++ b/kubernetes.sh @@ -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 \ No newline at end of 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 \ No newline at end of file diff --git a/plugins/cert-manager.yaml b/plugins/cert-manager.yaml new file mode 100644 index 0000000..e0c2897 --- /dev/null +++ b/plugins/cert-manager.yaml @@ -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" diff --git a/plugins/flux.yaml b/plugins/flux.yaml new file mode 100644 index 0000000..69285d5 --- /dev/null +++ b/plugins/flux.yaml @@ -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"