Question - How to setup local kubernetes cluster using minikube?
First of all lets describe briefly about "What is kubernetes?". Well, Kubernetes is open-source container orchestration tool which is used for deployments automation and scaling of containers on large scale environments. There are plenty of other features that it can do. Please go to the main site (https://kubernetes.io/) to explore more.In this specific post, we'll try to setup full kubernetes cluster on local machine. This should be used on Production like env, this is only for doing local testing and getting test of kubernetes on local server without investing much.
We will make use of "minikube" for this setup. Below is the "minikube" Architecture.
Env and Version Details -
- Host OS - Windows 10- Hypervisor - Vritualbox
Requirements -
1. Hypervisor -
Install some kind of hypervisor that minikube will use to create VM and spin up kubernetes cluster on one server.
So, if you don't have, then please install. Below are the options for different distros-
If you do not already have a hypervisor installed, install one now.
- For OS X, install VirtualBox or VMware Fusion, or HyperKit.
- For Linux, install VirtualBox or KVM.
- For OS X, install VirtualBox or VMware Fusion, or HyperKit.
- For Linux, install VirtualBox or KVM.
Note: Minikube has support which provides us option to define which HyperVisor we want to use. Parameter is
--vm-driver={Value}
. If you want to install this on same host instead of any VM, please use --vm-driver=none. Docker is needed for this, but you don't need a hypervisor.2. Install kubernetes controller i.e. kubectl -
"kubectl" is command line tool which is used to manage and deploy deployments on kubernetes. There are different of ways to do this based on different OS. Since we are doing this on windows, so for windows you either can use "chocolatey" package manager or simply download using curl or from browser and set that exeutable to PATH variable.
e.g.
https://storage.googleapis.com/kubernetes-release/release/stable.txt.
Check for version -
e.g.
curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.10.0/bin/windows/amd64/kubectl.exe
Check below for stable version -https://storage.googleapis.com/kubernetes-release/release/stable.txt.
Check for version -
>kubectl version --client
Client Version: version.Info{Major:"1", Minor:"8", GitVersion:"v1.8.2", GitCommit:"bdaeafa71f6c7c04636251031f93464384d54963", GitTreeState:"clean", BuildDate:"2017-10-24T19:48:57Z", GoVersion:"go1.8.3", Compiler:"gc", Platform:"windows/amd64"}
3. Install Minikube -
Download particular version from "https://github.com/kubernetes/minikube/releases" and move binary to system PATH in same as you did for kubectl.
check minikube version and start your local kubernetes cluster using virtualbox.
- Check Version :
> minikube version
minikube version: v0.23.0
- Start :
> minikube start --vm-driver virtualbox
Starting local Kubernetes v1.8.0 cluster...
Starting VM...
Getting VM IP address...
Moving files into cluster...
Setting up certs...
Connecting to cluster...
Setting up kubeconfig...
Starting cluster components...
Kubectl is now configured to use the cluster.
- Chech status :
>minikube statusminikube: Runningcluster: Runningkubectl: Correctly Configured: pointing to minikube-vm at 192.168.99.100
- Get Cluster info:
>kubectl cluster-info
Kubernetes master is running at https://192.168.99.100:8443
- Other kubectl handy commands:
>kubectl get po
NAME READY STATUS RESTARTS AGE
nginx-node-d747bd6df-prrpb 1/1 Running 1 18h
>kubectl get services
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ClusterIP 10.0.0.1 <none> 443/TCP 7d
nginx-node LoadBalancer 10.0.0.68 <pending> 80:32033/TCP 7d
>kubectl get deployment
NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
nginx-node 1 1 1 1 7d
>kubectl get all
NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
deploy/nginx-node 1 1 1 1 7d
NAME DESIRED CURRENT READY AGE
rs/nginx-node-d747bd6df 1 1 1 7d
NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
deploy/nginx-node 1 1 1 1 7d
NAME DESIRED CURRENT READY AGE
rs/nginx-node-d747bd6df 1 1 1 7d
NAME READY STATUS RESTARTS AGE
po/nginx-node-d747bd6df-prrpb 1/1 Running 1 18h
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
svc/kubernetes ClusterIP 10.0.0.1 <none> 443/TCP 7d
svc/nginx-node LoadBalancer 10.0.0.68 <pending> 80:32033/TCP 7d