Quick setup a local Kubernetes cluster with Minikube
To develop microservices with Kubernetes, it usually needed a local environment for development. Here’s how to quickly set up a local cluster with Minikube on MacOS.
Prerequisites
Run the command to install kubectl (Kubernetes cluster manager)
brew install kubernetes-cli
Test to ensure the version you installed is up-to-date
kubectl version
Install Virtualbox using Homebrew, or download the dmg from https://www.virtualbox.org/wiki/Downloads
brew cask install virtualbox
The easiest way to install Minikube on macOS is by using Homebrew
brew cask install minikube
Then test to ensure the version you installed is up-to-date
minikube version
Setup local cluster
Start Minikube and create a cluster
minikube start
After installing the cluster, set docker-env to let Minikube cluster access your local images
eval $(minikube docker-env)
Setup local cluster by Docker(new)
Install Docker desktop and go to Preferences > Kubernetes > Enable Kubernetes, Done!
Useful tools for Kubernetes
- Kubectl Plugin(oh-my-zsh)
This plugin adds completion for the Kubernetes cluster manager, as well as some aliases for common kubectl commands. (https://github.com/robbyrussell/oh-my-zsh/blob/master/plugins/kubectl/kubectl.plugin.zsh)
- K9s
This CLI provides a terminal UI to interact with your Kubernetes clusters.
(https://github.com/derailed/k9s)
- kubectx + kubens
This project helps you switching faster between clusters and namespaces. (https://github.com/ahmetb/kubectx)
- Helm
Helm is a tool for managing Kubernetes charts. Charts are packages of pre-configured Kubernetes resources. (https://github.com/helm/helm)
- Skaffold
Skaffold is an open-source project built by Google which is a command-line tool that facilitates continuous development for Kubernetes applications. (https://skaffold.dev/)