Goal:
This article explains the detailed steps on how to get started with Minikube on Mac OS.This is a good starting point to learn Kubernetes.
Env:
Mac OS 10.14Minikube v0.30.0
Solutions:
1. Prerequisite
Install xcode on Mac:1 | xcode- select -- install |
1 | /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" |
2. Install Minikube
Using Homebrew we can easily install Minikube on Mac:1 | brew cask install minikube |
3. Start a single node Kubernetes cluster in VM
By default Minikube uses "virtualbox" as the VM driver, and you can also change it to others:1 2 | $ minikube start -h | grep vm-driver --vm-driver string VM driver is one of: [virtualbox vmwarefusion kvm xhyve hyperv hyperkit kvm2 none] (default "virtualbox" ) |
1 | minikube start |
4. Launch Kubernetes Web Dashboard
1 | minikube dashboard |
5. Deploy a hello world Node.js application into Minikube
1 | kubectl run hello-minikube --image=k8s.gcr.io /echoserver :1.4 --port=8080 |
Or shown in CLI:
1 2 3 | $ kubectl get deployments NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE hello-minikube 1 1 1 1 15m |
6. Expose the deployment as a service
1 | kubectl expose deployment hello-minikube -- type =NodePort |
Or display the service information in CLI:
1 2 3 | $ kubectl get services hello-minikube NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE hello-minikube NodePort xxx.xxx.xxx.xxx <none> 8080:31978 /TCP 3m |
7. Wait for the pod up and running
Keep running below command until the pod's status is running and is ready.1 2 3 | $ kubectl get pods NAME READY STATUS RESTARTS AGE hello-minikube-6c47c66d8-gv7n2 1 /1 Running 0 31m |
8. Access the service
1 | curl $(minikube service hello-minikube --url) |
Or go directly to the web URL in browser:
1 2 | $ minikube service hello-minikube --url http: //192 .168.99.100:31978 |
9. Shutdown cluster
Delete the service(Service is gone after that):1 | kubectl delete service hello-minikube |
1 | kubectl delete deployment hello-minikube |
1 | minikube stop |
Reference:
https://github.com/kubernetes/minikube
No comments:
Post a Comment