How to install Rancher Docker Container Manager on CentOS

Rancher is an open source container management platform. This allows you to easily run and manage Docker and Kubernetes. Rancher provides infrastructure services such as multi-host networking, load balancing, and volume snapshots.

In this tutorial, I’ll walk you through installing and configuring a Rancher and Proxy server step-by-step on a CentOS 7 server. We’ll install Docker and Rancher on the CentOS server, enable the Rancher Local Authentication Server, add the farm host, and then try to deploy the application. “Stealth” container from Rancher Control Panel.

precondition

  • CentOS 7
    • host01 – 192.168.33.10
    • host02 – 192.168.33.11
  • Root user or regular user with sudo privileges

Steps for this tutorial

  1. Install Docker on CentOS 7
  2. Install Rancher Server
  3. Activate Rancher Local Authentication Server
  4. Add a new host
  5. Deploy a new container

Step 1 – Install Docker on CentOS 7

Rancher can be installed as a set of Docker containers, one as administration server and the other as proxy. And we need to install Docker on all of our farm hosts and agents.

Install Docker on CentOS 7 using the command yum Under this ..

yum -y install docker

After the installation is complete, start the service and enable it at boot up.

systemctl start docker
systemctl enable docker

Docker installed on farm host server – check with below command.

systemctl status docker
docker --version

And you will get the result as shown below.

Install Docker on CentOS 7

Step 2 – Install Server Rancher

To run and install Rancher, we just need to run the Rancher container on our host server. In this step, we will be installing the Rancher server on one container on the ‘host01’ server.

Before installing Rancher Server on the serverhost01In this article, we will create and define a new directory as the Rancher size database.

Run the command below.

HOST_VOLUME=$HOME/rancher-data/mysql
mkdir -p $HOST_VOLUME

Now install Rancher Server using the docker command below.

sudo docker run -d 
-v $HOST_VOLUME:/var/lib/mysql 
--restart=unless-stopped 
-p 8080:8080 
rancher/server

Wait for Rancher Server to be installed.

Install Rancher Server

When the installation is complete, the Rancher server can be accessed from a web browser.

Open your web browser and type in the server IP address using port 8080.

http://192.168.33.10:8080/

And you will get the first Rancher installation page as follows.

Rancher Installation - Front Page

Rancher Server is installed on CentOS 7 and is now running on default port 8080.

Step 3 – Enable Local Authentication on Server Rancher

After installing Rancher, we need to configure Rancher Access Control. Access Control lets you manage which users have permission to access your Rancher server.

Rancher supports multiple access control providers, including Active Directory, Azure AD, Github, OpenLDAP, SAML, and Local Authentication.

In this tutorial, we’ll enable local authentication for the Rancher Server installation.

Open your web browser and type in the server IP address using port 8080.

Move the cursor to the “Administrator” drop-down menu and click on “Access Control.”

Enable local authentication on the Rancher server

Now we want to use “Local authenticationClick on the page ‘Sweetened, Then type your username and password.

Configure authentication

Click on the “Enable Local Authentication” button and you will be directed to the Rancher admin dashboard.

Access Control is set up for Rancher Server with local authentication enabled.

Step 4 – Add a new host

Hosts are Rancher’s primary resource unit and are represented as any Linux server (virtual or physical server with Docker installed on it).

In this step we will add new host ‘host02’ with Ubuntu as OS and 2GB RAM.

Connect to server “host02” using ssh.

ssh [email protected]

Now install Docker on Host 2 using yum command.

yum -y install docker

When the installation is complete, start up Docker and enable it to start every time the system starts.

systemctl start docker
systemctl enable docker

Docker is installed on server “host02”.

Install Docker

Next, we’ll add host02 to Rancher as host.

Open the Rancher Control Panel, and move the cursor to the menu.infrastructure“And click”The hosts“.

Open Rancher Control Panel

Now click on the “Add a host” button.

Add a new host

For the host registration URL, we will use the default settings as shown below.

Enter the URL for the host

Click the “Save” button.

Now select Host Type and Rancher Support for many host types including Amazon EC2, Azure, DigitalOcean and Rackspace Hosts.

Choose a hostCustom, Type the ‘host02’ IP address, and copy the docker command into the box as shown in the following image.

Dedicated host type

Now open Terminal shell host02 and paste the following command.

sudo docker run -e CATTLE_AGENT_IP="192.168.33.11"  --rm --privileged -v /var/run/docker.sock:/var/run/docker.sock -v /var/lib/rancher:/var/lib/rancher rancher/agent:v1.2.10 http://192.168.33.10:8080/v1/scripts/BCF2EFCA73A02954EBDF:1514678400000:OdRDdvnEUbV2hUMAFIS3oQxcTt4

The command will download and run a new Rancher Agent container.

Download and run a new Rancher Agent container

And when this is done, you will get the result as shown below.

The container download has completed

Now return to the Add Rancher Host Dashboard page and click “Close”.

And you’ll see “host02” on the page as shown below.

Host 2 is featured at Rancher

Host02 has been added to the Rancher server, and now we are ready to run containers managed by the Rancher server.

Step 5 – Test the creation of a new container

Rancher provides a catalog of applications. Available app templates make deployment easy.

Rancher provides two types of catalogs. A library catalog containing templates from the authorized Rancher catalog, and a community catalog containing templates from the Rancher Community catalog.

In this step, we’ll try to use the simple “Ghost” blog platform as a container via the Rancher Catalog community template.

On the Rancher dashboard, move the cursor to the menu.indexAnd click on “Community Catalog.”

Catalog of pastures

In the “Search” box, type the name of the application we want to install (“Ghost”).

Search application

Click the “View Details” button.

Give the new ghost container a name and description.

Enter the name and description for the container

Then click the “Play” button.

When done, you will get the result as follows.

Launch container

The “Ghost” container has been created and is now running on a Rancher proxy server.

Now move your cursor over the “Infrastructure” menu and click on “Host”. Now make sure that the “ghost” container is running on the “host2” server.

Host infrastructure

To check that the Ghost container is installed, open your web browser and type in the ‘host02’ IP address and you will get the default ghost blog homepage.

http://192.168.33.11/

Ghosts Blog is working

At this point, the installation of Server Rancher and Rancher on the Ubuntu server has completed successfully.

.

Source link

Leave a Reply

Your email address will not be published. Required fields are marked *