我有Mac M1运行Docker桌面(V20. 10. 17)。Kubernetes没有启用,只是Docker引擎在运行。
我安装了Kind Cluster:
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
# Can add additional control planes
#- role: control-plane
#- role: control-plane
- role: control-plane
- role: worker
- role: worker
- role: worker
然后,我使用https://kind.sigs.k8s.io/docs/user/loadbalancer/中的步骤安装了Metalllb
然后我部署了nginx:kubectl create deploy nginx --image nginx
如果我端口转发,我可以从浏览器到达nginx。
然后,我将我的部署公开为LoadBalancer类型的服务:kubectl expose deploy nginx --port 8080 --type LoadBalancer
不幸的是,如果我尝试通过显示的外部IP地址访问服务,我无法访问nginx。
请告知。
1条答案
按热度按时间scyqe7ek1#
LoadBalancers通过利用云提供商(如GCP或AWS)上的负载平衡器来工作,因此本地运行的Kind群集可能会使用NodePort服务而不是部署/StatefulSet中的Loadbalancers来公开nginx,但要仔细检查选项。
目前我正在为Postgres部署Kind,当我遇到类似的连接和端口转发问题时,解决方案是在Kind配置文件中添加一个侦听地址-在这两种情况下,问题都是使服务可以在集群之外访问。我相信您也可以像下面这样公开一个externalIP,但要测试一下。
kind-config.yaml(一些值来自Postgres)