参考
前置准备
设置 kubeproxy 严格 arp 模式:strictARP: true 对比更改
root@server-03:~# kubectl get configmap kube-proxy -n kube-system -o yaml | \
sed -e "s/strictARP: false/strictARP: true/" | \
kubectl diff -f - -n kube-system
diff -u -N /tmp/LIVE-1216402085/v1.ConfigMap.kube-system.kube-proxy /tmp/MERGED-656917207/v1.ConfigMap.kube-system.kube-proxy
--- /tmp/LIVE-1216402085/v1.ConfigMap.kube-system.kube-proxy 2025-12-09 02:25:18.979725160 +0000
+++ /tmp/MERGED-656917207/v1.ConfigMap.kube-system.kube-proxy 2025-12-09 02:25:18.979725160 +0000
@@ -37,7 +37,7 @@
excludeCIDRs: null
minSyncPeriod: 0s
scheduler: ""
- strictARP: false
+ strictARP: true
syncPeriod: 0s
tcpFinTimeout: 0s
tcpTimeout: 0s
应用更改
root@server-03:~# kubectl get configmap kube-proxy -n kube-system -o yaml | \
sed -e "s/strictARP: false/strictARP: true/" | \
kubectl apply -f - -n kube-system
Warning: resource configmaps/kube-proxy is missing the kubectl.kubernetes.io/last-applied-configuration annotation which is required by kubectl apply. kubectl apply should only be used on resources created declaratively by either kubectl create --save-config or kubectl apply. The missing annotation will be patched automatically.
configmap/kube-proxy configured
重启 kube-proxy 使得配置生效
kubectl rollout restart daemonset kube-proxy -n kube-system
helm 进行安装
helm repo add metallb https://metallb.github.io/metallb```
helm repo update
helm install metallb metallb/metallb
配置 IP 池
# 如果您想使用不同的 IP 范围,手动指定
cat <<EOF | kubectl apply -f -
apiVersion: metallb.io/v1beta1
kind: IPAddressPool
metadata:
name: default-pool
namespace: default
spec:
addresses:
- 192.168.174.210-192.168.174.230 # 修改为您的 IP 范围
---
apiVersion: metallb.io/v1beta1
kind: L2Advertisement
metadata:
name: default-l2
namespace: default
spec:
ipAddressPools:
- default-pool
EOF
检查 Ingress Controller 是否获得 EXTERNAL-IP
root@server-03:~# kubectl get svc -n ingress-nginx ingress-nginx-controller
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
ingress-nginx-controller LoadBalancer 10.111.28.141 192.168.174.210 80:30968/TCP,443:31615/TCP 40m