- Disable the Uncomplicated Firewall (UFW)
ufw disable
- Install k3s script and initialize the cluster for the server (master) node:
curl -sfL https://get.k3s.io/ | K3S_TOKEN=<TOKEN> sh -s - server --cluster-init --tls-san=<MASTER_IP>
- Retrieve the K3S_TOKEN for the agent (to be used in the worker node setup in Step 3):
sudo cat /var/lib/rancher/k3s/server/node-token
- Identify the IP address of your VM Ubuntu using
ifconfig
(to be used in the worker node setup in Step 3). - Copy the Kubernetes configuration file from the master node to each worker node. This file is typically located at ~/.kube/config. You can use the Secure Copy (SCP) command to achieve this. Replace [worker-node-ip] with the actual IP address of each worker node:
scp ~/.kube/config username@[worker-node-ip]:~/.kube/config
- Assign role for each worker node with following command
sudo k3s kubectl label node <NODE_NAME> node-role.kubernetes.io/worker=worker
The result of all node should look like this
- To be another master, run this following command
curl -sfL https://get.k3s.io/ | K3S_TOKEN=<TOKEN> sh -s - server --server https://<MASTER1_IP>:<PORT>
The result from this commandsudo k3s kubectl get node
should display this
-
Access the bootline file using the following command:
sudo nano /cmd/bootline.txt
-
Add the following line at the end of the /boot/cmdline.txt file:
cgroup_enable=memory cgroup_memory=1
-
Install k3s script for the worker node by running the following command. Replace <YOUR_IP> and with the IP address and port of your master node, and <YOUR_TOKEN> with the token obtained from the master node in Step 3 of the master setup:
curl -sfL https://get.k3s.io/ | K3S_URL=https://<YOUR_IP>:<PORT>/ K3S_TOKEN=<YOUR_TOKEN> sh -
-
Wait for the configuration file at ./.kube/config to be copied from the master node (Step 5 of the master setup).
-
Check if the configuration file has appeared by running the following command:
k3s kubectl config view
The result should display the Kubernetes configuration. -
Check if the worker node is connected to the master node by running the following command:
sudo k3s kubectl --kubeconfig=./.kube/config get node
the result should be similar to this
- Clone the Kubernetes configuration repository using the following command
git clone https://github.com/RegSDS/regsds-gitops
- Apply the Kubernetes configuration by running the following command
sudo k3s kubectl apply -f <DEPLOYMENT_FILE_PATH>
- To check the status and location of each pod, use the following command
sudo k3s kubectl get pods -o wide