This guide allows you to run single-node Kubernetes cluster directly on your local machine, to try out Kubernetes or develop with it.
-
Unless you're using Docker for mac already, uninstall everything regarding Docker and Kubernetes you've ever installed, e.g.:
brew uninstall docker docker-compose docker-machine minikube kubectl
- Finder -> Applications -> remove Docker Toolbox
If you don't remove them and install Docker for mac, they'll be overridden anyway.
Remarks: Every container, volume, machine and image you've used will be lost.
-
Install or update "Docker for mac"
https://docs.docker.com/docker-for-mac/install/
Note: You always should keep your software up-to-date, but please ensure you've got version at least: "18.06.0-ce-mac70"
To check your version on macOS toolbar, click Docker icon and select "About Docker"
-
Once, you've installed successfully "Docker for mac" application:
Then check "Enable Kubernetes", select "Kubernetes" as default orchestrator and "Apply".
-
This will display a message that the Kubernetes cluster needs to be intially installed using internet connection.
Click install.
-
Docker deamon and Kubernetes cluster will be ready in several minutes
-
Commands in your terminal
docker
,docker-machine
,docker-compose
,kubectl
are accessible again, after Docker for mac installation, so you continue using them as usual. -
You may need to update your local application environment variables from ip addresses like
192.168.99.100
tolocalhost
orhost.docker.internal
. -
Changing context is now possible via -> Kubernetes -> Select context
Previously I've used ip address 192.168.99.100 (or similar) to access docker applications in container and on host machine (e.g. macOS terminal)
-
Use
host.docker.internal
hostname in containers -
Docker for mac exposes container ports locally, so in macOS terminal you have to use
localhost
or127.0.0.1
to connect with them, but if you want to use the same address in container and in macOS you can execute following command to bind hosthost.docker.internal
to local ip address:echo "127.0.0.1 host.docker.internal" | sudo tee -a /etc/hosts
- Go to -> Preferences -> Reset Kubernetes cluster. If Kubernetes won't restart in 5 minutes, you've to "Reset disk image", so every image, container and volume you've created will be lost.
Kubernetes Dashboard is a general purpose, web-based UI for Kubernetes clusters. It allows users to manage applications running in the cluster and troubleshoot them, as well as manage the cluster itself.
See https://github.com/kubernetes/dashboard for more details.
Guide:
-
Execute following command
$ kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/master/src/deploy/recommended/kubernetes-dashboard.yaml # secret/kubernetes-dashboard-certs created # serviceaccount/kubernetes-dashboard created # role.rbac.authorization.k8s.io/kubernetes-dashboard-minimal created # rolebinding.rbac.authorization.k8s.io/kubernetes-dashboard-minimal created # deployment.apps/kubernetes-dashboard created # service/kubernetes-dashboard created
-
Check whether deployment is already available
$ kubectl get deployments/kubernetes-dashboard -n kube-system # NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE # kubernetes-dashboard 1 1 1 1 37s
-
Proxy cluster network to your local machine
$ kubectl proxy --port=8001 --api-prefix= # Starting to serve on 127.0.0.1:8001
-
Now you can visit Kubernetes Dashboard under this url:
http://localhost:8001/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/
-
If following page will appear, click "skip" button