mirror of
https://github.com/lordmathis/dev-cluster.git
synced 2025-12-23 00:54:26 +00:00
Add MetalLB configuration and resources for Kubernetes
This commit is contained in:
@@ -2,5 +2,6 @@
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
resources:
|
||||
- metallb
|
||||
- cert-manager
|
||||
- traefik
|
||||
|
||||
77
infrastructure/controllers/metallb/config-job.yaml
Normal file
77
infrastructure/controllers/metallb/config-job.yaml
Normal file
@@ -0,0 +1,77 @@
|
||||
# /infrastructure/controllers/metallb/config-job.yaml
|
||||
apiVersion: batch/v1
|
||||
kind: Job
|
||||
metadata:
|
||||
name: metallb-config
|
||||
namespace: metallb-system
|
||||
spec:
|
||||
template:
|
||||
spec:
|
||||
serviceAccountName: metallb-config-sa
|
||||
containers:
|
||||
- name: kubectl
|
||||
image: bitnami/kubectl:latest
|
||||
command:
|
||||
- /bin/bash
|
||||
- -c
|
||||
- |
|
||||
# Get the external IP of the node using kubectl
|
||||
SERVER_IP=$(kubectl get nodes -o jsonpath='{.items[0].status.addresses[?(@.type=="ExternalIP")].address}')
|
||||
|
||||
echo "Detected server IP: $SERVER_IP"
|
||||
|
||||
cat <<EOF | kubectl apply -f -
|
||||
apiVersion: metallb.io/v1beta1
|
||||
kind: IPAddressPool
|
||||
metadata:
|
||||
name: first-pool
|
||||
namespace: metallb-system
|
||||
spec:
|
||||
addresses:
|
||||
- ${SERVER_IP}/32
|
||||
EOF
|
||||
|
||||
cat <<EOF | kubectl apply -f -
|
||||
apiVersion: metallb.io/v1beta1
|
||||
kind: L2Advertisement
|
||||
metadata:
|
||||
name: l2-advert
|
||||
namespace: metallb-system
|
||||
spec:
|
||||
ipAddressPools:
|
||||
- first-pool
|
||||
EOF
|
||||
|
||||
echo "MetalLB configured to use IP: $SERVER_IP"
|
||||
restartPolicy: OnFailure
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
name: metallb-config-sa
|
||||
namespace: metallb-system
|
||||
---
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRole
|
||||
metadata:
|
||||
name: metallb-config-role
|
||||
rules:
|
||||
- apiGroups: ["metallb.io"]
|
||||
resources: ["ipaddresspools", "l2advertisements"]
|
||||
verbs: ["get", "list", "watch", "create", "update", "patch", "delete"]
|
||||
- apiGroups: [""]
|
||||
resources: ["nodes"]
|
||||
verbs: ["get", "list"]
|
||||
---
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRoleBinding
|
||||
metadata:
|
||||
name: metallb-config-rolebinding
|
||||
subjects:
|
||||
- kind: ServiceAccount
|
||||
name: metallb-config-sa
|
||||
namespace: metallb-system
|
||||
roleRef:
|
||||
apiGroup: rbac.authorization.k8s.io
|
||||
kind: ClusterRole
|
||||
name: metallb-config-role
|
||||
8
infrastructure/controllers/metallb/kustomization.yaml
Normal file
8
infrastructure/controllers/metallb/kustomization.yaml
Normal file
@@ -0,0 +1,8 @@
|
||||
# /infrastructure/controllers/metallb/kustomization.yaml
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
resources:
|
||||
- namespace.yaml
|
||||
- repository.yaml
|
||||
- release.yaml
|
||||
- config-job.yaml
|
||||
5
infrastructure/controllers/metallb/namespace.yaml
Normal file
5
infrastructure/controllers/metallb/namespace.yaml
Normal file
@@ -0,0 +1,5 @@
|
||||
# /infrastructure/controllers/metallb/namespace.yaml
|
||||
apiVersion: v1
|
||||
kind: Namespace
|
||||
metadata:
|
||||
name: metallb-system
|
||||
20
infrastructure/controllers/metallb/release.yaml
Normal file
20
infrastructure/controllers/metallb/release.yaml
Normal file
@@ -0,0 +1,20 @@
|
||||
# /infrastructure/controllers/metallb/release.yaml
|
||||
apiVersion: helm.toolkit.fluxcd.io/v2
|
||||
kind: HelmRelease
|
||||
metadata:
|
||||
name: metallb
|
||||
namespace: metallb-system
|
||||
spec:
|
||||
interval: 15m
|
||||
chart:
|
||||
spec:
|
||||
chart: metallb
|
||||
version: "0.14.9"
|
||||
sourceRef:
|
||||
kind: HelmRepository
|
||||
name: metallb
|
||||
namespace: metallb-system
|
||||
interval: 15m
|
||||
values:
|
||||
crds:
|
||||
enabled: true
|
||||
9
infrastructure/controllers/metallb/repository.yaml
Normal file
9
infrastructure/controllers/metallb/repository.yaml
Normal file
@@ -0,0 +1,9 @@
|
||||
# /infrastructure/controllers/metallb/repository.yaml
|
||||
apiVersion: source.toolkit.fluxcd.io/v1
|
||||
kind: HelmRepository
|
||||
metadata:
|
||||
name: metallb
|
||||
namespace: metallb-system
|
||||
spec:
|
||||
interval: 24h
|
||||
url: https://metallb.github.io/metallb
|
||||
Reference in New Issue
Block a user