diff --git a/Kubernetes/K3S-Deploy/ipAddressPool.yaml b/Kubernetes/K3S-Deploy/ipAddressPool.yaml new file mode 100644 index 0000000..81238c6 --- /dev/null +++ b/Kubernetes/K3S-Deploy/ipAddressPool.yaml @@ -0,0 +1,8 @@ +apiVersion: metallb.io/v1beta1 +kind: IPAddressPool +metadata: + name: first-pool + namespace: metallb-system +spec: + addresses: + - lbrange diff --git a/Kubernetes/K3S-Deploy/k3s-test-do-not-use.sh b/Kubernetes/K3S-Deploy/k3s-test-do-not-use.sh new file mode 100644 index 0000000..72fc257 --- /dev/null +++ b/Kubernetes/K3S-Deploy/k3s-test-do-not-use.sh @@ -0,0 +1,197 @@ +#!/bin/bash + +echo -e " \033[33;5m __ _ _ ___ \033[0m" +echo -e " \033[33;5m \ \(_)_ __ ___( )__ / _ \__ _ _ __ __ _ __ _ ___ \033[0m" +echo -e " \033[33;5m \ \ | '_ \` _ \/ __| / /_\/ _\` | '__/ _\` |/ _\` |/ _ \ \033[0m" +echo -e " \033[33;5m /\_/ / | | | | | \__ \ / /_\\ (_| | | | (_| | (_| | __/ \033[0m" +echo -e " \033[33;5m \___/|_|_| |_| |_|___/ \____/\__,_|_| \__,_|\__, |\___| \033[0m" +echo -e " \033[33;5m |___/ \033[0m" + +echo -e " \033[36;5m _ _________ ___ _ _ _ \033[0m" +echo -e " \033[36;5m | |/ |__ / __| |_ _|_ _ __| |_ __ _| | | \033[0m" +echo -e " \033[36;5m | ' < |_ \__ \ | || ' \(_-| _/ _\` | | | \033[0m" +echo -e " \033[36;5m |_|\_|___|___/ |___|_||_/__/\__\__,_|_|_| \033[0m" +echo -e " \033[36;5m \033[0m" +echo -e " \033[32;5m https://youtube.com/@jims-garage \033[0m" +echo -e " \033[32;5m \033[0m" + + +############################################# +# YOU SHOULD ONLY NEED TO EDIT THIS SECTION # +############################################# + +# Version of Kube-VIP to deploy +KVVERSION="v0.6.3" + +# K3S Version +k3sVersion="v1.26.10+k3s2" + +# Set the IP addresses of the master and work nodes +master1=192.168.3.21 +master2=192.168.3.22 +master3=192.168.3.23 +worker1=192.168.3.24 +worker2=192.168.3.25 + +# User of remote machines +user=ubuntu + +# Interface used on remotes +interface=eth0 + +# Set the virtual IP address (VIP) +vip=192.168.1.50 + +# Array of master nodes +masters=($master2 $master3) + +# Array of worker nodes +workers=($worker1 $worker2) + +# Array of all +all=($master1 $master2 $master3 $worker1 $worker2) + +# Array of all minus master +allnomaster1=($master2 $master3 $worker1 $worker2) + +#Loadbalancer IP range +lbrange=192.168.1.61-192.168.1.79 + +#ssh certificate name variable +certName=id_rsa + +############################################# +# DO NOT EDIT BELOW # +############################################# +# For testing purposes - in case time is wrong due to VM snapshots +sudo timedatectl set-ntp off +sudo timedatectl set-ntp on + +# Move SSH certs to ~/.ssh and change permissions +cp /home/$user/{$certName,$certName.pub} /home/$user/.ssh +chmod 600 /home/$user/.ssh/$certName +chmod 644 /home/$user/.ssh/$certName.pub + +# Install k3sup to local machine if not already present +if ! command -v k3sup version &> /dev/null +then + echo -e " \033[31;5mk3sup not found, installing\033[0m" + curl -sLS https://get.k3sup.dev | sh + sudo install k3sup /usr/local/bin/ +else + echo -e " \033[32;5mk3sup already installed\033[0m" +fi + +# Install Kubectl if not already present +if ! command -v kubectl version &> /dev/null +then + echo -e " \033[31;5mKubectl not found, installing\033[0m" + curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" + sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl +else + echo -e " \033[32;5mKubectl already installed\033[0m" +fi + +# Create SSH Config file to ignore checking (don't use in production!) +echo "StrictHostKeyChecking no" > ~/.ssh/config + +#add ssh keys for all nodes +for node in "${all[@]}"; do + ssh-copy-id $user@$node +done + +# Install policycoreutils for each node +for newnode in "${all[@]}"; do + ssh $user@$newnode -i ~/.ssh/$certName sudo su <