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
- Install Docker on CentOS 7
- Install Rancher Server
- Activate Rancher Local Authentication Server
- Add a new host
- 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.
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 serverhost01
In 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.
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 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.”
Now we want to use “Local authenticationClick on the page ‘Sweetened, Then type your username and password.
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”.
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“.
Now click on the “Add a host” button.
For the host registration URL, we will use the default settings as shown below.
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.
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.
And when this is done, you will get the result as shown below.
Now return to the Add Rancher Host Dashboard page and click “Close”.
And you’ll see “host02” on the page as shown below.
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.”
In the “Search” box, type the name of the application we want to install (“Ghost”).
Click the “View Details” button.
Give the new ghost container a name and description.
Then click the “Play” button.
When done, you will get the result as follows.
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.
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/
At this point, the installation of Server Rancher and Rancher on the Ubuntu server has completed successfully.
.