Updates MetalLB to install with kustomize instea of ks default.
This commit is contained in:
@@ -40,7 +40,7 @@ K3s provides a fully-compliant Kubernetes distribution in a small footprint:
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Install K3s without the default load balancer (we'll use MetalLB)
|
# Install K3s without the default load balancer (we'll use MetalLB)
|
||||||
curl -sfL https://get.k3s.io | sh -s - --write-kubeconfig-mode=644 --disable servicelb
|
curl -sfL https://get.k3s.io | sh -s - --write-kubeconfig-mode=644 --disable servicelb --disable metallb
|
||||||
|
|
||||||
# Set up kubectl configuration
|
# Set up kubectl configuration
|
||||||
mkdir -p ~/.kube
|
mkdir -p ~/.kube
|
||||||
|
@@ -0,0 +1,18 @@
|
|||||||
|
namespace: metallb-system
|
||||||
|
resources:
|
||||||
|
- pool.yaml
|
||||||
|
configMapGenerator:
|
||||||
|
- name: metallb-config
|
||||||
|
envs:
|
||||||
|
- config/config.env
|
||||||
|
replacements:
|
||||||
|
- source:
|
||||||
|
kind: ConfigMap
|
||||||
|
name: metallb-config
|
||||||
|
fieldPath: data.CLUSTER_LOAD_BALANCER_RANGE
|
||||||
|
targets:
|
||||||
|
- select:
|
||||||
|
kind: IPAddressPool
|
||||||
|
name: first-pool
|
||||||
|
fieldPaths:
|
||||||
|
- spec.addresses.0
|
@@ -1,16 +1,14 @@
|
|||||||
---
|
---
|
||||||
# Define IP address pool for MetalLB
|
|
||||||
apiVersion: metallb.io/v1beta1
|
apiVersion: metallb.io/v1beta1
|
||||||
kind: IPAddressPool
|
kind: IPAddressPool
|
||||||
metadata:
|
metadata:
|
||||||
name: production
|
name: first-pool
|
||||||
namespace: metallb-system
|
namespace: metallb-system
|
||||||
spec:
|
spec:
|
||||||
addresses:
|
addresses:
|
||||||
- ${CLUSTER_LOAD_BALANCER_RANGE}
|
- PLACEHOLDER_CLUSTER_LOAD_BALANCER_RANGE
|
||||||
|
|
||||||
---
|
---
|
||||||
# Define Layer 2 advertisement for the IP pool
|
|
||||||
apiVersion: metallb.io/v1beta1
|
apiVersion: metallb.io/v1beta1
|
||||||
kind: L2Advertisement
|
kind: L2Advertisement
|
||||||
metadata:
|
metadata:
|
||||||
@@ -18,4 +16,4 @@ metadata:
|
|||||||
namespace: metallb-system
|
namespace: metallb-system
|
||||||
spec:
|
spec:
|
||||||
ipAddressPools:
|
ipAddressPools:
|
||||||
- production
|
- first-pool
|
@@ -0,0 +1,3 @@
|
|||||||
|
namespace: metallb-system
|
||||||
|
resources:
|
||||||
|
- github.com/metallb/metallb/config/native?ref=v0.15.0
|
@@ -1,12 +0,0 @@
|
|||||||
apiVersion: helm.cattle.io/v1
|
|
||||||
kind: HelmChartConfig
|
|
||||||
metadata:
|
|
||||||
name: metallb
|
|
||||||
namespace: kube-system
|
|
||||||
spec:
|
|
||||||
valuesContent: |-
|
|
||||||
apiVersion: v1
|
|
||||||
crds:
|
|
||||||
enabled: true
|
|
||||||
controller:
|
|
||||||
configInline: null
|
|
@@ -1,21 +0,0 @@
|
|||||||
---
|
|
||||||
# Define IP address pool for MetalLB using the new format
|
|
||||||
apiVersion: metallb.io/v1beta1
|
|
||||||
kind: IPAddressPool
|
|
||||||
metadata:
|
|
||||||
name: production
|
|
||||||
namespace: metallb-system
|
|
||||||
spec:
|
|
||||||
addresses:
|
|
||||||
- 192.168.8.240-192.168.8.250
|
|
||||||
|
|
||||||
---
|
|
||||||
# Define Layer 2 advertisement for the IP pool using the new format
|
|
||||||
apiVersion: metallb.io/v1beta1
|
|
||||||
kind: L2Advertisement
|
|
||||||
metadata:
|
|
||||||
name: l2-advertisement
|
|
||||||
namespace: metallb-system
|
|
||||||
spec:
|
|
||||||
ipAddressPools:
|
|
||||||
- production
|
|
@@ -12,22 +12,16 @@ fi
|
|||||||
|
|
||||||
echo "Setting up MetalLB..."
|
echo "Setting up MetalLB..."
|
||||||
|
|
||||||
# TODO: Remove the helm config in preference to a native config.
|
|
||||||
|
|
||||||
echo "Deploying MetalLB..."
|
echo "Deploying MetalLB..."
|
||||||
cat ${SCRIPT_DIR}/metallb/metallb-helm-config.yaml | envsubst | kubectl apply -f -
|
# cat ${SCRIPT_DIR}/metallb/metallb-helm-config.yaml | envsubst | kubectl apply -f -
|
||||||
|
kubectl apply -k metallb/installation
|
||||||
|
|
||||||
echo "Waiting for MetalLB to be deployed..."
|
echo "Waiting for MetalLB to be deployed..."
|
||||||
kubectl wait --for=condition=complete job -l helm.sh/chart=metallb -n kube-system --timeout=120s || echo "Warning: Timeout waiting for MetalLB Helm job"
|
kubectl wait --for=condition=Available deployment/controller -n metallb-system --timeout=60s
|
||||||
|
sleep 10 # Extra buffer for webhook initialization
|
||||||
|
|
||||||
echo "Waiting for MetalLB controller to be ready..."
|
echo "Customizing MetalLB..."
|
||||||
kubectl get namespace metallb-system &>/dev/null || (echo "Waiting for metallb-system namespace to be created..." && sleep 30)
|
kubectl apply -k metallb/configuration
|
||||||
kubectl wait --for=condition=Available deployment -l app.kubernetes.io/instance=metallb -n metallb-system --timeout=60s || echo "Warning: Timeout waiting for controller deployment"
|
|
||||||
|
|
||||||
echo "Configuring MetalLB IP address pool..."
|
|
||||||
kubectl get namespace metallb-system &>/dev/null && \
|
|
||||||
kubectl apply -f "${SCRIPT_DIR}/metallb/metallb-pool.yaml" || \
|
|
||||||
echo "Warning: metallb-system namespace not ready yet. Pool configuration will be skipped. Run this script again in a few minutes."
|
|
||||||
|
|
||||||
echo "✅ MetalLB installed and configured"
|
echo "✅ MetalLB installed and configured"
|
||||||
echo ""
|
echo ""
|
||||||
|
Reference in New Issue
Block a user