Kubernetes Installation with Minikube 101: Hello World

Update: December 1, 2020.
This is a quick guide to getting Kubernetes Installation with Minikube for macOS users. I will not explain what is docker or what is Kubernetes. There are tons of articles in Medium.
I didn’t have a plan to learn Kubernetes. Therefore, the DevOps team taught us Kubernetes, created their own NAMESPACE, and could continue to work with our environment.
This article is going to explain what I learned about Minikube and Kubernetes. How to use and create minikube in a local macOS machine. Thank you so much, guys.
History
The word of Kubernetes is in Greek. Meaning is the helmsman or pilot. In most sources, you can see Kubernetes written in k8s. This is because there are exactly 8 letters between the letters k and s. Kubernetes is a Container clustering tool that allows us to automatically deploy our existing containerized applications, manage and reduce their numbers with operations. The Kubernetes current version is 1.12. You can reach Github from the link below. https://github.com/kubernetes/kubernetes
Installation
- First and foremost let’s install Docker. You can reach docker store from the link below. Don't forget run docker.

- For Minikube we need to have a virtualization software on our macOS machine. I am using VirtualBox because of free.

Check our installation Success for Docker
$ docker version
You should see Docker version 18.06.1. Your version might me different but it is ok.

Installation Kubernetes
The first tool we need to install is called kubectl.
$ brew install kubernetes-cli
After the installation has finished you are ready to work with Kubernetes from you local macOS CLI.
Check our installation Success for Kubernetes
$ kubectl versionClient Version: version.Info{Major:"1", Minor:"12", GitVersion:"v1.12.0", GitCommit:"0ed33881dc4355495f623c6f22e7dd0b7632b7c0", GitTreeState:"clean", BuildDate:"2018-09-28T15:18:13Z", GoVersion:"go1.11", Compiler:"gc", Platform:"darwin/amd64"}Server Version: version.Info{Major:"1", Minor:"10", GitVersion:"v1.10.0", GitCommit:"fc32d2f3698e36b93322a3465f63a14e9f0eaead", GitTreeState:"clean", BuildDate:"2018-03-26T16:44:10Z", GoVersion:"go1.9.3", Compiler:"gc", Platform:"linux/amd64"}
Minikube
Minikube has a very similar user-experience to docker-machine
and also relies on boot2docker
. Its primary purpose is to create a single-node Kubernetes cluster which also includes a Docker host that can be used for development.
Installation Minikube
To perform the installation, you can download the latest version of Minikube by following the link. or You can copy and paste links below on the terminal.
$ curl -Lo minikube https://storage.googleapis.com/minikube/releases/v0.30.0/minikube-darwin-amd64 && chmod +x minikube && sudo cp minikube /usr/local/bin/ && rm minikube
We want to set up our first Kubernetes HelloWorld application and run the application in the Minikube. Finally expose the application via a load balancer.
$ minikube start
Starting local Kubernetes cluster…
Starting VM...
Check out installation Success for Minikube
$ minikube version && virtualbox

We can check out the nodes in the cluster and can verify Minikube and Virtualbox talk to each other.
$ kubectl get nodesNAME STATUS ROLES AGE VERSIONminikube Ready master 3h v1.10.0
We can get some information about our Minikube.
$ kubectl cluster-infoKubernetes master is running at https://192.168.99.100:8443CoreDNS is running at https://192.168.99.100:8443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
If you experience any problem please run minikube dashboard, it brings up the localhost (127.0.0.1) and shows the kubernetes dashboard successfully!
Next Step, we will run Hello World application. First, we are going to type
$ kubectl run hw —image=karthequian/helloworld — port=80
This creates a HelloWorld deployment and we can investigate into the Pod that gets created, which will run the container:
$ kubectl get podsNAME READY STATUS RESTARTS AGEhw-596b578c58-6wzwl 1/1 Running 0 3h
We can see that the pod is still being created from the ContainerCreating status insted of Running. Also, we can check current image in the output.
$ kubectl get deploymentNAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGEhw 1 1 1 1 3h
Next thing we are creating service to access deployment from outside.
$ kubectl expose deployment hw — type=NodePort
For checking our service run this command
$ kubectl get services
One more things, we need to tell Minikube to pull this up in the browser. This command will open your app automatically on your browser.
$ minikube service hw
Now we can check all details about HelloWorld deployment. First check details
$ kubectl get all

Scaling the Service
When we created the deployment, we did not mention about the number of instances for our service. We have single DESIRED replica set, Single CURRENT. Single UP-TO-DATE vs.. If some reason the pod crashes, we will not have any instance for up and running our application. We can scale our deployment. This command is changed from whatever their existing value is to 2.
$ kubectl scale --replicas=2 deployment/hwNAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGEhw 2 2 2 2 3h
Now, we have two replicas. That means, we will have two pod running.
$ kubectl get rsNAME DESIRED CURRENT READY AGEhw-596b578c58 2 2 2 4h
Troubleshooting
We can troubleshooting our Minikube with two commands. First command bring us all details about Minikube. But there is not any event information.
$ kubectl describe deployment hw
For getting event information first run pods command. You should have two pods because we have already scale 2 pods previous section.
$ kubectl get podsNAME READY STATUS RESTARTS AGEhw-596b578c58-6wzwl 1/1 Running 0 4hhw-596b578c58-mld9d 1/1 Running 0 34m
Now, let’s check specific event for each pod
$ kubectl describe po/hw-596b578c58-6wzwl
If there is a problem, check event section.
Labels
Labels are the mechanism that we use for filtering Kubernetes object.
$ kubectl get pods --show-labelsNAME READY STATUS RESTARTS AGE LABELShw-596b578c58-6wzwl 1/1 Running 0 4h pod-template-hash=1526134714,run=hwhw-596b578c58-mld9d 1/1 Running 0 46m pod-template-hash=1526134714,run=hw
You can find more details in this article.
Install the Kubernetes Dashboard
The next step we are going to install the Kubernetes Dashboard. First we need to check status
$ minikube addons list
If you see — dashboard: enabled just run this command below
$ minikube dashboard

Cleanup
if you want to delete the service and deployment for hw, and shut down the minikube cluster once finished:
$ kubectl delete service,deployment hw$ minikube stop
Stopping local Kubernetes cluster...
Machine stopped.
That’s it. 😃😃😃 Thanks for reading. I hope all these tools will help you to improve your productivity.
If you want to follow me on social media, here are some links. github, twitter, linkedin
You can check my previous articles here.