---
title: Setting up a Kubernetes Cluster using Rancher on Ubuntu with Docker
description: Rancher is an open-source container management platform providing a graphical interface that makes container management easier.
tags: Kubernetes Rancher k8s containers
products:
  - kubernetes
  - instances
  - domains-and-dns
dates:
  validation: 2025-03-06
  posted: 2019-08-12
  validation_frequency: 12
difficulty: beginner
usecase:
  - deploy-external-software
ecosystem:
  - third-party
---
import image from './assets/scaleway-rancher_instances.webp'
import image2 from './assets/scaleway-rancher_instant_apps.webp'
import image3 from './assets/scaleway-rancher_password.webp'
import image4 from './assets/scaleway-rancher_dashboard_empty.webp'
import image5 from './assets/scaleway-rancher_add_cluster.webp'
import image6 from './assets/scaleway-rancher_cluster_options.webp'
import image7 from './assets/scaleway-rancher_node_run.webp'
import image8 from './assets/scaleway-rancher_dashboard.webp'
import image9 from './assets/scaleway-rancher_menu.webp'
import image10 from './assets/scaleway-rancher_dashboard.webp'
import image11 from './assets/scaleway-deploy_workload.webp'
import image12 from './assets/scaleway-nginx_demo_app.webp'
import image13 from './assets/scaleway-workload_edit.webp'
import image14 from './assets/scaleway-upgrade_service.webp'
import image15 from './assets/scaleway-workload_updated.webp'

import Requirements from '@macros/iam/requirements.mdx'


Rancher is an open-source container management platform providing a graphical interface that makes container management easier.

The Rancher UI makes it easy to manage secrets, roles, and permissions. It allows you to scale nodes and Pods and set up load balancers without requiring a command-line tool or editing hard-to-read YAML files.

<Requirements />

- A Scaleway account logged into the [console](https://console.scaleway.com)
- [Owner](/iam/concepts/#owner) status or [IAM permissions](/iam/concepts/#permission) allowing you to perform actions in the intended Organization
- An [SSH key](/organizations-and-projects/how-to/create-ssh-key/)
- [Configured a domain name](/domains-and-dns/quickstart/) (i.e. `rancher.example.com`) pointing to the first Instance

## Spinning up the required Instances

1. Click **CPU & GPU Instances** in the **Compute** section of the side menu. The [Instances page](https://console.scaleway.com/instance/servers) displays.
2. Click **Create Instance**. The [Instance creation wizard](https://console.scaleway.com/instance/servers/create) displays.
3. To deploy Instances with [Docker](https://www.docker.com/) preinstalled, click **+ Create Instance**:
    <Lightbox image={image} alt="" />
4. Click the **InstantApps** tab, and choose the **Docker** image:
    <Lightbox image={image2} alt="" />
5. Choose a region, type, and name for your Instance (i.e., `rancher1`), then click **Create Instance**.
6. Repeat these steps two more times to spin up a total of three Instances running Docker.

## Installing Rancher

1. Log into the first Instance (`rancher1`) via [SSH](/instances/how-to/connect-to-instance/).
2. Run the following command to fetch the Docker image `rancher/rancher` and run it in a container. This setup ensures that the Rancher container will restart automatically in case of failure. Make sure to replace `rancher.example.com` with your actual domain name pointing to the first Instance to enable automatic Let's Encrypt SSL certificate generation:
    ```bash
    docker run -d --restart=unless-stopped -p 80:80 -p 443:443 -v /host/rancher:/var/lib/rancher rancher/rancher --acme-domain rancher.example.com
    ```
    This command installs Rancher in a Docker container and automatically configures SSL using Let's Encrypt for secure communication.

## Configuring Rancher

1. Once Rancher is installed, open a web browser and navigate to your Rancher domain (e.g., `https://rancher.example.com`). You will see the Rancher setup page:
    <Lightbox image={image3} alt="" />
2. Enter a password and its confirmation, and click **Continue** to proceed with the installation.
3. The empty Rancher dashboard will display:
    <Lightbox image={image4} alt="" />

## Creating a cluster

1. In the Rancher UI, click **Add Cluster** to start configuring your new Kubernetes cluster.
2. The cluster creation page will appear. Click **Custom** to deploy the cluster on the already launched Scaleway Instances:
    <Lightbox image={image5} alt="" />
3. Name the cluster, choose the desired Kubernetes version, and select **None** for the cloud provider (since this is a custom setup).
    <Lightbox image={image6} alt="" />
4. Assign roles for each Instance in the cluster:
    - **Control plane**: Manages the state and configuration of the cluster.
    - **etcd**: Stores the state of the entire cluster (recommended to run 3 Instances for redundancy).
    - **Worker**: Runs your containers/Pods and handles the workload.
    Once the roles are assigned, run the command shown on the page to install the necessary software on each Instance.
    <Lightbox image={image7} alt="" />
5. Once all Instances are ready, click **Done** to initialize the cluster.
6. When the cluster is initialized, the dashboard will display:
    <Lightbox image={image8} alt="" />

## Deploying a cluster workload

Now that the cluster is set up, let us deploy your first Pod. A [Pod](https://kubernetes.io/docs/concepts/workloads/pods/pod-overview/) is the smallest deployable unit in Kubernetes.

1. In the top navigation bar, click **Global**, select your cluster, then choose **Default** from the drop-down menu:
    <Lightbox image={image9} alt="" />
2. On the clusters dashboard, click **Deploy**:
    <Lightbox image={image10} alt="" />
3. Enter the details for the workload:
    - **Name**: A friendly name for your workload.
    - **Docker Image**: Enter `nginxdemos/hello` to deploy a demo Nginx application.
    - Under **Port Mapping**, click **Add port** and set the following:
        - **Publish the container port**: `80`
        - **Protocol**: `TCP`
        - **As a**: `NodePort`
        - **Listening port**: `30000`
    <Lightbox image={image11} alt="" />
4. Click **Launch** to create the workload.
5. After deployment, you can access the Nginx demo application by visiting `http://<rancher.example.com>:30000/` in your web browser:
    <Lightbox image={image12} alt="" />

### Scaling the cluster workload

Currently, the Nginx demo app is running on a single Pod. Let’s scale it to multiple Pods.

1. From the cluster dashboard, click the ellipsis (**…**) next to your deployment and select **Edit**:
    <Lightbox image={image13} alt="" />
2. Set the number of replicas for the workload to **3** to scale to 3 Pods:
    <Lightbox image={image14} alt="" />
3. Click **Save**. Rancher will update the Kubernetes deployment to create 3 replicas of the Pod.
    <Lightbox image={image15} alt="" />
4. To access the application running on the second Instance, visit `http://<second_instance_ip>:30000/` in your browser. The Nginx demo application should display.

## Security considerations and best practices

- SSL/TLS: Ensure your Rancher domain is configured with a valid SSL certificate for secure communication. The `--acme-domain` option in the Rancher Docker command automatically handles Let's Encrypt certificates.
- Cluster security: It is a good practice to follow Kubernetes security guidelines for RBAC (Role-Based Access Control) and network policies when deploying to a production environment. For example, configure namespaces, enforce least-privilege access, and use network policies to control traffic between Pods.
- Backup & recovery: Regularly backup your Rancher configurations and Kubernetes data (e.g., etcd) to ensure you can restore your cluster in case of failure.

### Going further

For more detailed documentation on Rancher and Kubernetes, check out the official docs:
- [Rancher Documentation](https://ranchermanager.docs.rancher.com/)
- [Kubernetes Documentation](https://kubernetes.io/docs/home/)