Basic Setup: Steps to assign hostname to ubuntu
Step 1: check installed hostname
sudo nano /etc/hosts
Step 2: change hostname in file below
sudo nano /etc/hostname
Basic Setup: Steps to assign static ip to ubuntu
Step 1: Connect your MAC to wifi where your device is going to be connected with static ip
Step 2: Find Default Gateway IP. Now You can see in wifi setting in MAC after wifi connected.
Step 3: Make Router to Pick other IP range so that it doesn't assign same ip to other devices
Step 3.1: Specify Static ip for Server
Step 4: Find how many files present for network connection in this path /etc/netplan/
sudo ls /etc/netplan/
Step 5: Edit those file and add the folling content with bold text
Step 5.1: Make sure it contains only following content
Step 6: To change hostname
sudo nano /etc/hostname
Step 6.1: If you have kubernetes installed then use dns resolver with /etc/systemd/resolved.conf
Step 7: And apply (if Kubernetes installed)
sudo systemctl restart systemd-resolved
Step 8: try again it works or not
nslookup smtp.gmail.com
How to generate open ssl keys
Run Following command to generate private key
openssl genpkey -algorithm RSA -out private.key -pkeyopt rsa_keygen_bits:2048
Run to extract public key using private key
openssl pkey -in private.key -pubout -out public.key
Run to get private key
cat private.key
Run to get public key
cat public.key
Basic Setup: Make service to hosts always in /etc/hosts
Step 1: Populate all hosts in texearea like example below
create scripting file to the VM
sudo nano setup-hadoop-hosts.sh
And Paste the content below into setup-hadoop-hosts.sh
Basic Setup:(Optional) Cgroup Setup for VM (But K8s Requirement)
Open file to enable cgroup_enable (to All machine)
sudo nano /boot/firmware/cmdline.txt
And append to the file to enable cgroup_enable (to all machines)
cgroup_enable=cpuset cgroup_enable=memory cgroup_memory=1 systemd.unified_cgroup_hierarchy=0
Reboot and see cgroup is enabled or not (to all machines)
cat /sys/fs/cgroup/cgroup.controllers
(Required only if cgroup is missing)
Install kernel built with memory
cgroup support to Ubuntu 25.10 in Raspberry pi 5
VPN Setup in VPN Client
Step 1: Add path of security key in local
Step 1: Add VPN Client IP Address
Step 1: Add VPN Server IP Address
Step 1.1: Add Ports you want to forward
Step 2: Move of QM.pem to user directory of client VPN machine
Step 2.1: Login to VPN Client
Now you are in VPN client in remote
Step 3: Save VPN Server Url to environment Variable in client
Step 4: Set VPN client file name in VPN client
Step 5: Apply changes in .bashrc
source ~/.bashrc
Step 6: Install Wireguard
Step 7: Stop VPN Client if VPN running already. Following is the command to see status
sudo wg show
Step 8: Generate Private Key and Public key for VPN client
Watcher service need to start from this step
wg genkey | tee /home/ubuntu/client_private.key | wg pubkey > /home/ubuntu/client_public.key
Step 9: Modify permission to QM.pem
sudo chmod 400 /home/ubuntu/QM.pem
Step 10: Generate config file for server for new client connection
Step 11: Upload .conf file to tmp directory of VPN Server
sudo scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i /home/ubuntu/QM.pem $conf_fileName ubuntu@${_VPN_SERVER_ADDR}:/tmp/
Step 12: Move .conf file in tmp directory to /etc/wireguard of VPN Server
Step 13: Enable VPN in VPN Server to listen from new VPN Client
Step 14: Forward traffic to VPN Client network
Step 15: Run following command to create vpn_client.conf file for VPN client
Step 16: Move .conf file in tmp directory to /etc/wireguard of VPN Client
sudo mv /tmp/vpn_client.conf /etc/wireguard/ && sudo chown root:root /etc/wireguard/vpn_client.conf && sudo chmod 600 /etc/wireguard/vpn_client.conf
Step 17: Enable and restart the wireguard
Step 18: To check IP table rule in VPN Server from VPN client
sudo ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i /home/ubuntu/QM.pem ubuntu@${_VPN_SERVER_ADDR} "sudo iptables -t nat -L -v -n"
VPN Watch Service in VPN Client
Step 1: Add VPN Server IP Address
Step 1.1: Add Ports you want to forward
Step 1.2: Open script file to to add process for checking VPN live or not
sudo nano /home/ubuntu/wg_handshake_check.sh
Step 2: Add following content to file /home/ubuntu/wg_handshake_check.sh
And Give execution permission to file
sudo chmod +x /home/ubuntu/wg_handshake_check.sh
Step 5: Create log file
sudo touch /home/ubuntu/wg_check.log && sudo chown ubuntu:ubuntu /home/ubuntu/wg_check.log && sudo chmod 644 /home/ubuntu/wg_check.log
Step 6: Create logrotate config to delete old logs
sudo nano /etc/logrotate.d/wg_check
And add following config
Step 7: Test rotation
sudo logrotate -f /etc/logrotate.d/wg_check
Step 3: Open a wg_check.service file to run wg_handshake_check.sh
sudo nano /etc/systemd/system/wg_check.service
And add following content to /etc/systemd/system/wg_check.service
Step 4: Open a wg_check.timer file to trigger wg_check.service
sudo nano /etc/systemd/system/wg_check.timer
And add following content to /etc/systemd/system/wg_check.timer
Step 4: Start service and Timer
Step 5: Check Service logs
tail -f /home/ubuntu/wg_check.log
Step 5: Check Service logs alternative
sudo journalctl -u wg_check.service -f
Step 6: (Optional) to check ip table rule in VPN server
sudo iptables -t nat -L -v -n --line-numbers
(Optional) to stop timer to check service
sudo systemctl disable --now wg_check.timer
(Optional) to stop timer to check service
sudo systemctl stop wg_check.service
Mongo restore/dump/export
Monitor and Maintain the Model
Step 1: Add Address of Mongo Server
Step 1: Login to Mongo Server
Step 2: Delete directory mongo_backup in loggned server outside of docker
sudo rm -r ./mongo_backup
Step 3: Delete directory mongo_backup inside docker of container of mongodb_1 of loggned server outside of docker
sudo docker exec -it mongodb_1 rm -rf ./var/mongo_backup
Step 4: Dump mongodb to directory mongo_backup inside docker of container of mongodb_1 of loggned server outside of docker
sudo docker exec -it mongodb_1 mongodump --host localhost --port 27017 --db qualitymore --username root --password password --authenticationDatabase admin --out ./var/mongo_backup
Step 5: Copy directory mongo_backup out of container mongodb_1 to ./mongo_backup
sudo docker cp mongodb_1:./var/mongo_backup ./mongo_backup
Step 6: Exiting from Server
exit
Step 7: Delete directory ~/Documents/mongo_backup in local computer
sudo rm -r ~/Documents/mongo_backup
Step 8: Download directory mongo_backup to ~/Documents/mongo_backup in local computer
Steps to restore dumped mongodb database
Step 1: Specify which one is the server ip
Step 1: Upload downloaded mongo to server
Step 2: ssh login to server
Step 3: Now restore database to mongodb_1 container
docker cp ./mongo_backup mongodb_1:/var && sudo docker exec -it mongodb_1 mongorestore --username root --password password --authenticationDatabase admin --nsFrom="qualitymore.*" --nsTo="qualitymore.*" ./var/mongo_backup
Format output format of docker ps
Add this command script to ./bashrc or in ~/.zshrc in mac
K8s Setup Process
Step 1: Add Address of Server
Step 1.1: login to each server
to switch to the pane Ctrl + b then ← →
Step 4: After each pane is ready with each server and synchronize all terminals with following steps
Ctrl + b then :
set synchronize-panes on
Now all terminal is synchronized and login with each machine
Step 5: check system is fine to install Kubernetes because it need 64bit in the machine.
uname -m
Step 6: OS should have option to enable memory for cgroup. E.g. Ubuntu 25.04.
Step 6: Better to turn off swaoff memory but kubernetes work without turning off swaoff memory too
sudo swapoff -a
Step 7: Check swap memory is zero or not.
free -h
Step 8: Load kernel modules to all nodes
To check cgroup available
stat -fc %T /sys/fs/cgroup
Step 9: Set sysctl params to all nodes
Step 10: And apply
sudo sysctl --system
Step 11: Install container runtime (containerd) to all nodes
Step 11.1: Reboot Master
sudo reboot
Step 12: Setup to install kubeadm, kubelet, kubectl to all nodes
Step 13: Open file to enable cgroup_enable (should be done in each machine one by one)
sudo nano /boot/firmware/cmdline.txt
Step 13.1: and append to the file to enable cgroup_enable (should be done in each machine one by one)
cgroup_enable=cpuset cgroup_enable=memory cgroup_memory=1 systemd.unified_cgroup_hierarchy=0
Step 13.1: Check whether if cgroup is enabled following command should show cpu and memory
cat /sys/fs/cgroup/cgroup.controllers
Step 13.1: (Optional) with Ubuntu 25.10 in Raspberry pi 5 to install kernel built with memory cgroup support
Step 13: Install kubeadm, kubelet, kubectl to all nodes and hold the version
Step 13.2: Reboot all nodes
sudo reboot
Step 13: Once kubeadm, kubelet, kubectl to kubeadm then put following command to synchronize all terminal because only we need to make master operation
Ctrl + b then :
set synchronize-panes off
Step 13.1: deleting all old files
Step 13.2: Flush iptables
Step 14.1: Make config file for kubeadm arguments
sudo nano /home/ubuntu/kubeadm-config.yaml
Step 14.2: Paste the following content
Step 14.3: initialize kubeadm and follow the instruction in the console
sudo kubeadm init --config /home/ubuntu/kubeadm-config.yaml
Step 16: Specify where config directory can be locatedn (which is given in console)
Step 17: Configure crictl to use containerd
Step 18: Restart kubelet (And wait for some minutes)
sudo systemctl restart kubelet
Step 19: See status
sudo crictl ps
Step 21.1: download kube-flannel.yml
curl -O https://raw.githubusercontent.com/projectcalico/calico/v3.28.0/manifests/calico.yaml
Step 21.2: Make calico not to bound nodes for dns outside like google.com
Find kind: IPPool in calico.yaml file and place line inside spec section
ipipMode: "Never"
Step 21.3: Make calico to detect dns using wifi
kind: DaemonSet → spec.template.spec.containers → name: calico-node → env:
Step 17: Verify nodes after 1 minute
kubectl get nodes
Step 17.1: Remove pod in kubernetes
kubectl delete pod -l app=<pod name>
Reset Kubeadmin and kublet (additional if not working)
Get join command in master
kubeadm token create --print-join-command
To see all containerd status in static pod
sudo crictl ps | egrep 'kube-apiserver|kube-controller-manager|kube-scheduler|etcd'
Give permission to all user for docker command
sudo usermod -aG docker $USER
to check node not ready
kubectl describe node node-name | grep -A5 Conditions
To check all system pods are runing
kubectl get pods -A
To see old CNI network
ls -l /etc/cni/net.d
delete old CNI network
kubectl delete -f https://raw.githubusercontent.com/flannel-io/flannel/v0.25.4/Documentation/kube-flannel.yml
Clean CNI configs
Check node is ready
kubectl get nodes
To see pod crash issue
kubectl describe pod podId
To make teporary pod to check networking issue
kubectl run -it --rm debug --image=busybox --restart=Never -- sh
To change scaling of pod in kubernetes
kubectl scale deployment--replicas=1
To see control page url
kubectl cluster-info
Additional Info of dependency order
To see all existing ServiceAccounts in Kubernetes
kubectl get sa -n <namespace>
To generate token for ServiceAccounts in Kubernetes
kubectl create token <serviceaccount-name> --duration=1h
To list all services in given namespace in Kubernetes
To see data is coming to tempo service
wget -qO- http://tempo-service:3100/metrics | grep tempo_distributor
Hadoop Installation Process
Before Starting this setup make sure you have all hosts listed in /etc/hosts in all machines
Step 1: Install java to all nodes.
Step 2: Generate Key in Master Node and copy to other node to allow ssh without password. (Only in master)
Step 3: Download Hadoop to all nodes
Step 4: Run this command to get java path and Copy in all nodes
readlink -f $(which java) | sed "s:bin/java::"
Step 4.1: Add Path to code Below so that command will be ready
Step 5: Add variables below to ~/.bashrc file in all nodes
Step 6: Add variable to hadoop-env.sh for Java 17 in all nodes
Step 8: Create Directories to all nodes
Step 7: Set Name Node location (Only in master now)
sudo nano $HADOOP_HOME/etc/hadoop/core-site.xml
And add following config>
Step 9: Specify the data directories (Only in master now)
sudo nano $HADOOP_HOME/etc/hadoop/hdfs-site.xml
And add following content
Step 9.1: Copy config files to all data nodes like follwing has sample for two nodes
List all workers in workers file in hadoop (Only in master)
sudo nano $HADOOP_HOME/etc/hadoop/workers
Assign JAVA_HOME variable to all nodes
sudo nano /usr/local/hadoop/etc/hadoop/hadoop-env.sh
Step 10: Format node in master (Only one time in only master)
Note: if you want to reformat it then stop hadoop first and repeat step 8.
hdfs namenode -format
Step 11: Now Start Hadoop in Master (Only in Master Node)
start-dfs.sh
Step 12: See status in master
jps
Step 13: Run following command to start data node (Only in data node)
hdfs --daemon start datanode
Step 12: Run following command to see reports (Only in Master node)
hdfs dfsadmin -report
Step 14: Any Failure see the report in Data Node (Only in Data node)
tail -n 30 /usr/local/hadoop/logs/hadoop-ubuntu-namenode-*.log
Other commands for master
To create directory to check in hdfs
hdfs dfs -mkdir -p /user/ubuntu/data
Set maximum allowed size in hadoop
hdfs dfsadmin -setSpaceQuota 72g /
To see maximum allowed size of directory in hadoop
hdfs dfs -count -q -h /shared/spark-logs
To copy file to hdfs
hdfs dfs -put ./housing_data.json /shared/housing_data/
To give permission for directory in hdfs
hdfs dfs -chmod 777 /shared/spark-logs
To to see file size contained by hdfs directory
hdfs dfs -du -h /path/
To see limited file content using hdfs
To upload file using namenode api