Yasitha's Technical Blog
website·Indexed 30 days ago
https://blog.yasitha.dev/A collection of technical guides and tutorials focusing on infrastructure and system administration. Topics include multi-master Kubernetes cluster setups with Ceph and vSphere on CentOS 8, HashiCorp Vault HA clusters, etcd HA clusters, Confluent Kafka deployment, and MariaDB Galera Cluster configuration. It also provides instructions for AWS services like Athena and AMI creation, as well as OS-specific guides for CentOS, Ubuntu, macOS, and Windows.
What's inside Yasitha's Blog
- Amazon Athena allows you to query ALB access logs stored in Amazon S3 using standard SQL without needing complex ETL processes. Because ALB logs are stored as gzip files in S3, Athena is the recommended tool for analyzing large volumes of these logs to identify suspicious activity or system performance issues.
Plan network and DNS for Kubernetes cluster
The cluster architecture requires a Virtual IP for the Load Balancer, a range for VM IPs, and a dedicated IP pool for MetalLB. DNS entries must be configured for the API server and all individual nodes.IP Allocation
- Load Balancer VIP: 192.168.16.80
- VM IPs: 192.168.16.100 - 192.168.16.108
- MetalLB IP Pool: 192.168.16.200 - 192.168.16.250
DNS Mapping
- kube-api.example.local -> 192.168.16.80
- kubelb01.example.local -> 192.168.16.100
- kubelb02.example.local -> 192.168.16.101
- kubemaster01.example.local -> 192.168.16.102
- kubemaster02.example.local -> 192.168.16.103
- kubemaster03.example.local -> 192.168.16.104
- kubeworker01.example.local -> 192.168.16.105
- kubeworker02.example.local -> 192.168.16.106
- kubeworker03.example.local -> 192.168.16.107
System requirements for multi-master Kubernetes cluster on CentOS 8
The following hardware and software specifications are required for a multi-master Kubernetes deployment on CentOS 8 x64 using XFS file systems. Root access is preferred for all nodes.Nginx Load Balancers (2 VMs)
- CPU: 2 Cores
- Memory: 4 GB
- Disk: 20 GB SSD (Thin Provision)
Master Nodes (3 VMs)
- CPU: 2 Cores
- Memory: 8 GB
- Disk: 150 GB SSD (Thin Provision)
Worker Nodes (3 VMs)
- CPU: 4 Cores
- Memory: 16 GB
- Disk: 500 GB SSD (Thin Provision)
Install Nexus Repository OSS on CentOS 7
Install Nexus Repository OSS by setting up prerequisites, installing OpenJDK 8, and deploying the Nexus artifact to/opt/nexuswith a dedicated service account.# Install Prerequisites yum install -y epel-release unzip vim wget # Install OpenJDK 8 yum -y install java-1.8.0-openjdk java-1.8.0-openjdk-devel # Create folder structure mkdir -p /data/nexus-data /opt/nexus # Download and extract Nexus wget -O /tmp/nexus.tar.gz http://download.sonatype.com/nexus/3/latest-unix.tar.gz tar xvfz /tmp/nexus.tar.gz -C /opt/nexus --strip-components 1 # Create service account and set permissions sudo useradd --system --no-create-home nexus chown -R nexus:nexus /opt/nexus chown -R nexus:nexus /data/nexus-dataPrepare CentOS 7 VMs for Kafka installation
Before installing Kafka, ensure each node has a unique MAC address and
product_uuid. Use the following commands to verify:- MAC address:
ip link | grep link/ether - Product UUID:
cat /sys/class/dmi/id/product_uuid
Then, perform the system preparation steps: cleaning YUM cache, updating packages, installing prerequisites, and configuring Java 8.
# Clean YUM repository cache and update packages yum clean all -y yum update -y # Install prerequisites yum install -y curl which ntp # Install JDK 8 yum install -y java-1.8.0-openjdk java-1.8.0-openjdk-devel # Set JAVA_HOME in /etc/bashrc echo 'export JAVA_HOME=$(dirname $(dirname $(readlink $(readlink $(which javac)))))' >> /etc/bashrc source /etc/bashrc # Verify Java version java -version- MAC address:
Disable IPv6 on a specific network interface
If the cluster environment does not require IPv6, disable it on the specific network interface (e.g., ens192) using nmcli.sudo nmcli connection modify ens192 ipv6.method ignoreBoot a VMware macOS VM into Recovery Mode via EFI
Follow these steps to access the macOS Utilities menu when the standard boot process does not provide a recovery option:
- Start VMware Workstation/Fusion.
- Select the macOS VM and choose Power on to Firmware.
- In the EFI menu, navigate to: Enter setup > Configure boot options > Add boot options.
- Select the Recovery partition and then select boot.efi.
- When prompted for a description, type
recoveryand press Enter. - Choose Commit changes and exit.
- In the Boot Manager, select the newly created
recoveryoption and follow the prompts until the macOS Utilities menu appears.
Automatically mount an SMB/CIFS share on CentOS 6 using autofs
To automatically mount an SMB/CIFS share on CentOS 6, use theautofsservice. This process involves installing the necessary Samba and autofs packages, defining a master mount point, creating a map file for the specific share, and securing a credentials file for authentication.# 1. Install necessary packages yum install samba-client samba-common autofs # 2. Create the mount point mkdir /mnt/cifs_share # 3. Add the mount point and map file to /etc/auto.master # Format: <mount-point> <map-file> --timeout=<seconds> --ghost echo "/mnt/cifs_share /etc/auto.cifs --timeout=600 --ghost" >> /etc/auto.master # 4. Create the map file /etc/auto.cifs # Format: <mount-name> -fstype=cifs,rw,noperm,credentials=<path-to-creds> ://<Host Name>/<Folder Name> echo "share_data -fstype=cifs,rw,noperm,credentials=/etc/credentials.txt ://<Host Name>/<Folder Name>" > /etc/auto.cifs # 5. Create and secure the credentials file echo "username=DOMAIN/User password=Password" > /etc/credentials.txt chmod 0700 /etc/credentials.txt # 6. Restart the automounter service /etc/init.d/autofs restartInstall and configure Docker CE on CentOS 8 for Kubernetes
Install Docker CE and configure the daemon to use thesystemdcgroup driver, which is required for Kubernetes stability. Set the storage driver tooverlay2and limit log sizes to 100MB.# Add repo and install dnf config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo dnf install -y docker-ce-20.10.1 docker-ce-cli-20.10.1 # Configure daemon.json mkdir -p /etc/docker cat <<EOF | sudo tee /etc/docker/daemon.json > /dev/null { "exec-opts": ["native.cgroupdriver=systemd"], "log-driver": "json-file", "log-opts": { "max-size": "100m" }, "storage-driver": "overlay2", "storage-opts": [ "overlay2.override_kernel_check=true" ] } EOF # Start service systemctl daemon-reload systemctl enable --now dockerJoin additional Master and Worker nodes to the cluster
Join additional control-plane nodes and worker nodes one by one. Ensure the first master isREADYand all pods inkube-systemare running before joining new nodes. Use the join command generated during the first master's initialization.# Example Control Plane Join (requires token and cert-key from first master) kubeadm join kube-api.example.local:6443 --token <token> \ --discovery-token-ca-cert-hash sha256:<hash> \ --control-plane --certificate-key <key> --v=5 # Example Worker Join kubeadm join kube-api.example.local:6443 --token <token> \ --discovery-token-ca-cert-hash sha256:<hash> --v=5System requirements for etcd HA cluster on CentOS 7
To deploy an etcd High Availability (HA) cluster, the following minimum specifications are required per node for a 3-node cluster:
- CPU: 2 Cores
- Memory: 4 GB
- Disk: 20 GB SSD
- OS: CentOS 7 x64
- File System: XFS
- Privileges: Root access preferred
Prepare etcd system user and directory structure
Create a system user for the etcd service and set up the necessary configuration and data directories with restricted permissions and restored SELinux contexts.# Create ETCD service user sudo useradd --system --no-create-home etcd # Create ETCD directory structure sudo mkdir -p /etc/etcd/tls /var/lib/etcd # Provide necessary permissions sudo chown -R etcd:etcd /etc/etcd /var/lib/etcd sudo chmod 0700 /var/lib/etcd # Restore SELinux context sudo restorecon -RvF /etc/etcd /var/lib/etcd