Minikube broken ssh terminal saver

Get rid of broken minikube ssh terminal.

Dependency: jq.

Add this to .rc file:

ssh_minikube() {
    local ID=${1:-""}
    if [[ ! $ID = "" ]]; then
        ID="-m$ID"
    fi
    local PROFILE=${2:-"minikube"}
    local DIR="$HOME/.minikube/machines/${PROFILE}${ID}"
    local IP=$(jq -r ".Driver.IPAddress" "$DIR/config.json")
    ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i "$DIR/id_rsa" docker@$IP
}

Usage:

  • ssh_minikube: ssh to minikube (primary control plane now)
  • ssh_minikube 02: ssh to minikube-m02 (multi node)