Nodes Creation

Panchayatseva Orbit: 3-Node Cluster Setup

Panchayatseva Orbit is a high-performance, scalable system deployed on a 3-node cluster.

1. Infrastructure Setup

1.1 Node Installation

Server Configuration: The cluster consists of three nodes, installed on server1.

  • Hardware Requirements:

    • CPU: 4
    • Memory: 8GB
    • Disk: 128GB
  • Operating System: Ubuntu-22.04

  • IP: 172.21.0.90

  • Port: 59222

Step-1: Create node-1 using below command.

sudo virt-install \
  --name ps-in-orbit-node01 \
  --os-variant ubuntu22.04 \
  --vcpus 2 \
  --memory 8192 \
  --location /data1/os-iso/ubuntu-22.04.4-live-server-amd64.iso,kernel=casper/vmlinuz,initrd=casper/initrd \
  --network bridge=virbr20,model=virtio,mac=0a:01:e1:20:00:08 \
  --network network=virho10,model=virtio,mac=0a:01:e1:20:00:08 \
  --disk size=128,pool=adm-images \
  --uuid 00000000-0000-0000-0000-0a01e1200008 \
  --graphics none \
  --extra-args 'console=ttyS0' \
  --debug

Step-2: Disk partition for the node.

  • /: 25 GB
  • /boot: 1 GB
  • SWAP: 8 GB
  • /opt: 34 GB
  • /data: 60 GB

Step-3: User Setup

  • Full Name: Devops Admin sayukth
  • Server Name: psorbit-node01
  • User: devopsadmin
  • Password: <1!Devxxxx>

Note:

  • Select the SSH server option during the installation process.
  • Add User to Sudoers: Use visudo to add the following line at the end of the file:
    devopsadmin ALL=(ALL) NOPASSWD: ALL
    
  • Make static the IP address of this node through winbox.

1.2. Tech Stack Installation

1. Clone the GitHub Repository

Execute the following command to clone the repository containing the automation scripts:

git clone https://github.com/DevOps-Model/DevOps-Automation-Scripts.git

2. Navigate to the Repository

Change directory to the cloned repository:

cd DevOps-Automation-Scripts

3. Copy the resource files to the temp

Copy the psorbit resource files to the temp directory:

cp -r psorbitConfigurationFiles/demo-resources-conf/ /tmp/demo-resources-conf

4. Run the TechStackInstallation Script

Execute the TechStackInstallation.py script to install the required tech stack:

python3 TechStackInstallation.py psorbit java maven haproxy tomcat git scylla redpanda mysql

5. Configure the Services

After installing the tech stack, configure the services using the following command:

python3 ConfigureScript.py psorbit configuration.conf
  • Start the mysql and scylla services.
sudo systemctl start mysql@bootstrap
sudo systemctl start scylla-server

6. Run Base Data

Once the services are configured, run the following command to initialize the base data:

python3 ConfigureScript.py psorbit databases.conf

Finally, the tech stack is completely installed, configured, and initialized with the base data.

1.3 Hardening the Node

  1. Go to the Hardening folder inside the repository:
    cd Hardening
    
  2. Execute the script to harden the node:
    bash ubuntu.sh
    
  3. If you want to verify the hardening score, run the following command:
    bash checkScore.sh
    
  4. To increase the hardening score, refer to the below documentation

2. Generate Nodes for the Cluster

Generate additional nodes for the cluster from a base node in server-1.

1. Run the Script to Generate Additional Nodes

  1. Node must be in shutdown state
virsh shutdown psorbit-node01

Create and execute the following Python script to generate two additional nodes for the cluster:

  1. Copy the below content save it as generate_nodes.py file.

    import subprocess
    
    def run_command(command):
        print(f"Running command: {command}")
        subprocess.run(command, shell=True, check=True)
    
    emp_suffix_list = ['02', '03']
    
    ip_prefix = '172.21.'
    ip_list = ['0.91', '0.92']
    
    mac_list = ['09', '10']
    
    project_name = 'psorbit'
    
    source_disk_img = '/data2/adm-images/psorbit-node01.qcow2'
    source_xml = '/data1/guest-xml/dev-template.xml'
    
    base_firstboot_script = '/root/scripts/startup-script.sh'
    
    base_uuid = '00000000-0000-0000-'
    
    for i in range(len(emp_suffix_list)):
    
        emp_id = emp_suffix_list[i]
    
        target_name = f'{project_name}-node{emp_id}'
    
        target_disk_img = f'/data2/guest-images/{target_name}.qcow2'
        target_xml = f'/data1/guest-xml/{target_name}.xml'
        target_firstboot_script = f'/root/scripts/{target_name}.sh'
    
        target_bridge_mac = f'0a:01:e1:20:00:{mac_list[i]}'
        target_host_mac = f'0a:01:e0:10:00:{mac_list[i]}'
    
        target_uuid = base_uuid + target_bridge_mac.replace(':', '')
    
        content = ""
        with open(source_xml, 'r') as file:
            content = file.read()
            content = content.replace('dev-ein0034', target_name)
            content = content.replace('0a:01:0d:20:de:35', target_bridge_mac)
            content = content.replace('0a:01:0d:10:de:35', target_host_mac)
            content = content.replace('/data1/guest-images/dev-template.qcow2', target_disk_img)
    
        with open(target_xml, 'w') as file:
            file.write(content)
    
        run_command(f"cp {source_disk_img} {target_disk_img}")
    
        script_content = ""
        with open(base_firstboot_script, 'r') as script:
            script_content = script.read()
            script_content = script_content.replace("mac-id", target_uuid)
            script_content = script_content.replace("iptobereplaced", ip_prefix + ip_list[i])
    
        with open(target_firstboot_script, "w") as start_script:
            start_script.write(script_content)
    
        run_command(f"virt-sysprep -a {target_disk_img}")
        run_command(f"virt-sysprep --hostname {target_name} -a {target_disk_img} --firstboot {target_firstboot_script}")
        run_command(f"virsh define {target_xml}")
    
  2. Run the above script.

    python3 generate_nodes.py
    

2. Start the Nodes

Once the nodes are generated, start them using the following command:

virsh start <node_name>

Example:

virsh start psorbit-node02
virsh start psorbit-node03

3. Make the IPs Static in Winbox

Log in to the router through Winbox and assign static IPs for the generated nodes.


4. Update Hostnames in the Nodes

Log in to the cluster nodes and update their hostnames in the /etc/hosts file:

vi /etc/hosts

Add or modify the following entries:

<node_static_ip>    psorbit-node02
<node_static_ip>    psorbit-node03