Saturday 12 May 2018

Setup Kubernetes Cluster locally | Minikube

Kubernetes Cluster for Local Development with Minikube

Minikube Installation

Deploy Nginx WebServer In Kubernets Cluster Setup via Minikube

From Official Documentation:

"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."

# Minikube Cluster supports

  • Dashboard to manage cluster.
  • ConfigMaps to store configurations.
  • Secrets to store secrets related to your application.
  • NodePorts
  • Various Container Runtime like: Docker, rkt etc
  • Container Network Interface (CNI)
  • Ingress

# End Goal

  • Minikube installed.
  • Little hands on with Minikube commands
  • Deploy Nginx webserver in kubernetes cluster formed by minikube

# Prerequisites

  • Hypervisor installed. For Linux: VirtulBox or KVM, for OSX: VirtualBox or HyperKit.
  • Kubectl installed.

# Video Tutorial


# Installation Steps

  1.  For Linux:

    curl -Lo minikube https://storage.googleapis.com/minikube/releases/v0.26.1/minikube-linux-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/
    

  2. For OSX:

    curl -Lo minikube https://storage.googleapis.com/minikube/releases/v0.26.1/minikube-darwin-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/
    
Minikube is ready to use.

# Minikube Useful Commands

1. To start Minikube Cluster

$ minikube start
Starting local Kubernetes cluster...
Running pre-create checks...
Creating machine...
Starting local Kubernetes cluster...

2. To stop Minikube Cluster

$ minikube stop
Stopping local Kubernetes cluster...
Stopping "minikube"...

3. To check Status

$ minikube status
minikube: Running
cluster: Running
kubectl: Correctly Configured: pointing to minikube-vm at 192.168.99.100

4. To launch dashboard

$ minikube dashboard
Opening kubernetes dashboard in default browser...

# Lets try deploying Nginx Webserver on Minikube Cluster

1. Create deployment for nginx server

$ kubectl run nginx --image=nginx:latest --port=80
deployment.apps "nginx" created

2. Create service to expose the nginx web server

$ kubectl expose deployment nginx --type=NodePort
service "nginx" exposed
3. Check Pod status

$ kubectl get pods
NAME                     READY     STATUS    RESTARTS   AGE
nginx-7dc954dcb5-6qqcz   1/1       Running   0          18s

4. Get endpoint and port on which nginx service is running, so that it can be accessed.

$ minikube service nginx --url
http://192.168.99.100:32688

Open above url in browser, you will see, nginx webserver up and running.

Once you have setup minikube, you might be interested in setting up kubernetes cluster for production - How To Setup Kubernetes Cluster 

0 comments:

Post a Comment

 

Copyright @ 2013 Appychip.

Designed by Appychip & YouTube Channel