feat: Added Virtual Machines

This commit introduces a new directory structure for managing virtual
machines, specifically tailored for setting up Kubernetes manually on
Ubuntu. Files have been added to the `virtual-machines` directory,
which includes scripts and configurations necessary for the setup.
The following files have been added:
- `README.md`: Documentation for the virtual machines setup.
- `Vagrantfile`: Configuration for Vagrant to manage the virtual machines.
- `ssh.sh`: Script to set up SSH access.
- `tmux.conf`: Configuration file for tmux.
- `update-dns.sh`: Script to update DNS settings.
- `controlplane.sh`: Script to set up the control plane.
- `setup-hosts.sh`: Script to configure the hosts file.
- `vimrc`: Configuration file for Vim.

This commit is part of the ongoing effort to enhance the documentation
and setup instructions for manual installation of Kubernetes. Making
it easier for users to get started with manual installations and
configurations. With the intended purpose of making them more capabale
administrators and users of Kubernetes.
This commit is contained in:
Khalifah Shabazz
2025-06-01 13:18:00 -04:00
parent 52eb26dad1
commit 74ddcb11aa
8 changed files with 445 additions and 0 deletions

View File

@@ -0,0 +1,6 @@
#!/bin/bash
# Enable password auth in sshd so we can use ssh-copy-id
sed -i 's/#PasswordAuthentication/PasswordAuthentication/' /etc/ssh/sshd_config
sed -i 's/KbdInteractiveAuthentication no/KbdInteractiveAuthentication yes/' /etc/ssh/sshd_config
systemctl restart sshd

View File

@@ -0,0 +1,3 @@
set -g default-shell /usr/bin/bash
set -g mouse on
bind -n C-x setw synchronize-panes

View File

@@ -0,0 +1,6 @@
#!/bin/bash
# Point to Google's DNS server
sed -i -e 's/#DNS=/DNS=8.8.8.8/' /etc/systemd/resolved.conf
service systemd-resolved restart

View File

@@ -0,0 +1,10 @@
{
POD_CIDR=10.244.0.0/16
SERVICE_CIDR=10.96.0.0/16
kubeadm init --pod-network-cidr $POD_CIDR --service-cidr $SERVICE_CIDR --apiserver-advertise-address $PRIMARY_IP
kubectl --kubeconfig /etc/kubernetes/admin.conf \
apply -f "https://github.com/weaveworks/weave/releases/download/v2.8.1/weave-daemonset-k8s-1.11.yaml"
}

View File

@@ -0,0 +1,52 @@
#!/usr/bin/env bash
#
# Set up /etc/hosts so we can resolve all the nodes
set -e
IP_NW=$1
BUILD_MODE=$2
NUM_WORKER_NODES=$3
MASTER_IP_START=$4
NODE_IP_START=$5
if [ "$BUILD_MODE" = "BRIDGE" ]
then
# Determine machine IP from route table -
# Interface that routes to default GW that isn't on the NAT network.
sleep 5
MY_IP="$(ip route | grep default | grep -Pv '10\.\d+\.\d+\.\d+' | awk '{ print $9 }')"
# From this, determine the network (which for average broadband we assume is a /24)
MY_NETWORK=$(echo $MY_IP | awk 'BEGIN {FS="."} ; { printf("%s.%s.%s", $1, $2, $3) }')
# Create a script that will return this machine's IP to the bridge post-provisioner.
cat <<EOF > /usr/local/bin/public-ip
#!/usr/bin/env sh
echo -n $MY_IP
EOF
chmod +x /usr/local/bin/public-ip
else
# Determine machine IP from route table -
# Interface that is connected to the NAT network.
MY_IP="$(ip route | grep "^$IP_NW" | awk '{print $NF}')"
MY_NETWORK=$IP_NW
fi
# Remove unwanted entries
sed -e '/^.*ubuntu-jammy.*/d' -i /etc/hosts
sed -e "/^.*${HOSTNAME}.*/d" -i /etc/hosts
# Export PRIMARY IP as an environment variable
echo "PRIMARY_IP=${MY_IP}" >> /etc/environment
[ "$BUILD_MODE" = "BRIDGE" ] && exit 0
# Update /etc/hosts about other hosts (NAT mode)
echo "${MY_NETWORK}.${MASTER_IP_START} controlplane" >> /etc//hosts
for i in $(seq 1 $NUM_WORKER_NODES)
do
num=$(( $NODE_IP_START + $i ))
echo "${MY_NETWORK}.${num} node0${i}" >> /etc//hosts
done

View File

@@ -0,0 +1,6 @@
set nu
set ts=2
set sw=2
set et
set ai
set pastetoggle=<F3>