(: March 1, 2018)
Welcome to our complete guide on How to launch Kubernetes cluster using Rancher on Cloud, Virtual Machine ( VMware, VirtualBox, Openstack) or a dedicated server with in-house hosting.
Rancher is a complete container management platform that makes deployment of Kubernetes and containers easy. Rancher natively supports Kubernetes and allows users to control its features through a simple and intuitive UI. Kubernetes can be launched in a matter of minutes with a single click through Rancher. It integrates with LDAP, AD, and GitHub for authentication.
Rancher also provides Application catalog with over 90 popular Docker applications where you can deploy and manage complex applications with a click of a button.If you’re a Helm user, then no worry since Rancher ships with it by default. Additionally, it’s easy to update Kubernetes to latest stable release using its UI.
Setting Up a Rancher Kubernetes Environment
The first thing you need to do is setup Rancher server. Recommended operating system is Ubuntu 16.04 (64-bit), which must have a kernel of 3.10+. For this, you need to create an EC2 instance on AWS then proceed with the setup.
Step 1: Update system apt cache
$ sudo apt-get update
Step 2: Install Docker
Install docker by running below commands on your terminal.
# curl -fsSL get.docker.com -o get-docker.sh # bash get-docker.sh # usermod -aG docker user # Add your username to docker group
For more details on how to install and configure Docker, refer to our previous article: How to install Docker CE on Ubuntu / Debian / Fedora / Arch / CentOS
Step 3: Start Rancher server
Rancher server will run as Docker container. The base image can be from rancher/server:latest or rancher/server:stable. Choose a stable tag for production deployments. If your server has port 8080 in use, choose a different port that gets mapped to port 8080 on the container.
$ sudo docker run --name rancher-server -d --restart=unless-stopped -p 8080:8080 rancher/server:stable
To see the progress of deployment, tails logs from the container.
$ sudo docker logs -f rancher-server
It will take a couple of minutes to finish. Once done, you should see “Startup Succeeded, Listening on port…,” on logs, the UI can be accessed on port 8080 on the host system. The URL will be:
Since anyone can access UI and API by default, it is recommended to do Access Control.
Step 4: Configure Kubernetes Environment
An environment in Rancher is a logical entity for sharing deployments and resources with different sets of users. To add Kubernetes environment go to Default > Manage Environments > Add Environment. Input name e.g kubernetes-cluster-01, then choose Kubernetes under Environment Template and click the Create Button.
Step 5: Add Hosts for Kubernetes cluster
We need to add at least one host under newly-created Kubernetes environment. To do this, under Infrastructure section, go to Hosts, then Add Host. Again in parallel, you need to prepare the host system to be added by using the following procedure.
- Install docker on the host
- Open UDP ports 500 and 4500 on the firewall – Used for IPsec networking.
- Paste the command given on Add Host dashboard to register the host with Rancher
Then click on the close button at the bottom of the screen. After adding hosts to Kubernetes environment, you’ll see the Kubernetes cluster being setup (this may take a few minutes). The cluster will be shown under Kubernetes menu.
This is the end of How to launch Kubernetes cluster using Rancher. I will update this article soon to cover node addition in details and working with Mesos and other cloud providers like Amazon, Azure, DigitalOcen e.t.c to deploy Kubernetes.