me
Published on

How to install rancher

Authors
  • avatar
    Name
    Omer ATAGUN
    Twitter

I have talked in this blog why and when should you use rancher. Now its time to get into how to install and what to be careful about.

There is not much detailed explanations or sources that you can come out clean. Even though kubernetes is at least 10 years old technology is still relatively new and not much in usage due to its case specific nature.

Okay now, we have couple options to do so. In previous version of rancher deploying as docker image was not suggested, now they have updated in a way that you can export entire rancher installation if you want to carry your orchestration into high availability setup.

Official Rancher Instalation Guide

Yes it does exist, but it is generally commonly used providers based. Those are expensive, remember we do not want to pay thousands for some applications that is not needed to.

So we arrange ourselves a vps server as for to be our control plane,etcd

Installation

Get yourself a some vps linux server ( on Mac it may not work )

  • If you do not have docker installed in your linux server, get yourself one :)
sudo docker run --privileged -d --restart=unless-stopped -p 80:80 -p 443:443 rancher/rancher

OR

You can go with Helm CLI quick start

Helm CLI Quickstart

This installs the k3s server into your machine. Afterwards by using scp you download the kubeconfig file in order to have access to your k3s cluster from your own terminal.

Then simply via helm repo(sitory) you start to build rancher, namespace for cattlesystem ( rancher's management system ) cert-manager (for internal and external certificates) charts ( package manager ) also called helm charts has to be installed within this procedure.

You are ready to go now. Next, when you type ip of your server to your browser, you will be welcomed with rancher's first log-in

Rancherk3s
  • Don't make the guy angry, do as he says :)

  • To the terminal of yours which connected to the VPS server then;

type

docker ps

you will be witnessing the list of docker images that runs on your machine, rancher asks you to get container id so that you can grab your password, it will look like this

CONTAINER ID   IMAGE             COMMAND           CREATED         STATUS         PORTS                                      NAMES
4028334c0371   rancher/rancher   "entrypoint.sh"   3 minutes ago   Up 3 minutes   0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp   focused_banach

Copy the CONTAINER ID and then type below and enter;

docker logs 4028334c0371  2>&1 | grep "Bootstrap Password:"

You will have message printed to you something like this;

2022/08/11 18:18:06 [INFO] Bootstrap Password: 9jmsvh8ptccgq9kzwhm4gz9bt4nmh7dv228ng42m2xhcst5dcpn6nh

Do not worry, this is a test server :) enter your password in your browser. Then rancher will ask you to reset this and set by yourself one. Do that too, i just said don't make the guy angry. Agree the terms which you will never read, continue;

First look

On the welcome screen, you will be flowing with information of your cluster, there will be one named local as default when you click that, you will be witnessing your cluster details. System resources, how much used, how much reserved etc.

Let's deploy something that actually works. Depends on your personality, i will give you a 2 options. First is to deploy something via Workload -> Deployments OR Apps section to see how all these stuff combined.

Workloads

Most of the time, you will need this place to bring your images and install into your cluster. Lets create one

If you can't see the image below, copy the link of the image to get bigger version of it

Rancherk3s

I am going with mariadb deployment. Let's name our deployment in name* field which is needed. Say it like mariadb-deployment

On the Container image, we say get us version 10.7 which is mariadb:10.7

Not yet, we still have to tell which ports to look at. Below image, you will see ports Add two of them and say leave it as Do not create a service and name them as you are pleased to. Private container port for both is 3306 ( default mariadb, mysql ports )

Now we need to set mysql root password so we can access to it. To achieve that, Go below and find Environment variables and add one as Key/Value pair variable name should be MYSQL_ROOT_PASSWORD and value is your password so set one. I just typed myamazingpassword

Rancherk3s

Congratulations, you now have successfully deployed your mariadb instance. Surely this is not the end, but it's a nice beginning. There is a lot more to do such as creating yourself a persistent storage in order to assure even if your mariadb deployment is gone, your data remains the same.

Go to your workload on the left menu, you will see mariadb-deployment is active ( wait for a while if not ready yet ) on far right, you will see 3 dots as dropdown menu, click that and execute shell. This will allow you to get sh access into your container. So you can see if your deployment is actually running.

Just to test its there, write mariadb or mysql and you will see response as below. No i will not teach you how to create DB and stuff, that's entirely another topic :)

Rancherk3s

Next maybe we can continue with persistent storages using Longhorn. Till then stay hydrated :)