Setting up a Kubernetes Cluster using Rancher on Ubuntu with Docker
Reviewed on 06 March 2025 • Published 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
- Click Instances in the Compute section of the side menu. The Instances page displays.
- Click Create Instance. The Instance creation wizard displays.
- To deploy Instances with Docker preinstalled, click + Create Instance:
- Click the InstantApps tab, and choose the Docker image:
- Choose a region, type, and name for your Instance (i.e.,
rancher1
), then click Create Instance. - Repeat these steps two more times to spin up a total of three Instances running Docker.
Installing RancherLink to this anchor
- Log into the first Instance (
rancher1
) via SSH. - 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 replacerancher.example.com
with your actual domain name pointing to the first instance to enable automatic Let’s Encrypt SSL certificate generation:This command installs Rancher in a Docker container and automatically configures SSL using Let’s Encrypt for secure communication.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
Configuring RancherLink to this anchor
- 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: - Enter a password and its confirmation, and click Continue to proceed with the installation.
- The empty Rancher dashboard will display:
Creating a clusterLink to this anchor
- In the Rancher UI, click Add Cluster to start configuring your new Kubernetes cluster.
- The cluster creation page will appear. Click Custom to deploy the cluster on the already launched Scaleway Instances:
- Name the cluster, choose the desired Kubernetes version, and select None for the cloud provider (since this is a custom setup).
- 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.
- Once all instances are ready, click Done to initialize the cluster.
- 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.
- In the top navigation bar, click Global, select your cluster, then choose Default from the drop-down menu:
- On the clusters dashboard, click Deploy:
- 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
- Publish the container port:
- Click Launch to create the workload.
- 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.
- From the cluster dashboard, click the ellipsis (…) next to your deployment and select Edit:
- Set the number of replicas for the workload to 3 to scale to 3 pods:
- Click Save. Rancher will update the Kubernetes deployment to create 3 replicas of the pod.
- 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:
Was this page helpful?