NavigationContentFooter
Jump toSuggest an edit
Was this page helpful?

Setting up a Kubernetes Cluster using Rancher on Ubuntu with Docker

Reviewed on 06 March 2025Published on 12 August 2019
  • Kubernetes,
  • Rancher,
  • k8s,
  • containers

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.

Before you startLink to this anchor

To complete the actions presented below, you must have:

  • A Scaleway account logged into the console
  • Owner status or IAM permissions allowing you to perform actions in the intended Organization
  • An SSH key
  • Configured a domain name (i.e. rancher.example.com) pointing to the first Instance

Spinning up the required InstancesLink to this anchor

  1. Click Instances in the Compute section of the side menu. The Instances page displays.
  2. Click Create Instance. The Instance creation wizard displays.
  3. To deploy Instances with Docker preinstalled, click + Create Instance:
  4. Click the InstantApps tab, and choose the Docker image:
  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 RancherLink to this anchor

  1. Log into the first Instance (rancher1) via SSH.
  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:
    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 RancherLink to this anchor

  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:
  2. Enter a password and its confirmation, and click Continue to proceed with the installation.
  3. The empty Rancher dashboard will display:

Creating a clusterLink to this anchor

  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:
  3. Name the cluster, choose the desired Kubernetes version, and select None for the cloud provider (since this is a custom setup).
  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.
  5. Once all instances are ready, click Done to initialize the cluster.
  6. When the cluster is initialized, the dashboard will display:

Deploying a cluster workloadLink to this anchor

Now that the cluster is set up, let us deploy your first pod. A pod 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:
  2. On the clusters dashboard, click Deploy:
  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
  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:

Scaling the cluster workloadLink to this anchor

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:
  2. Set the number of replicas for the workload to 3 to scale to 3 pods:
  3. Click Save. Rancher will update the Kubernetes deployment to create 3 replicas of the pod.
  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 practicesLink to this anchor

  • 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.

Further readingLink to this anchor

For more detailed documentation on Rancher and Kubernetes, check out the official docs:

  • Rancher Documentation
  • Kubernetes Documentation
Was this page helpful?
API DocsScaleway consoleDedibox consoleScaleway LearningScaleway.comPricingBlogCareers
© 2023-2025 – Scaleway