Created
June 21, 2018 08:12
-
-
Save Ethcelon/55c2cf3f0746c84bfd0c88a855f8c584 to your computer and use it in GitHub Desktop.
k8s shortcuts
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
def klo(){ | |
kubectl logs -f $1 | |
} | |
def kli(){ | |
kubectl logs -f $1 -c git-init | |
} | |
def kpv(){ | |
kubectl get pv --all-namespaces $@ | |
} | |
def kpvc(){ | |
kubectl get pvc --all-namespaces $@ | |
} | |
def kconn(){ | |
kubectl exec -it $1 sh | |
} | |
def fwdtls(){ | |
kubectl port-forward $1 8443:8443 | |
} | |
def fwd(){ | |
kubectl port-forward $1 8080:8080 | |
} | |
# Use with caution | |
copy_secrets() { | |
if [ $# -lt 1 ] | |
then | |
echo "Usage: copy_secrets <from_namespace> <to_namespace> <secToCopy1> <secToCopy2> ." | |
fi | |
for sec in ${@:3} | |
do | |
echo "$sec" | |
kubectl get secret $sec --namespace $1 -o json | jq --arg v "$2" '.metadata.namespace = $v' | kubectl create -f - | |
done | |
} | |
def knpl(){ | |
kubectl describe netpol | |
} | |
function docker-ips() { | |
docker ps | while read line; do | |
if `echo $line | grep -q 'CONTAINER ID'`; then | |
echo -e "IP ADDRESS\t$line" | |
else | |
CID=$(echo $line | awk '{print $1}'); | |
IP=$(docker inspect -f "{{ range .NetworkSettings.Networks }}{{ .IPAddress }}{{ end }}" $CID); | |
printf "${IP}\t${line}\n" | |
fi | |
done; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment