Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

 
 

Create a Rancher RKE2 Cluster

SUMMARY See examples on how to create a Rancher RKE2 cluster.

Use this example procedure to create a Rancher RKE2 cluster.

This procedure configures a server node and two agent nodes. In Rancher, a server node functions as a control plane node, and an agent node functions as a worker node. Tailor this procedure to the number of nodes in your cluster.

We provide this example procedure purely for informational purposes.

For more information about creating an RKE2 cluster, see the official Rancher documentation: https://docs.rke2.io/install/quickstart.

Before you start, make sure you've brought up the servers or VMs that you plan to use for the cluster nodes.

Note:

The command line examples below don't always show absolute directory paths. We leave it to you to apply these commands within your directory structure.

Configure a Server Node

Use this procedure to configure a server node.

A server node functions as a control plane node in RKE2. The server node used in our single cluster example is an Ubuntu host reachable at IP address 172.16.0.11.

  1. From your local computer, SSH into the server node as the root user.
  2. Create a config.yaml file at /etc/rancher/rke2 with the following content.
  3. Install, enable, and start the rke2-server service.
    1. Download the RKE2 installation script:
    2. Make the installation script executable.
    3. Set the installation variables to point to the desired release.
    4. Run the installation script.
      This script installs the rke2-server service.
    5. Enable and start the rke2-server service.
    6. Verify the status of the rke2-server service.
  4. Copy the kubeconfig file into the default kubeconfig directory.
  5. Copy kubectl into your default path. For convenience, Rancher provides the kubectl binary at the location shown.
  6. Show the status of the pods.
    Some pods are not running because CN2 is not yet installed.
  7. Download and install the CNI plugin.
    1. Create the following directory for the CNI plugin.
    2. Download the CNI plugin.
    3. Untar and gunzip the .tgz file.

Configure an Agent Node

Use this procedure to configure an agent node.

An agent node functions as a worker node in RKE2. The agent nodes used in our single cluster example are Ubuntu hosts reachable at IP addresses 172.16.0.12 and 172.16.0.13.

Note:

Repeat these steps for the desired amount of agent nodes.

  1. SSH into the agent node as the root user.
  2. Create a config.yaml file in the /etc/rancher/rke2 directory with the following content:
    The server_node_IP is the IP address of the server (control plane) node.
    The server_node_token is the token found in /var/lib/rancher/rke2/server/node-token on the server node.
  3. Install, enable, and start the rke2-agent service.
    1. Download the RKE2 installation script:
    2. Make the installation script executable.
    3. Set the installation type.
    4. Run the installation script.
      This script installs the rke2-agent service.
    1. Enable and start the rke2-agent service.
    2. Verify the status of the rke2-agent service.
  4. Show the status of the pods.
    Here's an example of the output when one agent node is up. Remember to issue this command from the server node.
  5. Download and install the CNI plugin.
    1. Create the following directory for the CNI plugin.
    2. Download the CNI plugin.
    3. Untar and gunzip the .tgz file.