【问题标题】:Kubernetes API External Point Fail on ConnectionKubernetes API 外部点连接失败
【发布时间】:2018-08-21 15:34:42
【问题描述】:

我目前创建了这个kubernetes file:用于在 GCloud 上的集群中部署两个 API。我曾尝试在 kind Service 上制作两种“类型”。 首先,我将服务类型设置为 NodePort 并且无法连接到它,之后我尝试使用 LoadBalancer,尽管即使使用外部 IP 和 Endpoints 我也无法访问任何 API。

apiVersion: apps/v1
kind: Deployment
metadata:
  name: xxxxxxxxxxxxx
  labels:
    app: xxxxxxxx
spec:
  replicas: 1
  selector:
    matchLabels:
      app: xxxxxxxxx
  template:
    metadata:
      labels:
        app: xxxxxxxx
    spec:
      containers:
      - name: xxxxx
        image: xxxxxxxxx
        ports:
        - containerPort: 3000
---

kind: Service
apiVersion: v1
metadata:
  name: xxxxxxxxx
spec:
  selector:
    app: xxxxxxxx
  ports:
  - protocol: TCP
    port: 8080
    targetPort: 3000
  type: LoadBalancer

---

apiVersion: apps/v1
kind: Deployment
metadata:
  name: yyyyyy
  labels:
    app: yyyyyy
spec:
  replicas: 1
  selector:
    matchLabels:
      app: yyyyyy
  template:
    metadata:
      labels:
        app: yyyyyy
    spec:
      containers:
      - name: yyyyyy
        image: yyyyyy
        ports:
        - containerPort: 3000
---

kind: Service
apiVersion: v1
metadata:
  name: yyyyyy
spec:
  selector:
    app: yyyyyy
  ports:
  - protocol: TCP
    port: 80
    targetPort: 3000
  type: LoadBalancer

有人可以帮我解决这个问题吗?

问候。

【问题讨论】:

  • 1.如果您想将服务公开为 type:nodePort,那么您可以使用节点外部 IP 结合分配给服务的 nodePort(即 xxx.xxx.xxx.xxx:31000)到达 pod,或者您需要使用 @ 987654322@ 可以联系到外部。
  • 2.如果使用 type:LoadBalancer:验证 TCP 负载均衡器中配置的节点是否健康,可以接收流量,如果它们被列为不健康,那么他应该验证配置端口中的 Service IP 和 Endpoint (pod) IP 是否可达。为此,您可以 SSH 进入其中一个 Google Kubernetes Engine 节点并 curl 内部 IP: SVC-IP:端口 Endpoint-IP:端口 如果这没有回复,那么您将需要 SSH 进入 pod 并验证它是否正常工作在 localhost:3000 或验证服务可能正在侦听的端口。

标签: kubernetes google-kubernetes-engine


【解决方案1】:

有很多部署 Service (type:LoadBalancer) 的示例,并将流量重定向到 GKE 文档上的 Deployment。

请按照以下教程进行操作:

此外,在您的问题中,您没有列出任何“错误”或“事件”。请查看服务的kubectl describe 输出。如果您没有让负载平衡器正常工作,则可能会出现错误,例如您的 GCP 项目中的 IP 地址用完。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-03-12
    • 2016-04-30
    • 2018-09-21
    • 2020-06-12
    • 2020-01-10
    • 2020-01-07
    相关资源
    最近更新 更多