In this tutorial, you will learn one way to set up Linux nodes for the Rancher management server. These nodes will fulfill the node requirements for OS, Docker, hardware, and networking.
If the Rancher server will be installed on an RKE Kubernetes cluster, you should provision three instances.
If the Rancher server will be installed on a K3s Kubernetes cluster, you only need to provision two instances.
If the Rancher server is installed in a single Docker container, you only need one instance.
1. Optional Preparation
- Create IAM role: To allow Rancher to manipulate AWS resources, such as provisioning new storage or new nodes, you will need to configure Amazon as a cloud provider. There are several things you'll need to do to set up the cloud provider on EC2, but part of this process is setting up an IAM role for the Rancher server nodes. For the full details on setting up the cloud provider, refer to this page.
- Create security group: We also recommend setting up a security group for the Rancher nodes that complies with the port requirements for Rancher nodes.
2. Provision Instances
- Log into the Amazon AWS EC2 Console to get started. Make sure to take note of the Region where your EC2 instances (Linux nodes) are created, because all of the infrastructure for the Rancher management server should be in the same region.
- In the left panel, click Instances.
- Click Launch Instance.
- In the section called Step 1: Choose an Amazon Machine Image (AMI), we will use Ubuntu 18.04 as the Linux OS, using
ami-0d1cd67c26f5fca19 (64-bit x86). Go to the Ubuntu AMI and click Select.
- In the Step 2: Choose an Instance Type section, select the
- Click Next: Configure Instance Details.
- In the Number of instances field, enter the number of instances. A high-availability K3s cluster requires only two instances, while a high-availability RKE cluster requires three instances.
- Optional: If you created an IAM role for Rancher to manipulate AWS resources, select the new IAM role in the IAM role field.
- Click Next: Add Storage, Next: Add Tags, and Next: Configure Security Group.
- In Step 6: Configure Security Group, select a security group that complies with the port requirements for Rancher nodes.
- Click Review and Launch.
- Click Launch.
- Choose a new or existing key pair that you will use to connect to your instance later. If you are using an existing key pair, make sure you already have access to the private key.
- Click Launch Instances.
Result: You have created Rancher nodes that satisfy the requirements for OS, hardware, and networking. Next, you will install Docker on each node.
3. Install Docker and Create User
- From the AWS EC2 console, click Instances in the left panel.
- Go to the instance that you want to install Docker on. Select the instance and click Actions > Connect.
- Connect to the instance by following the instructions on the screen that appears. Copy the Public DNS of the instance. An example command to SSH into the instance is as follows:
sudo ssh -i [path-to-private-key] ubuntu@[public-DNS-of-instance]
- Run the following command on the instance to install Docker with one of Rancher's installation scripts:
curl https://releases.rancher.com/install-docker/18.09.sh | sh
- When you are connected to the instance, run the following command on the instance to create a user:
sudo usermod -aG docker ubuntu
- Repeat these steps so that Docker is installed on each node that will eventually run the Rancher management server.
To find out whether a script is available for installing a certain Docker version, refer to this GitHub repository, which contains all of Rancher’s Docker installation scripts.
Result: You have set up Rancher server nodes that fulfill all the node requirements for OS, Docker, hardware and networking.
Next Steps for RKE Kubernetes Cluster Nodes
If you are going to install an RKE cluster on the new nodes, take note of the IPv4 Public IP and Private IP of each node. This information can be found on the Description tab for each node after it is created. The public and private IP will be used to populate the
internal_address of each node in the RKE cluster configuration file,
RKE will also need access to the private key to connect to each node. Therefore, you might want to take note of the path to your private keys to connect to the nodes, which can also be included in the
rancher-cluster.yml under the
ssh_key_path directive for each node.