Set up a Kubernetes cluster using Minikube on macOS

reybis

Reybis Ceballos

Posted on August 17, 2020

Set up a Kubernetes cluster using Minikube on macOS

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.

Table of Contents

  1. Minikube
  2. Prerequisites
  3. Installation
  4. Create the cluster
  5. Test Kubernetes
  6. See the Cluster IP
  7. Deploy a Pod

πŸ’  Minikube

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.

β˜‘οΈ Prerequisites

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.

βš™οΈ Installation

Open terminal and run the following commands.

  1. 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
    
  2. Confirm Installation of Minikube.

    minikube status
    

πŸ§‘β€πŸš€ Create the cluster

  1. To deploy a Kubernetes cluster, just start minikube with the driver parameter set to virtualbox.
  minikube start --driver=virtualbox
  1. Enable the DNS service.
  minikube addons enable kube-dns

βœ… Test Kubernetes

Let's test our command center

  kubectl get nodes

You should see one node in status Ready

πŸ—ΊοΈ See the Cluster IP

Run the following command and find the cluster IP in the endpoint property.

  kubectl describe svc kubernetes

πŸš€ Deploy a Pod

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.

πŸ’– πŸ’ͺ πŸ™… 🚩
reybis
Reybis Ceballos

Posted on August 17, 2020

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related