Last active
January 8, 2023 22:47
-
-
Save akarca/ff2a237e9bf9482c210740df41d7ff0a to your computer and use it in GitHub Desktop.
kubectl alias functions with grep for fish shell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Usage: kg deploy consumer // shows all deploy names containes consumer | |
# Usage: kg pods listener // shows all pod names containes listener | |
# Usage: kg pods listener -A // shows all pod names containes listener in all namespaces | |
function kg | |
set ARGS (count $argv) | |
if test $ARGS -gt 2 | |
kubectl get $argv[1] $argv[3..-1] | grep "NAME\|$argv[2]" | |
else if test $ARGS -gt 1 | |
kubectl get $argv[1] | grep "NAME\|$argv[2]" | |
else | |
kubectl get $argv[1] | |
end | |
end | |
# Usage: kgcm [configmap name] // converts configmap to shell environment variables | |
function kgcm | |
kubectl get cm $argv[1] -o json | jq ".data" | grep ":" | sed 's/",//g' | sed 's/": "/ /g' | sed 's/ "//g' | sed 's/"//g' | awk '{print $1"=\042"$2"\042"}' | tr '\n' ' ' | |
echo | |
end | |
function kscale | |
kubectl scale deploy/$argv[1] --replicas=$argv[2] | |
end | |
function kexec | |
kubectl exec -it pods/$argv -- /bin/bash | |
end | |
function klogs | |
kubectl logs -f pods/$argv | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment