Tutorials

Manage Kubernetes with Rancher 2.0

Table of Contents

Introduction

Software containers in a Kubernetes environment can be easily managed by Rancher. While much expertise was needed to build and run a Kubernetes cluster, Rancher's latest release will get you done in minutes. Rancher is open source software that combines everything it needs to make an agile enterprise productive in using containers. Based on Kubernetes, Rancher ensures that DevOps teams can test, deploy and manage their applications with minimal effort. Operational system administrators use the tool to launch, manage, and ultimately secure a Kubernetes environment, no matter where it physically operates.

In this article, I describe an example of how to set up a Rancher infrastructure on ProfitBricks IaaS. Rancher itself is started in a container. ProfitBricks offers a Rancher-compatible Docker driver, which can be integrated quickly and easily.

Prepare a Linux host for Rancher

Using the ProfitBricks DCD or the Cloud API we create a Linux server with the following key data:

  • Ubuntu 16:04 64 bit
  • 50 GB HDD hard drive
  • 2 Intel cores
  • 4 GB RAM
  • Connection to the Internet
  • Fixed public IP address

Rancher Server in DCD

Install Docker

Rancher requires one of the following Docker versions:

  • 1.12.6
  • 1.13.1
  • 17.03.2

After the login via ssh we proceed as follows:

Update the package index:

sudo apt-get update

Install the packages that allow accessing a repository via https:

sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    software-properties-common

Add the Docker GPG key:

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

Add the Docker stable repository:

sudo add-apt-repository \
    "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
    $(lsb_release -cs) \
    stable"

Updating the package index again:

sudo apt-get update

List the Docker versions available in the repository:

sudo apt-cache madison docker-ce

docker-ce | 18.03.1~ce-0~ubuntu | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
docker-ce | 18.03.0~ce-0~ubuntu | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
docker-ce | 17.12.1~ce-0~ubuntu | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
docker-ce | 17.12.0~ce-0~ubuntu | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
docker-ce | 17.09.1~ce-0~ubuntu | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
docker-ce | 17.09.0~ce-0~ubuntu | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
docker-ce | 17.06.2~ce-0~ubuntu | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
docker-ce | 17.06.1~ce-0~ubuntu | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
docker-ce | 17.06.0~ce-0~ubuntu | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
docker-ce | 17.03.2~ce-0~ubuntu-xenial | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
docker-ce | 17.03.1~ce-0~ubuntu-xenial | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
docker-ce | 17.03.0~ce-0~ubuntu-xenial | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages

Install Docker in version 17.03.2

sudo apt-get install docker-ce=17.03.2~ce-0~ubuntu-xenial

Start the Rancher container

sudo docker run -d --restart=unless-stopped -p 80:80 -p 443:443 rancher/rancher

Configure Rancher

Now we can access the running Rancher server at https://<ip_address>.

First, we set our password.

Rancher Set Password

... then confirm the URL for the Rancher server:

Rancher Confirm URL

Now we access the welcome page:

Rancher Welcome Page

Add the ProfitBricks driver

To add the ProfitBricks Docker Machine Driver, click on "Node Driver" and then on "Add Node Driver"

Rancher Node Drivers

Rancher Add Node Driver

In the now open mask, we enter the following URL and then click on "Create".

https://github.com/profitbricks/docker-machine-driver-profitbricks/releases/download/v1.3.3/docker-machine-driver-profitbricks-v1.3.3-linux-amd64.tar.gz

The ProfitBricks Docker driver is downloaded and automatically set to active.

ProfitBricks Node Driver Active

Create a template

Now we create a template for the deployment of the nodes (virtual instances on ProfitBricks) of the Kubernetes cluster. To do this, we click on the avatar on the top right and choose "Node Templates".

Node Templates

and then "Add Template"

In the following we fill out a mask, in which we enter ProfitBricks-specific information for creating the template (including the access data). Many fields are filled with default values. The Datacenter Id field may or may not be filled. If we enter the ID of an existing ProfitBricks virtual data center here, all nodes based on this template will be created in this virtual data center. If you do not enter an ID, a new virtual data center is created for each node that is created. In our setup Karlsruhe (de/fkb) is given as location.

ProfitBricks Options

Rancher Template

Now we choose a name for the template and click on "Create".

In principle, one template for the start is quite sufficient. However, a Rancher cluster can also be spun over different geographical locations. If desired, additional templates for the locations Frankfurt, Newark, or Las Vegas can be added.

We are now ready to go. This means that we can automatically deploy a Kubernetes cluster via the Rancher API or via the Rancher GUI, including the necessary roles. This is ensured by Rancher's newly developed Rancher Kubernetes Engine, RKE for short.

Create a cluster

In the menu click on "Clusters", then on "Add Cluster"

Clusters

Here we select ProfitBricks as provider and assign a name for the new Kubernetes cluster. In the lower part you click on "Add Node Pool". The cluster now has two node pools:

Infra contains a node that holds the etcd and control roles Workers contains two nodes that hold the worker role

Add Cluster

After clicking on Create the cluster will be created. In the background, virtual instances are provisioned in the location specified in the template and added to the Kubernetes cluster.

Cluster Provisioning Nodes Provisioning

The status page of the newly created cluster provides an overview of integrity and utilization at all times.

Dashboard Status

Deploy a workload

We now want to deploy a workload. As an example, I have selected an Apache web server.

Change to the workspace default:

Workspace Default Click on Deploy and enter the values as shown in the screenshot:

Deploy Workload

Click on "Launch" at the bottom of the page. After a short time, the pod is deployed:

Apache Workload

Via the link to 31102/tcp we reach the default page of the Apache webserver.

Conclusion

You are welcome to give Rancher a try in the ProfitBricks cloud. We are very pleased to provide you with help if you have any questions. Comment below or ask a question in the Community section. New customers can enjoy a free trial for 30 days.

 
  • Based on Kubernetes, Rancher ensures that DevOps teams can test, deploy and manage their applications with minimal effort. happy wheels classic game.

Log In, Add a Comment