Site icon The Perpetual Student

Installing and Configuring Kubernetes with Docker on MacOS

Docker Containers

Install Kubernetes for MacOS

Installing Kubernetes (K8S) with Docker installed on my machine caused an error:

The connection to the server was refused – did you specify the right host or port?

I tried the following:

I found that installation of K8S can be done through Docker.  Do the following to automate the installation of K8S on your machine (mine is MacOS):

The UI should look the following:

Kubernetes Section of Docker UI Configuration

Install Minikube

Do the following to use Homebrew to install Minikube:

Switch between Docker for Desktop or minikube by clicking on the Docker icon on the menu bar, hover to Kubernetes, and choose the driver.

Uninstall Minikube

The latest Docker for MacOS (Docker v18) comes with Kubernetes built-in and we don’t need to use Minikube for local development.  We can use docker-for-desktop! 🙂

Switching Context

We can switch between Docker for Desktop (DFD) and Minikube with two ways. One way is through kubectl

The alternative is using Docker for Desktop menu:

kubectl Commands

Some of the commands I use commonly on Kubernetes.

Apply yaml Configkubectl apply -f ./deployment.yaml
Export Portkubectl expose deployment tomcat-deployment –type=NodePort
Service Detailskubectl describe service/tomcat-deployment
Exit mobile version