close

minikube is a good tool for running kubernetes on your local machine. 

Minikube is a tool that makes it easy to run Kubernetes locally. Minikube runs a single-node Kubernetes cluster inside a VM on your laptop for users looking to try out Kubernetes or develop with it day-to-day.

github link: https://github.com/kubernetes/minikube

1. install minikube on the Mac using brew 

brew cask install minikube

2. install asdf

brew install asdf

3. install minikube plugin

sudo asdf plugin-add minikube

4. start up the minikube

minikube start

5. create an echoserver pod by below commands

$ kubectl run hello-minikube --image=k8s.gcr.io/echoserver:1.4 --port=8080
deployment "hello-minikube" created
$ kubectl expose deployment hello-minikube --type=NodePort
service "hello-minikube" exposed

# We have now launched an echoserver pod but we have to wait until the pod is up before curling/accessing it
# via the exposed service.
# To check whether the pod is up and running we can use the following:
$ kubectl get pod
NAME                              READY     STATUS              RESTARTS   AGE
hello-minikube-3383150820-vctvh   1/1       ContainerCreating   0          3s
# We can see that the pod is still being created from the ContainerCreating status
$ kubectl get pod
NAME                              READY     STATUS    RESTARTS   AGE
hello-minikube-3383150820-vctvh   1/1       Running   0          13s
# We can see that the pod is now Running and we will now be able to curl it:
$ curl $(minikube service hello-minikube --url)
CLIENT VALUES:
client_address=192.168.99.1
command=GET
real path=/
...

6. open kubernetes dashboard in the browser

minikube dashboard

7. delete the pod

$ kubectl delete service hello-minikube
service "hello-minikube" deleted
$ kubectl delete deployment hello-minikube
deployment "hello-minikube" deleted

8. stop the minikube

$ minikube stop
Stopping local Kubernetes cluster...
Machine stopped.
arrow
arrow

    webbhlin 發表在 痞客邦 留言(0) 人氣()