Sakananote: Kubernetes In Docker For Mac

Sakananote: Kubernetes In Docker For Mac

Now you can deploy a local Kubernetes cluster easier than even with Docker Desktop. If you have docker version 18.06.0ce or later, it comes bundled with Kubernetes. In this post, I’ll walk you through getting your Docker Desktop Kubernetes cluster up and running.

Docker for Mac is simple to install, so you can have Docker containers running on your Mac in just a few minutes. And Docker for Mac auto-updates so you continue getting the latest Docker product revisions.

With this cluster, you can run kubectl commands, deploy helm, the, or any other facility that can run in Kubernetes. You can even setup Docker Compose to deploy pods to Kubernetes directly from a compose file by using docker stack. I’ll be using a mac to demonstrate these features. Let’s get started.

Sakananote Kubernetes In Docker For Mac

If you have not done so. Kubernetes Setup After docker is installed, pull up the preferences and click on the Kubernetes tab. Enable Kubernetes by selecting the checkbox, also select Kubernetes as the default orchestrator. We’ll be using the default orchestrator later in the post for the docker stack command. Avoid clicking on the “Show system containers” checkbox.

When you enable that, all of the Kubernetes “system” containers will show up in your docker ps commands. Only check this if you fully understand the consequences, otherwise it’s unnecessary. Hit the “apply” button and Kubernetes will download if this is the first time you’ve enable it, otherwise it will just begin to start up. You’ll see an orange indicator while Kubernetes is starting.

You’ll see a green indicator, like the docker status indicator, when the cluster is up and running. Kubectl Now that kubernetes is running, you can access your cluster with kubectl. Make sure kubectl is set to the docker-for-desktop context (this should happen automatically). Now you can access the dashboard in your web browser.

Skip the authentication and you will go directly to the dashboard home screen. Your cluster is up and the kubernetes dashboard is installed. From here, you can deploy pods and install other facilities in your cluster. Docker stack You can use docker stack and deploy docker compose files to Kubernetes. For this to work, Kubernetes must be selected as your default orchestrator in your docker preferences (this was done in a previous step).

I’ll show you a simple example of deploying nginx via a compose file to your cluster. Create a docker-compose.yaml file with the following contents.