I was not a big fan on container technology. Well, duty calls. So I would start with tutorials and Minikube on laptop.
Installation is simple. Instruction is here.
minikube, both is available as pre-built binary on Mac, and can be readily downloaded via
For simplicity best not to move them to
/usr/local/bin as in instruction. Just put them somewhere in user
PATH would do.
One more requirement is hypervisor. I would use VirtualBox for Mac (HyperKit need a bit work, while VMWare Fusion cost money).
After installation, one need to start Minikube for the first-time.
minikube start would do.
However, for mainland China, one had to retrieve ISO and image from AlibabaCloud mirror. Command line would be
minikube start --iso-url 'https://kubernetes.oss-cn-hangzhou.aliyuncs.com/minikube/iso/minikube-v1.2.0.iso' --image-mirror-country cn
for current Minikube version 1.2.0. There is a GitHub with modified default ISO URL. Here the ISO URL could be found as
DefaultISOURL at minikube/pkg/minikube/constants/constants.go
If there is future upgrade, remember to use latest version.
After Minikube is started, one can try with some deployment. Start a Node.js echo server (again, mainland China need to use a mirror, instead of default
kubectl create deployment hello-node --image=registry.cn-hangzhou.aliyuncs.com/google_containers/echoserver:1.10
It will create echo server deployment on the pod. The server can be accessed locally within the pod.
kubectl exec $POD_NAME -- curl localhost:8080
Next, one can expose it as service.
kubectl expose deployment hello-node --type=LoadBalancer --port=8080
kubectl get all
Sample response (note the external NODE_PORT on
NAME READY STATUS RESTARTS AGE pod/hello-node-67c8cf8784-9t2h6 1/1 Running 0 15m NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE service/hello-node LoadBalancer 10.104.130.7 <pending> 8080:30252/TCP 3m49s service/kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 5h6m NAME READY UP-TO-DATE AVAILABLE AGE deployment.apps/hello-node 1/1 1 1 16m NAME DESIRED CURRENT READY AGE replicaset.apps/hello-node-67c8cf8784 1 1 1 15m
All is fine. Now it can be accessed externally.
minikube service hello-node
Above command line is just a convenience, simple
curl $(minikube ip):$NODE_PORT
Further, deployment can be scaled-up (to 2 pods).
kubectl scale deployment.apps/hello-node --replicas=2
After having enough of our echo service, one can shut it down.
kubectl delete service hello-node
kubectl delete deployment hello-node
Further, stop Minikube (to save some CPU and memory).