Kubernetes environment building - MacOS

Posted by stebbi on Fri, 20 Mar 2020 20:25:15 +0100


1. Mac environment requirements

Minikube requires VT-x / AMD-v virtualization to be enabled in BIOS. To check if this is running on OSX / macOS, do the following:

sysctl -a | grep machdep.cpu.features | grep VMX

If there's output, you're great!

2. [recommended] use Tsinghua brew image source

cd "$(brew --repo)"
git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git

cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git

brew update

Relevant software installation

  • kubectl
  • docker (for Mac)
  • minikube
  • virtualbox
brew update && brew install kubectl && brew cask install docker minikube virtualbox

Verify software version information

docker --version                # Docker version 18.03.1-ce, build 9ee9f40
docker-compose --version        # docker-compose version 1.21.1, build 5a3f1a3
docker-machine --version        # docker-machine version 0.14.0, build 89b8332
minikube version                # minikube version: v0.26.1
kubectl version --client        # Client Version: version.Info{Major:"1", Minor:"10", GitVersion:"v1.10.1", GitCommit:"d4ab47518836c750f9949b9e0d387f20fb92260b", GitTreeState:"clean", BuildDate:"2018-04-13T22:28:25Z", GoVersion:"go1.9.5", Compiler:"gc", Platform:"darwin/amd64"}      


1. Start kubernetes cluster

minikube start --bootstrapper=localkube

After a while, there will be the following output

Starting local Kubernetes v1.10.0 cluster...
Starting VM...
Downloading Minikube ISO
 150.53 MB / 150.53 MB [============================================] 100.00% 0s
Getting VM IP address...
WARNING: The localkube bootstrapper is now deprecated and support for it
will be removed in a future release. Please consider switching to the kubeadm bootstrapper, which
is intended to replace the localkube bootstrapper. To disable this message, run
[minikube config set ShowBootstrapperDeprecationNotification false]
Moving files into cluster...
Downloading localkube binary
 173.54 MB / 173.54 MB [============================================] 100.00% 0s
 0 B / 65 B [----------------------------------------------------------]   0.00%
 65 B / 65 B [======================================================] 100.00% 0sSetting up certs...
Connecting to cluster...
Setting up kubeconfig...
Starting cluster components...
Kubectl is now configured to use the cluster.
Loading cached images from config file.

Congratulations! Minikube starts a virtual machine for you and runs the Kubernetes cluster in it.

2. View cluster node information

➜  ~ kubectl get nodes
minikube   Ready     <none>    15m       v1.10.0

Common problems and Solutions

1. kubectl installation failed

➜ brew install kubectl
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 2 taps (caskroom/cask, homebrew/core).
==> Updated Formulae
pandoc-citeproc                                                   php                                                               php@7.0

Error: Failed to link all completions, docs and manpages:
  Permission denied @ rb_file_s_symlink - (../../../Homebrew/completions/zsh/_brew, /usr/local/share/zsh/site-functions/_brew)
Warning: kubernetes-cli 1.10.1 is already installed, it's just not linked
You can use `brew link kubernetes-cli` to link this version.


sudo chown -R $(whoami) /usr/local/share/
brew link kubernetes-cli

Topics: brew Docker git Kubernetes