Start Kubernetes with Minikube

What is Minikube? 


Minikube is a tool to run Kubernetes(k8s) on the local machine easily. It creates a single-node k8s cluster without requiring much time and resources.

All we need to start are:


1. Installation

1. To install the latest minikube stable release on x86-64 macOS using Homebrew:

brew install minikube

If the
 installation fails via brew, you may have to remove the old minikube links and link the newly installed binary:

brew unlink minikube
brew link minikube

2. Install kubectl

minikube kubectl --get po -A


2. Run cluster

Start a cluster by running following command on the terminal.
minikube start

3. Interact with your cluster

You can now use it to access your cluster:

kubectl get po -A


4. Deploy applications

Create a sample deployment and expose it on port 8080:

kubectl create deployment hello-minikube --image=k8s.gcr.io/echoserver:1.4
kubectl expose deployment hello-minikube --type=NodePort --port=8080

Check if the service is running:
kubectl get services hello-minikube

Let minikube launch a web browser for you:

minikube service hello-minikube

or forward the port like:

kubectl port-forward service/hello-minikube 7080:8080

and check your application at http://locahost:7080

LoadBalancer 

To access a LoadBalancer deployment, deploy the service with the type LoadBalancer:
kubectl create deployment balanced --image=k8s.gcr.io/echoserver:1.4
kubectl expose deployment balanced --type=LoadBalancer --port=8080

and start the tunnel to create a routable IP for the ‘balanced’ deployment:

minikube tunnel


To find the routable IP, run this command and examine the EXTERNAL-IP column:

kubectl get services balanced

Your deployment is now available at <EXTERNAL-IP>:8080

5. Managing cluster

Pause Kubernetes without impacting deployed applications:

minikube pause

Unpause a paused instance:

minikube unpause

Halt the cluster:

minikube stop

Increase the default memory limit (requires a restart):

minikube config set memory 16384

Browse the catalog of easily installed Kubernetes services:

minikube addons list

Create a second cluster running an older Kubernetes release:

minikube start -p aged --kubernetes-version=v1.16.1

Delete all of the minikube clusters:

minikube delete -all

Comments