Updated kube alises

Signed-off-by: Marcus Noble <github@marcusnoble.co.uk>
This commit is contained in:
Marcus Noble 2021-11-26 13:22:19 +00:00
parent 5d4a7758c0
commit 48ad89385b
Signed by: AverageMarcus
GPG Key ID: B8F2DB8A7AEBAF78
2 changed files with 50 additions and 24 deletions

View File

@ -1,28 +1,11 @@
export ZSH="$HOME/.oh-my-zsh"
export ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE=20
plugins=(
aws
zsh-syntax-highlighting
zsh-autosuggestions
)
autoload -U compinit && compinit
# This speeds up pasting w/ autosuggest
# https://github.com/zsh-users/zsh-autosuggestions/issues/238
pasteinit() {
OLD_SELF_INSERT=${${(s.:.)widgets[self-insert]}[2,3]}
zle -N self-insert url-quote-magic # I wonder if you'd need `.url-quote-magic`?
}
pastefinish() {
zle -N self-insert $OLD_SELF_INSERT
}
zstyle :bracketed-paste-magic paste-init pasteinit
zstyle :bracketed-paste-magic paste-finish pastefinish
# https://github.com/zsh-users/zsh-autosuggestions/issues/351
ZSH_AUTOSUGGEST_CLEAR_WIDGETS+=(bracketed-paste accept-line)
DISABLE_UNTRACKED_FILES_DIRTY="true"
SHOW_AWS_PROMPT=false

View File

@ -1,11 +1,6 @@
alias k='kubectl '
alias kgs='kubectl-gs '
alias kshell='kubectl run -it shell --image bash --restart Never --rm -- sh'
kiam () {
kubectl run -it shell --image docker-tiocoreeng-apps-virtual.bts.artifactory.tio.systems/aws-cli:latest --env=AWS_DEFAULT_REGION=eu-west-1 --overrides="{ \"metadata\": { \"annotations\": { \"iam.amazonaws.com/role\": \"$1\" } } }" --command bash --restart Never --rm
}
kube-ssh() {
sh -c "$(curl -sSL https://raw.githubusercontent.com/AverageMarcus/kube-ssh/master/ssh.sh)"
}
@ -90,8 +85,56 @@ kl () {
}
## Display everything
kall () {
kubectl get all --all-namespaces
kall() {
NAMESPACE=""
LABEL=""
ALL_NAMESPACES=false
while test $# -gt 0; do
case "$1" in
-n|--namespace)
shift
NAMESPACE=$1
shift
;;
-l|--selector)
shift
LABEL=$1
shift
;;
-A|--all-namespaces)
ALL_NAMESPACES=true
shift
;;
-h|--help)
echo "kall - get all Kubernetes resources matching a given label selector"
echo " "
echo "kall [options]"
echo " "
echo "Options:"
echo "-h, --help show this help text"
echo "-n, --namespace the namespace to check against"
echo "-l, --selector the label selector to match on"
echo "-A, --all-namespaces search all namespaces"
return 0
;;
*)
break
;;
esac
done
if [[ "${LABEL}" == "" ]]; then
echo "Please provide a label selector to match on"
return 1
fi
NAMES="$(kubectl api-resources --namespaced --verbs list -o name | tr '\n' ,)"
if [ $ALL_NAMESPACES ]; then
kubectl get "${NAMES:0:-1}" --show-kind --ignore-not-found -l ${LABEL} -A
else
kubectl get "${NAMES:0:-1}" --show-kind --ignore-not-found -l ${LABEL} -n ${NAMESPACE}
fi
}
k-version-test() {