Skip to main content

Kubernetes

Kubernetes is a containerization orchestrator which you can read more about but for the purpose of our system, we use a stripped down version called K3S.

Kubernetes Server

There are many options to install K3S and what we call the master node (manager) server should be configured to allocate container resources. Each option is described in the Installation Manual. For ease of use, we will be using Docker Hub as our container registrar and thus, a normal install of K3S where it uses ETCD for it's internal database is fine. For this installation, you can SSH into the server and run the following:

curl -sfL https://get.k3s.io | sh -

The K3S Server will get installed but you will need a token which can be retrieved by running:

cat /var/lib/rancher/k3s/server/node-token

Kubernetes Agents

Worker nodes can be installed on their individual server by running the following command replacing (server ip address) and (node token) which you retrieved above:

curl -sfL https://get.k3s.io | K3S_URL=https://(server ip address):6443 K3S_TOKEN=(node token) sh -

Kubectl

To configure Kubernetes remotely for use, you will first need Kubectl. To simplify this process, you can download and install Docker Desktop.

Enable Kubernetes, this will create a local Kubernetes cluster on your computer.

Enable Kubernetes

Whether you are on Windows, Unix, or Linux, keep in mind the configuration is in the home folder: ~/.kube/config

What we want to do for the remote machines is to download the remote configuration to use locally. So on the staging/production server, pull the file locally to your computer from /etc/rancher/k3s/k3s.yaml. To simplify this, you can ssh into each server and run:

sudo cp /etc/rancher/k3s/k3s.yaml .

This will copy the file to your home folder but you should modify it's read/write settings so run:

sudo chmod 777 k3s.yaml

It's a good idea to rename the file to understand which server it came from so run:

mv k3s.yaml staging.yaml

Keep in mind this configuration file is configured for local so edit the file with the IP address directly:

nano staging.yaml

Replace 127.0.0.1 with the server address obtained from running 'ip address':

apiVersion: v1
clusters:
- cluster:
certificate-authority-data:
server: https://127.0.0.1:6443

Once done on your local computer, you can pull the file into ~/.kube/:

scp <user>@<ipaddress>:/home/<user>/staging.yaml .

Save these files for later, we will use them when setting up OpenLens.