From ce1a34246eb9ad84ce79a18c9113f3330378ef8a Mon Sep 17 00:00:00 2001 From: Marcus Noble Date: Thu, 8 May 2025 09:41:14 +0100 Subject: [PATCH] Updated k9s config Signed-off-by: Marcus Noble --- .gitignore | 4 + home/.dotfiles/environment | 3 + home/.k9s/aliases.yaml | 11 ++ home/.k9s/config.yaml | 43 +++++ home/.k9s/config.yml | 26 --- home/.k9s/plugins.yaml | 216 ++++++++++++++++++++++ home/.k9s/{skin.yml => skins/default.yml} | 0 7 files changed, 277 insertions(+), 26 deletions(-) create mode 100644 home/.k9s/aliases.yaml create mode 100644 home/.k9s/config.yaml delete mode 100644 home/.k9s/config.yml create mode 100644 home/.k9s/plugins.yaml rename home/.k9s/{skin.yml => skins/default.yml} (100%) diff --git a/.gitignore b/.gitignore index 346da36..228ca11 100644 --- a/.gitignore +++ b/.gitignore @@ -28,3 +28,7 @@ /home/.kube/* !/home/.kube/clusters/.gitkeep !/home/.kube/switch-config.yaml + +/home/.k9s/benchmarks +/home/.k9s/clusters +/home/.k9s/screen-dumps diff --git a/home/.dotfiles/environment b/home/.dotfiles/environment index 7b9e863..b0a8d0f 100644 --- a/home/.dotfiles/environment +++ b/home/.dotfiles/environment @@ -34,3 +34,6 @@ export DOCKER_HOST=$(docker context inspect --format='{{.Endpoints.docker.Host}} # Brew - Prevent updating all packages when installing a new one export HOMEBREW_NO_AUTO_UPDATE=1 + +# k9s +export K9S_CONFIG_DIR="$HOME/.k9s" diff --git a/home/.k9s/aliases.yaml b/home/.k9s/aliases.yaml new file mode 100644 index 0000000..2c40c91 --- /dev/null +++ b/home/.k9s/aliases.yaml @@ -0,0 +1,11 @@ +aliases: + dp: deployments + sec: v1/secrets + jo: jobs + cr: clusterroles + crb: clusterrolebindings + ro: roles + rb: rolebindings + np: networkpolicies + cl: cluster.x-k8s.io/v1beta1/clusters + app: application.giantswarm.io/v1alpha1/apps diff --git a/home/.k9s/config.yaml b/home/.k9s/config.yaml new file mode 100644 index 0000000..c2955cd --- /dev/null +++ b/home/.k9s/config.yaml @@ -0,0 +1,43 @@ +k9s: + liveViewAutoRefresh: false + screenDumpDir: ${HOME}/.k9s/screen-dumps + refreshRate: 2 + maxConnRetry: 5 + readOnly: false + noExitOnCtrlC: false + ui: + enableMouse: false + headless: false + logoless: true + crumbsless: false + reactive: true + noIcons: false + skin: default + skipLatestRevCheck: false + disablePodCounting: false + shellPod: + image: busybox:1.35.0 + namespace: default + limits: + cpu: 100m + memory: 100Mi + tty: true + imageScans: + enable: false + exclusions: + namespaces: [] + labels: {} + logger: + tail: 5000 + buffer: 50000 + sinceSeconds: 0 + fullScreen: false + textWrap: false + showTime: false + thresholds: + cpu: + critical: 90 + warn: 80 + memory: + critical: 90 + warn: 80 diff --git a/home/.k9s/config.yml b/home/.k9s/config.yml deleted file mode 100644 index f0d98c8..0000000 --- a/home/.k9s/config.yml +++ /dev/null @@ -1,26 +0,0 @@ -k9s: - refreshRate: 2 - maxConnRetry: 5 - enableMouse: false - headless: false - logoless: true - crumbsless: false - readOnly: false - noIcons: false - logger: - tail: 5000 - buffer: 50000 - sinceSeconds: 0 - fullScreenLogs: false - textWrap: false - showTime: false - currentContext: - currentCluster: - clusters: [] - thresholds: - cpu: - critical: 90 - warn: 80 - memory: - critical: 90 - warn: 80 diff --git a/home/.k9s/plugins.yaml b/home/.k9s/plugins.yaml new file mode 100644 index 0000000..d3a1ff5 --- /dev/null +++ b/home/.k9s/plugins.yaml @@ -0,0 +1,216 @@ +plugins: + sshnode: + shortCut: s + description: SSH via Teleport + dangerous: false + scopes: + - nodes + background: false + command: bash + args: + - -c + - tsh ssh root@cluster=$(echo "$CONTEXT" | rev | cut -d'-' -f1 | rev),node=$(echo "$NAME" | cut -d '.' -f 1) + + aws: + shortCut: w + description: Open AWS Console + dangerous: false + scopes: + - clusters + - awsclusters + background: false + command: bash + args: + - -c + - open "https://signin.aws.amazon.com/switchrole?account=$(kubectl --context ${CONTEXT} get awsclusterroleidentity $(kubectl --context ${CONTEXT} get awsclusters -n ${NAMESPACE} ${NAME} -o json | jq -r '.spec.identityRef.name') -o json | jq -r '.spec.roleARN | split(":")[4]')&roleName=GiantSwarmAdmin&displayName=${CONTEXT}+-+${NAME}" + + clusterapps: + shortCut: a + description: List Apps + dangerous: false + scopes: + - clusters + background: false + command: sh + args: + - -c + - "viddy -n 5s 'kubectl get apps -n $NAMESPACE | grep $NAME'" + + tree: + shortCut: t + description: Show Tree + dangerous: false + scopes: + - clusters + background: false + command: sh + args: + - -c + - "viddy -n 15s 'kubectl tree -n $NAMESPACE clusters.v1beta1.cluster.x-k8s.io $NAME'" + + values: + shortCut: v + description: Show Values + dangerous: false + scopes: + - clusters + - apps + background: false + command: sh + args: + - -c + - "kubectl get -o yaml cm ${NAME}-chart-values -n giantswarm | less" + + # kubectl-blame by knight42 + # Annotate each line in the given resource's YAML with information from the managedFields to show who last modified the field. + # Source: https://github.com/knight42/kubectl-blame + # Install via: + # krew: `kubectl krew install blame` + # go: `go install github.com/knight42/kubectl-blame@latest` + blame: + shortCut: b + confirm: false + description: "Blame" + scopes: + - all + command: sh + background: false + args: + - -c + - "kubectl-blame $RESOURCE_NAME $NAME -n $NAMESPACE --context $CONTEXT | less" + + # Suspends/Resumes a cronjob + toggleCronjob: + shortCut: Shift-S + confirm: true + scopes: + - cj + description: Toggle to suspend or resume a running cronjob + command: kubectl + background: true + args: + - patch + - cronjobs + - $NAME + - -n + - $NAMESPACE + - --context + - $CONTEXT + - -p + - '{"spec" : {"suspend" : $!COL-SUSPEND }}' + + # Flux + reconcile-git: + shortCut: Shift-R + confirm: false + description: Flux reconcile + scopes: + - gitrepositories + command: bash + background: false + args: + - -c + - >- + flux + reconcile source git + --context $CONTEXT + -n $NAMESPACE $NAME + | less -K + reconcile-hr: + shortCut: Shift-R + confirm: false + description: Flux reconcile + scopes: + - helmreleases + command: bash + background: false + args: + - -c + - >- + flux + reconcile helmrelease + --context $CONTEXT + -n $NAMESPACE $NAME + | less -K + reconcile-helm-repo: + shortCut: Shift-R + description: Flux reconcile + scopes: + - helmrepositories + command: bash + background: false + confirm: false + args: + - -c + - >- + flux + reconcile source helm + --context $CONTEXT + -n $NAMESPACE $NAME + | less -K + reconcile-oci-repo: + shortCut: Shift-R + description: Flux reconcile + scopes: + - ocirepositories + command: bash + background: false + confirm: false + args: + - -c + - >- + flux + reconcile source oci + --context $CONTEXT + -n $NAMESPACE $NAME + | less -K + reconcile-ks: + shortCut: Shift-R + confirm: false + description: Flux reconcile + scopes: + - kustomizations + command: bash + background: false + args: + - -c + - >- + flux + reconcile kustomization + --context $CONTEXT + -n $NAMESPACE $NAME + | less -K + + remove_finalizers: + shortCut: Ctrl-F + confirm: true + scopes: + - all + description: | + Removes all finalizers + command: kubectl + background: true + args: + - patch + - --context + - $CONTEXT + - --namespace + - $NAMESPACE + - $RESOURCE_NAME.$RESOURCE_GROUP + - $NAME + - -p + - '{"metadata":{"finalizers":null}}' + - --type + - merge + + watch-events: + shortCut: Shift-E + confirm: false + description: Watch Events + scopes: + - all + command: sh + background: false + args: + - -c + - "kubectl events --context $CONTEXT --namespace $NAMESPACE --for $RESOURCE_NAME.$RESOURCE_GROUP/$NAME --watch" diff --git a/home/.k9s/skin.yml b/home/.k9s/skins/default.yml similarity index 100% rename from home/.k9s/skin.yml rename to home/.k9s/skins/default.yml