Skip to content

Commit

Permalink
Adding k8s custom fluff.
Browse files Browse the repository at this point in the history
  • Loading branch information
TechDufus committed Nov 30, 2023
1 parent 989041e commit 34b948b
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions roles/bash/files/bash/k8s_functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,27 @@ function __refresh_kubecontexts() {
complete -W "$(kubectl config get-contexts -o=name)" kc
}

__refresh_kubecontexts
complete -W "$(kgnonly)" k.node.exec
function __kgnonly_complete() {
local cur=${COMP_WORDS[COMP_CWORD]}
COMPREPLY=( $(compgen -W "$(kgnonly)" -- $cur) )
}

function __kc_complete() {
local cur=${COMP_WORDS[COMP_CWORD]}
COMPREPLY=( $(compgen -W "$(kubectl config get-contexts -o=name)" -- $cur) )
}

function k.node.debug() {
if [ -z "$1" ]; then
echo -e "${WARNING}${RED} Node name not found: ${YELLOW}$1${NC}"
return
fi
echo -e "${YELLOW}===========================================${NC}"
echo -e "${ARROW}${CYAN} $1 ${YELLOW}: [${GREEN}${@:2}${YELLOW}] : ${SEA}$(TZ="America/Chicago" date)${NC}"
echo -e "${YELLOW}===========================================${NC}"
kubectl debug node/$1 -qit --image=mcr.microsoft.com/dotnet/runtime-deps:6.0 --target $1 -- chroot /host bash
}

complete -o nospace -F __kc_complete kc
omplete -o nospace -F __kgnonly_complete k.node.debug k.node.exec

0 comments on commit 34b948b

Please sign in to comment.