Skip to content

Instantly share code, notes, and snippets.

@omkar0001
Created October 6, 2019 22:43
Show Gist options
  • Save omkar0001/3cec97d220a0f0b12b42db2efa37f864 to your computer and use it in GitHub Desktop.
Save omkar0001/3cec97d220a0f0b12b42db2efa37f864 to your computer and use it in GitHub Desktop.
# Kubernetes usefulness.
alias kubeprod='kubectl config use-context gke_typegenie_europe-west1-d_production'
alias kubestag='kubectl config use-context gke_typegenie_europe-west1-b_staging'
eval $(kubectl completion zsh)
alias kubectx="kubectl config current-context"
# Shells into a service on the current kubernetes cluster
function kubesh {
local service=${1:?"Service name must be arg1"}
kubectl exec -it $(kubectl get po | grep $service | awk '{ print $1 }') bash
}
function kubeforward {
local service=${1:?"Service name must be arg1"}
local port=${2:?"Port musst be arg2"}
kubectl port-forward $(kubectl get po | grep $service | awk '{ print $1 }') $port
}
function kubelog {
local service=${1:?"Service name must be arg1"}
shift
if [[ $1 == -f ]]; then
FOLLOW=-f
shift
fi
kubectl logs $FOLLOW $(kubectl get po | grep $service | awk '{ print $1 }')
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment