Created
August 2, 2018 12:17
-
-
Save EamonKeane/cd51b8c2653a994720c8a4965897e27f to your computer and use it in GitHub Desktop.
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
VM_USERNAME=azureuser | |
NODE_NAME=aks-nodepool1-47278868-0 | |
CONTAINER_LIFETIME=600 | |
INTERNAL_IP=$(kubectl get nodes --selector=kubernetes.io/hostname=$NODE_NAME -o json | jq .items[0].status.addresses[0].address --raw-output) | |
DEPLOYMENT_NAME=aksssh | |
LABELS="app=aksssh" | |
kubectl run $POD_NAME --image=debian --labels=$LABELS --command sleep $CONTAINER_LIFETIME | |
sleep 60 | |
POD_NAME=$(kubectl get po --selector=$LABELS -o json | jq .items[0].metadata.name --raw-output) | |
kubectl exec $POD_NAME -- apt-get update | |
kubectl exec $POD_NAME -- apt-get install openssh-client -y | |
kubectl cp ~/.ssh/id_rsa $POD_NAME:/id_rsa | |
kubectl exec $POD_NAME -- chmod 0600 id_rsa | |
kubectl exec -it $POD_NAME -- ssh -i id_rsa $VM_USERNAME@$INTERNAL_IP | |
# Say yes to accept commands | |
# Run commands on VM node | |
# Exit | |
# Delete the deployment | |
kubectl delete deploy --selector=$LABELS |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment