Part 4 – Deploy Your Own Kubernetes Cluster!
Previously, we have discussed the basics and the benefits of a Kubernetes cluster. Now, let’s build one for ourselves! The simplest Kubernetes cluster to get your hands onto would be Minikube – a “single node cluster” for learning and experimenting purposes. I am using a MacBook Pro so the commands shown in this post would be specifically demonstrating for OSX. However, you may find the full installation guide here, which covers all operating systems.
On OSX, installing Minikube and its essential tools is extremely simple:
- brew install kubectl
$ brew cask install minikube
With two lines of command shown above, you are all set! As soon as the installation is complete, we can quickly check it out by using commands:
$ minikube start $ kubectl cluster-info $ kubectl get nodes -o wide
To stop Minikube, simply do:
$ minikube stop
**We won’t go into details on “how to use Kubernetes” in this series, but you may look into my Minikube Intro Workshop if interested.
Although Minikube is quick and easy, it doesn’t represent a good production/testing environment, which often requires multiple nodes for distributed microservices. In order to build a Kubernetes cluster for non-experimenting purposes, it is recommended to deploy the cluster with kubeadmn. However, the process could be slightly daunting. inwinSTACK’s kube-ansible, on the other hand, is a tool that will make your life a lot easier.
kube-ansible includes two main features, both deploying a Kubernetes cluster. The first feature is its Quick Start VM cluster deployment. In order to this feature, you will need to install a few software beforehand, including:
- Ansible version: v2.4+
- Vagrant: >= 1.7+
- VirtualBox: >= 5.0+
- OSX needs to install sshpass tool
In Quick Start, users would only need to input VM size parameters, and the ansible playbook does all the work. You may specify the number of Masters and Nodes for your cluster, the specs (CPU, RAM, OS) for the VMs, and the CNI plugin of your choice. By default, it deploys a 1 Master 2 Node cluster.
You might want to configure some YAML files before running kube-ansible, though. In the file group_vars/all.yml, you’ll find a section labeled “Extra addons”, listing dashboard, logging (ELK), and monitoring (Heapster). By default, these are set to false. Change the corresponding item to true if you’d like to utilize its feature.
Another thing you might want to check, if you’re using Kubernetes 1.9+ and want to use Heapster for Kubernetes HPA functionalities, is adding the line:
After finishing your configurations, simply run tools/setup in terminal. Make sure to setup 2 vCPU or more for each node if enabling Heapster (use option -c).
Login to kube-master1 and check out the cluster using commands below:
$ vagrant ssh master1 $ sudo su – $ kubectl cluster-info $ kubectl get nodes -o wide
The second feature for kube-ansible, is to deploy Kubernetes on premises. Follow detailed instructions under this link if you are up to building your own Kubernetes private cloud infrastructure. Details on how to do so will probably be in our next post (or not, since the README is quite straightforward).
So that’s all for today, we’ll see you around next time
by 迎棧科技資深架構師 陳逸凡