Skip to content

RegSDS/regsds-gitops

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Document: SDS project

How to set up your Kubernetes cluster

Master (VM ubuntu)

Master 1

  1. Disable the Uncomplicated Firewall (UFW)
    ufw disable
  2. 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>
  3. 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
  4. Identify the IP address of your VM Ubuntu using ifconfig (to be used in the worker node setup in Step 3).
  5. 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
  6. 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 image

Master 2

  1. 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 command sudo k3s kubectl get node should display this
    image

Worker node

  1. Access the bootline file using the following command:
    sudo nano /cmd/bootline.txt

  2. Add the following line at the end of the /boot/cmdline.txt file:
    cgroup_enable=memory cgroup_memory=1

  3. 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 - image

  4. Wait for the configuration file at ./.kube/config to be copied from the master node (Step 5 of the master setup).

  5. Check if the configuration file has appeared by running the following command:
    k3s kubectl config view
    The result should display the Kubernetes configuration. image

  6. 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 image

How to deploy your application

  1. Clone the Kubernetes configuration repository using the following command
    git clone https://github.com/RegSDS/regsds-gitops
  2. Apply the Kubernetes configuration by running the following command
    sudo k3s kubectl apply -f <DEPLOYMENT_FILE_PATH>
  3. To check the status and location of each pod, use the following command
    sudo k3s kubectl get pods -o wide

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •