diff --git a/bin/kubectl-env b/bin/kubectl-env new file mode 100755 index 0000000..b250a48 --- /dev/null +++ b/bin/kubectl-env @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +case "$1" in +mycloud) + shift + command kubectl --kubeconfig=<(pass show mycloud/kubeconfig) "${@}" + ;; +*) + command kubectl "${@}" + ;; +esac diff --git a/zsh/zshrc.d/40_functions.sh b/zsh/zshrc.d/40_functions.sh index 5bfb86c..6e369e2 100644 --- a/zsh/zshrc.d/40_functions.sh +++ b/zsh/zshrc.d/40_functions.sh @@ -208,9 +208,9 @@ tmp() { } kubectl_pod() { - kubectl get -n "${1}" pods --field-selector=status.phase=Running --selector=${2} -o jsonpath='{.items[*].metadata.name}' + kubectl-env mycloud get -n "${1}" pods --field-selector=status.phase=Running --selector=${2} -o jsonpath='{.items[*].metadata.name}' } kubectl_deployment() { - kubectl get -n "${1}" deployment --selector=${2} -o jsonpath='{.items[*].metadata.name}' + kubectl-env mycloud get -n "${1}" deployment --selector=${2} -o jsonpath='{.items[*].metadata.name}' }