Pet*_*rtz 2 load-balancing docker kubernetes bare-metal-server metallb
我正在尝试建立一个裸机 Kubernetes 集群。我已经设置了基本的集群,没问题,但我似乎无法让 MetalLB 正常工作以向服务公开外部 IP。
我的最终目标是能够部署具有 2 个以上副本的应用程序,并拥有一个我可以引用的单个 IP/端口,以便访问任何正在运行的实例。
到目前为止,我所做的(为了测试这一点)是:
kubectl apply -f https://raw.githubusercontent.com/google/metallb/v0.7.3/manifests/metallb.yaml
kubectl apply -f metallb-layer-2.yml
kubectl run nginx --image=nginx --port=80
kubectl expose deployment nginx --type=LoadBalancer --name=nginx-service
Run Code Online (Sandbox Code Playgroud)
metallb-layer-2.yml:
apiVersion: v1
kind: ConfigMap
metadata:
namespace: metallb-system
name: config
data:
config: |
address-pools:
- name: k8s-master-ip-space
protocol: layer2
addresses:
- 192.168.0.240-192.168.0.250
Run Code Online (Sandbox Code Playgroud)
然后当我运行时kubectl get svc,我得到:
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
nginx-service LoadBalancer 10.101.122.140 <pending> 80:30930/TCP 9m29s
Run Code Online (Sandbox Code Playgroud)
无论我做什么,我都无法让服务拥有外部IP。有没有人有想法?
编辑:在找到有关使用 NodePort 的另一篇文章后,我执行了以下操作:
iptables -A FORWARD -j ACCEPT
Run Code Online (Sandbox Code Playgroud)
在这里找到。
现在,不幸的是,当我尝试卷曲 nginx 端点时,我得到:
> kubectl get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
nginx-service LoadBalancer 10.101.122.140 192.168.0.240 80:30930/TCP 13h
> curl 192.168.0.240:30930
curl: (7) Failed to connect to 192.168.0.240 port 30930: No route to host
> curl 192.168.0.240:80
curl: (7) Failed to connect to 192.168.0.240 port 80: No route to host
Run Code Online (Sandbox Code Playgroud)
我现在不确定这到底是什么意思。
编辑 2: 当我对运行 pod 的工作程序执行 TCP 转储时,我得到:
15:51:44.705699 IP 192.168.0.223.54602 > 192.168.0.240.http: Flags [S], seq 1839813500, win 29200, options [mss 1460,sackOK,TS val 375711117 ecr 0,nop,wscale 7], length 0
15:51:44.709940 ARP, Request who-has 192.168.0.240 tell 192.168.0.169, length 28
15:51:45.760613 ARP, Request who-has 192.168.0.240 tell 192.168.0.169, length 28
15:51:45.775511 IP 192.168.0.223.54602 > 192.168.0.240.http: Flags [S], seq 1839813500, win 29200, options [mss 1460,sackOK,TS val 375712189 ecr 0,nop,wscale 7], length 0
15:51:46.800622 ARP, Request who-has 192.168.0.240 tell 192.168.0.169, length 28
15:51:47.843262 IP 192.168.0.223.54602 > 192.168.0.240.http: Flags [S], seq 1839813500, win 29200, options [mss 1460,sackOK,TS val 375714257 ecr 0,nop,wscale 7], length 0
15:51:47.843482 ARP, Request who-has 192.168.0.240 tell 192.168.0.169, length 28
15:51:48.880572 ARP, Request who-has 192.168.0.240 tell 192.168.0.169, length 28
15:51:49.774953 ARP, Request who-has 192.168.0.240 tell 192.168.0.223, length 46
15:51:49.920602 ARP, Request who-has 192.168.0.240 tell 192.168.0.169, length 28
Run Code Online (Sandbox Code Playgroud)
在与 MetalLB 维护者讨论后,他能够找出问题是 Debian Buster 的新 nftables 防火墙。要禁用,
# update-alternatives --set iptables /usr/sbin/iptables-legacy
# update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy
# update-alternatives --set arptables /usr/sbin/arptables-legacy
# update-alternatives --set ebtables /usr/sbin/ebtables-legacy
Run Code Online (Sandbox Code Playgroud)
并重启集群中的节点!
| 归档时间: |
|
| 查看次数: |
2069 次 |
| 最近记录: |