kubernetes cli is a command line client required to interact with a kubernetes cluster. You can download, install it using:
brew install kubectl
MiniKube can create a single-node Kubernetes cluster locally using a virtual machine created with VirtualBox.
This is useful for developing and testing locally with Kubernetes.
brew cask install minikube
To set up a kubernetes cluster locally, Minikube will need a hypervisor (virtual machine). There are many options for each platform.
The easiest to setup and get working. Run the following command to download and install VirtualBox.
brew cask install virtualbox
Virtualbox is default driver for Minikube. So to start a kubernetes cluster, just run:
minikube start
Above command will automatically download virtual machine images and create a virtual machine.
If you do not need VirtualBox for other purposes, installing it for kubernetes localhost development could be overkill.
There is a minimalistic alternative. You can install it using:
brew install xhyve docker-machine-driver-xhyve
With, xhyve, you need to start minikube differently:
minikube start --vm-driver=xhyve
MacOS has native hypervisor support. Unfortunately, its a bit tricky to get working. At the time of writing, we couldn’t get DNS issues resolved.
Assuming you have Go language installed correctly, you need to run following to build docker-machine driver plugin for hyperkit. It’s required later by Minikube but pre-compiled binaries were not found.
Following commands may take from few minutes to even an hour depending on your machine power and Internet speed.
git clone https://github.com/kubernetes/minikube $GOPATH/src/k8s.io/minikube
cd $GOPATH/src/k8s.io/minikube
make out/docker-machine-driver-hyperkit
cp out/docker-machine-driver-hyperkit $GOPATH/bin/docker-machine-driver-hyperkit
sudo chown root:wheel $GOPATH/bin/docker-machine-driver-hyperkit
sudo chmod u+s $GOPATH/bin/docker-machine-driver-hyperkit
With, hyperkit, you need to start minikube differently:
minikube start --vm-driver=hyperkit
No matter how you start minikube, as in using a driver, you can run minikube dashboard
command to open kubernetes dashboard web interface.
It’s advisable to open kubernetes dashboard at this point to verify you have followed along correctly.
Helm is package manager for kubernetes. In kubernetes, application of different types can be packed and distributed using helm. One example is WordPress.
To install helm, run following:
brew install kubernetes-helm
Helm has two parts: a client (helm
) and a server (tiller
).
The server will start in current kubernetes cluster. You can verify if current kubernetes context is minikube by running kubectl config current-context
Next, you can start helm by running command
helm init
We will install official WordPress chart using following command:
helm install --set serviceType=NodePort --name wp-k8s stable/wordpress
Above will setup a fresh WordPress site up and running.
To find out URL of WordPress site, run following three commands as it is.
export NODE_PORT=$(kubectl get --namespace wordpress -o jsonpath="{.spec.ports[0].nodePort}" services wp-k8s-wordpress)
export NODE_IP=$(kubectl get nodes --namespace wordpress -o jsonpath="{.items[0].status.addresses[0].address}")
echo http://$NODE_IP:$NODE_PORT/admin
The default WordPress admin username is user
.
For password, please run following command:
echo Password: $(kubectl get secret --namespace wordpress wp-k8s-wordpress -o jsonpath="{.data.wordpress-password}" | base64 --decode)
Tets if you can log into the WordPress site and use it by publishing some posts and uploading some media.
Run helm help
to see all commands. Below are one which you need frequently.
helm list
helm delete my-release-name
Following is copied with some changes from https://docs.helm.sh/using_helm/#three-big-concepts