一千萬個為什麽

搜索

在master的IP上公開kubernetes部署



我有簡單的部署,有3個副本。我希望此部署在這3個副本之間進行負載平衡,但在我的 master 的IP和某些指定端口上可用。

這個集群是使用 kubeadm 創建的,我有一個主節點和20個工作節點。

  • I tried to expose the service as LoadBalancer, but this only works when you have cloud load balancer configured. I don't have such thing and EXTERNAL-IP is always .
  • I tried to expose the service as NodePort, but this only works on nodes where pods were created. So for example after rollout, when pods will be created on different nodes, it will stop working. Also I guess this is not load balanced properly.
  • I tried to create ingress to make it work, but unsuccessfully.

    apiVersion: extensions/v1beta1
    kind: Ingress
    metadata:
      name: registry-ingress
      namespace: registry
      annotations:
        nginx.ingress.kubernetes.io/rewrite-target: /
    spec:
      rules:
      - http:
        paths:
          - path: /registry
            backend:
              serviceName: registry-service
              servicePort: 5000
    

這裏適當的方法是什麽?


如果以上是可能的話,那麽第二個問題:如果我想創建第二個問題,是否可以在2個主人身上公開它?

轉載註明原文: 在master的IP上公開kubernetes部署

一共有 1 個回答:

我對 NodePort 方法錯了。防火墻在端口 30000-32767 上阻止了與主設備的連接。

解鎖此端口後,一切都正常與 NodePort 服務。