Disclaimer: This post follows a simple approach, there are probably better ways to do this (please share them if you know any!), and your mileage most definitely will vary.
This post is part of a series of posts on how to Set up a Kubernetes cluster on macOS, in this case, using minikube.
Kubernetes is a complex container orchestration tool that can be overwhelming for beginners. Had you wondered how to get started on Kubernetes by yourself easily without the complexity of Turnkey Solutions (Oracle OKE, AWS EKS) and Managed Solutions (Google GKE), this post would give you the simplicity to deploy a Kubernetes cluster on macOS intended for dev/test purposes.
- Create the cluster
- Test Kubernetes
- See the Cluster IP
- Deploy a Pod
Minikube is a tool that runs a single-node Kubernetes cluster in a virtual machine on your computer, so basically, it wouldn't be for a production environment. Remember, this is for test/dev purposes.
Before starting, you need these prechecks:
Check if virtualization is supported on your system
In terminal run the following command, and verify that the output is non-empty:
sysctl -a | grep -E --color 'machdep.cpu.features|VMX'
If the output is not empty, we can proceed.
An Hypervisor, in macOS you can use hyperkit or Virtualbox.
For this post's goal, we would stay with Virtualbox to maintain simplicity and hence is cross-platform. I'm a big fan of vagrant to make this kind of environment but it would be overwhelming for the tutorial, maybe for another day 😉.
At least 20G of disk space and 4G of memory is recommended.
A system that supports virtualization.
An internet connection.
Open terminal and run the following commands.
Install Minikube with brew.
brew install minikube
Install Minikube without brew.
curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-darwin-amd64 \ && chmod +x minikube sudo mv minikube /usr/local/bin
Confirm Installation of Minikube.
- To deploy a Kubernetes cluster, just start minikube with the driver parameter set to
minikube start --driver=virtualbox
- Enable the DNS service.
minikube addons enable kube-dns
Let's test our command center
kubectl get nodes
You should see one node in status Ready
Run the following command and find the cluster IP in the endpoint property.
kubectl describe svc kubernetes
I make a definition file just for you, Time to make a simple cluster:
kubectl create -f https://raw.githubusercontent.com/reybis/tutorial-minikube/master/nginx-deployment.yml
This will create a pod of nginx and one nodePort service at 30005.
Since you know the Cluster IP, you can see your nginx pod http://cluster-ip:30005 deployed on your new local cluster! 🎉
That's it, now you have a Kubernetes cluster in your machine.