Skip to content

Instantly share code, notes, and snippets.

@scottrigby
Last active July 16, 2017 17:15
Show Gist options
  • Save scottrigby/0d5e79afbc00a3650f043cb7d380080d to your computer and use it in GitHub Desktop.
Save scottrigby/0d5e79afbc00a3650f043cb7d380080d to your computer and use it in GitHub Desktop.
⛔️ [DEPRECATED] Minikube + xhyve workaround
#! /bin/bash
# Minikube 0.19 has some issues with with xhyve driver after stop. Workaround.
xhyve_minikube_start() {
# Require the administrator password upfront. If the user already has a sudo
# session, sudo validate here will not prompt again, but will silently succeed.
sudo -v
if [ $? == 1 ]; then
echo 'You must enter an administrative password to use this script.'
exit 1
fi
which brew &> /dev/null
if [ $? == 1 ]; then
# homebrew is not installed. Do it.
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
fi
brew cask list minikube &> /dev/null
if [ $? == 1 ]; then
# minikube cask is not installed. Do it.
# ref: https://github.com/kubernetes/minikube#macos
brew cask install minikube
fi
brew list docker-machine-driver-xhyve &> /dev/null
if [ $? == 1 ]; then
# xhyve driver is not installed. Do it.
# ref: https://github.com/kubernetes/minikube/blob/master/DRIVERS.md#xhyve-driver
brew install docker-machine-driver-xhyve
fi
# If we remove ~/.minikube while minikube is running, we get to a dirty
# minikube state, and would be forced to `minikube delete`. So stop it first.
minikube stop
# ref: https://github.com/kubernetes/minikube/issues/307#issuecomment-295243637
# ref: https://github.com/zchee/docker-machine-driver-xhyve/issues/156#issuecomment-300051049
sudo rm -rf ~/.minikube
sudo chown root:wheel $(brew --prefix)/opt/docker-machine-driver-xhyve/bin/docker-machine-driver-xhyve
sudo chmod u+s $(brew --prefix)/opt/docker-machine-driver-xhyve/bin/docker-machine-driver-xhyve
# This also sets kuberentes cluster congtext to 'minikube'.
minikube start --vm-driver xhyve
}
xhyve_minikube_start
@scottrigby
Copy link
Author

I would have added this as a homebrew binary so you could just brew tap my repo and brew install the fix. But I hope this is just a temporary issue, so not going to bother for now (comments link to GitHub issues, so follow those to see if this problem still applies).

Personally – while the gist above should be more robust – I just added this lighter command below into my ~/.bash_profile, because I already automate installing all the deps elsewhere (if you add this, be sure to source ~/.bash_profile if using an existing term session):

xhyve_minikube_start() {
  minikube stop
  sudo rm -rf ~/.minikube
  sudo chown root:wheel $(brew --prefix)/opt/docker-machine-driver-xhyve/bin/docker-machine-driver-xhyve
  sudo chmod u+s $(brew --prefix)/opt/docker-machine-driver-xhyve/bin/docker-machine-driver-xhyve
  minikube start --vm-driver xhyve
}

@scottrigby
Copy link
Author

@sampowers
Copy link

Hey, I guess Minikube wrappers are kind of a genre now. :)

Here's mine, if it helps anyone:
https://gist.github.com/sampowers/4399646bd9375efff03611407733c0a2#file-minikube-curlbash-to-the-extreme-sh

@scottrigby
Copy link
Author

@sampowers Hey that's much more robust (a much larger scope than mine here).

Luckily the xhyve driver issue has been resolved as of the latest version of docker-machine-driver-xhyve: https://github.com/zchee/docker-machine-driver-xhyve/releases/tag/v0.3.3

Deprecating this gist 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment