Tuesday 25 June 2019

Setting Up Docker & Kubernetes - Minikube (Infrastucture).

Tuesday 25 June 2019
Setting Up Docker & Kubernetes - Minikube (Infrastucture). 

The easiest way to install Minikube on macOS is using Homebrew:

brew cask install minikube

If you are on macOS and using Homebrew package manager, you can install kubectl with Homebrew.

Run the installation command:
brew install kubernetes-cli

Test to ensure the version you installed is sufficiently up-to-date:
kubectl version

If got an error when check version, you can do this :
When Minikube is started after than kubectl is configured automatically.

Run this command:
minikube start
- Starting local Kubernetes cluster...
- Kubernetes is available at
- Kubectl is now configured to use the cluster.
- You can verify and validate the cluster and context with following commands.

Run this command:
kubectl config view

Check again using this command
kubectl version

Example Output : 
#Client Version: version.Info{Major:”1", Minor:”8", GitVersion:”v1.8.4", GitCommit:”9befc2b8928a9426501d3bf62f72849d5cbcd5a3", GitTreeState:”clean”, BuildDate:”2017–11–20T05:28:34Z”, GoVersion:”go1.8.3", Compiler:”gc”, Platform:”darwin/amd64"}

#Server Version: version.Info{Major:”1", Minor:”8", GitVersion:”v1.8.2", GitCommit:”bdaeafa71f6c7c04636251031f93464384d54963", GitTreeState:”clean”, BuildDate:”2017–10–24T19:38:10Z”, GoVersion:”go1.8.3", Compiler:”gc”, Platform:”linux/amd64"}

And then check kubernetes so you have to Run this command
kubectl config current-context

Run this command
minikube start
Starting local Kubernetes v1.7.5 cluster...
Starting VM...
SSH-ing files into VM...
Setting up certs...
Starting cluster components...
Connecting to cluster...
Setting up kubeconfig...
Kubectl is now configured to use the cluster.

$ 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)

real path=/

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

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

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

No comments:

Post a Comment

ByeBlog's Inc © 2016