From 84c228b43b201c9aee71ab5c425ea47f62a3ab3c Mon Sep 17 00:00:00 2001 From: James Turland Date: Mon, 4 Dec 2023 11:34:59 +0000 Subject: [PATCH] update --- Kubernetes/RKE2/ipAddressPool | 8 +++ Kubernetes/RKE2/k3s | 66 ++++++++++++++++++------- Kubernetes/RKE2/l2Advertisement.yaml | 8 +++ Kubernetes/RKE2/rke2-test-do-not-use.sh | 19 +++++-- 4 files changed, 80 insertions(+), 21 deletions(-) create mode 100644 Kubernetes/RKE2/ipAddressPool create mode 100644 Kubernetes/RKE2/l2Advertisement.yaml diff --git a/Kubernetes/RKE2/ipAddressPool b/Kubernetes/RKE2/ipAddressPool new file mode 100644 index 0000000..ffd58cc --- /dev/null +++ b/Kubernetes/RKE2/ipAddressPool @@ -0,0 +1,8 @@ +apiVersion: metallb.io/v1beta1 +kind: IPAddressPool +metadata: + name: first-pool + namespace: metallb-system +spec: + addresses: + - $lbrange \ No newline at end of file diff --git a/Kubernetes/RKE2/k3s b/Kubernetes/RKE2/k3s index 41b889c..83dcbc5 100644 --- a/Kubernetes/RKE2/k3s +++ b/Kubernetes/RKE2/k3s @@ -1,42 +1,70 @@ -#!/bin/bash - -echo "apiVersion: apps/v1 +apiVersion: apps/v1 kind: DaemonSet metadata: creationTimestamp: null + labels: + app.kubernetes.io/name: kube-vip-ds + app.kubernetes.io/version: v0.6.3 name: kube-vip-ds namespace: kube-system spec: selector: matchLabels: - name: kube-vip-ds + app.kubernetes.io/name: kube-vip-ds template: metadata: creationTimestamp: null labels: - name: kube-vip-ds + app.kubernetes.io/name: kube-vip-ds + app.kubernetes.io/version: v0.6.3 spec: + affinity: + nodeAffinity: + requiredDuringSchedulingIgnoredDuringExecution: + nodeSelectorTerms: + - matchExpressions: + - key: node-role.kubernetes.io/master + operator: Exists + - matchExpressions: + - key: node-role.kubernetes.io/control-plane + operator: Exists containers: - args: - manager env: - name: vip_arp - value: \"true\" - - name: vip_interface - value: $vipInterface + value: "true" - name: port - value: \"6443\" + value: "6443" + - name: vip_interface + value: $interface - name: vip_cidr - value: \"32\" + value: "32" - name: cp_enable - value: \"true\" + value: "true" - name: cp_namespace value: kube-system + - name: vip_ddns + value: "false" - name: svc_enable - value: \"true\" - - name: vip_address - value: $vipAddress - image: ghcr.io/kube-vip/kube-vip:v0.5.11 + value: "false" + - name: svc_leasename + value: plndr-svcs-lock + - name: vip_leaderelection + value: "true" + - name: vip_leasename + value: plndr-cp-lock + - name: vip_leaseduration + value: "5" + - name: vip_renewdeadline + value: "3" + - name: vip_retryperiod + value: "1" + - name: address + value: $vip + - name: prometheus_server + value: :2112 + image: ghcr.io/kube-vip/kube-vip:v0.6.3 imagePullPolicy: Always name: kube-vip resources: {} @@ -45,15 +73,17 @@ spec: add: - NET_ADMIN - NET_RAW - - SYS_TIME hostNetwork: true serviceAccountName: kube-vip tolerations: - effect: NoSchedule - key: node-role.kubernetes.io/master + operator: Exists + - effect: NoExecute + operator: Exists updateStrategy: {} status: currentNumberScheduled: 0 desiredNumberScheduled: 0 numberMisscheduled: 0 - numberReady: 0" + numberReady: 0 + diff --git a/Kubernetes/RKE2/l2Advertisement.yaml b/Kubernetes/RKE2/l2Advertisement.yaml new file mode 100644 index 0000000..b6f8c4d --- /dev/null +++ b/Kubernetes/RKE2/l2Advertisement.yaml @@ -0,0 +1,8 @@ +apiVersion: metallb.io/v1beta1 +kind: L2Advertisement +metadata: + name: example + namespace: metallb-system +spec: + ipAddressPools: + - first-pool \ No newline at end of file diff --git a/Kubernetes/RKE2/rke2-test-do-not-use.sh b/Kubernetes/RKE2/rke2-test-do-not-use.sh index 957e136..fc267fc 100644 --- a/Kubernetes/RKE2/rke2-test-do-not-use.sh +++ b/Kubernetes/RKE2/rke2-test-do-not-use.sh @@ -159,8 +159,6 @@ kubectl get nodes # Step 5: Install kube-vip as network LoadBalancer - Install the kube-vip Cloud Provider kubectl apply -f https://kube-vip.io/manifests/rbac.yaml kubectl apply -f https://raw.githubusercontent.com/kube-vip/kube-vip-cloud-provider/main/manifest/kube-vip-cloud-controller.yaml -#IP range for loadbalancer services to use -kubectl create configmap -n kube-system kubevip --from-literal range-global=$lbrange # Step 6: Add other Masternodes, note we import the token we extracted from step 3 for newnode in "${masters[@]}"; do @@ -204,7 +202,22 @@ done kubectl get nodes -# Step 8: Install Rancher (Optional - Delete if not required) +# Step 8: Install Metallb +kubectl apply -f https://raw.githubusercontent.com/metallb/metallb/v0.12.1/manifests/namespace.yaml +kubectl apply -f https://raw.githubusercontent.com/metallb/metallb/v0.13.12/config/manifests/metallb-native.yaml +# Download ipAddressPool and configure using lbrange above +curl -sO https://raw.githubusercontent.com/JamesTurland/JimsGarage/main/Kubernetes/RKE2/ipAddressPool +cat ipAddressPool | sed 's/$lbrange/'$lbrange'/g' > $HOME/ipAddressPool.yaml + +# Step 9: Deploy IP Pools and l2Advertisement +kubectl wait --namespace metallb-system \ + --for=condition=ready pod \ + --selector=component=controller \ + --timeout=120s +kubectl apply -f ipAddressPool.yaml +kubectl apply -f https://raw.githubusercontent.com/JamesTurland/JimsGarage/main/Kubernetes/RKE2/l2Advertisement.yaml + +# Step 10: Install Rancher (Optional - Delete if not required) #Install Helm curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 chmod 700 get_helm.sh