【问题标题】:Access to exposed service in Kubernetes访问 Kubernetes 中的公开服务
【发布时间】:2019-09-26 07:32:42
【问题描述】:

设置详情:

  • VMWare 环境中的 Kubernetes 集群(1 个主节点,ip .222 - 2 个节点)
  • 已安装入口控制器,来自NGINXINC REPO 的示例应用程序

问题和疑问:

  • 无法从 Kubernetes 集群外部访问应用程序
  • 我想念什么?

配置:

kubectl get svc

输出

 NAME         TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)   AGE
coffee-svc   ClusterIP   10.109.97.144   <none>        80/TCP    60m

来自 Master 内部的 Curl(使用 ip .222)

curl http://10.109.97.144/coffee

输出

Server address: 10.36.0.5:80
Server name: coffee-bbd45c6-82w6t
Date: 08/May/2019:09:09:29 +0000
URI: /coffee
Request ID: a9602071f75126323a48efeb3552bb55

入口

kubectl get ingress

NAME           HOSTS                   ADDRESS   PORTS     AGE
cafe-ingress   test.me.at                        80, 443   62m
  • 目标:通过浏览器从不同的机器访问服务:

ps:我也试过用

卷曲
curl http://test.me.at/coffee 

输出

Failed connect to test.me.at:80; Connection refused

Add1: kubectl -n nginx-ingress 获取 svc

NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) default-http-backend ClusterIP 10.111.28.170 <none> 80/TCP nginx-ingress NodePort 10.101.248.204 <none> 80:31080/TCP, 443:31443/TCP

【问题讨论】:

  • 你能粘贴“kubectl -n nginx-ingress get svc”的输出吗?
  • 确保你的入口控制器前面的服务暴露在集群外部你希望访问你的服务的端口上。
  • @VasilyAngapov 这是输出 NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) default-http-backend ClusterIP 10.111.28.170 80/TCP nginx-ingress NodePort 10.101.248.204 80:31080/TCP,443:31443/TCP

标签: nginx kubernetes kubernetes-ingress nginx-ingress kubernetes-service


【解决方案1】:

您应该使用 NodePort 来公开服务。 如果你使用 ClusterIp 你不能从其他机器卷曲

【讨论】:

    猜你喜欢
    • 2019-07-26
    • 2017-02-13
    • 2020-04-07
    • 2019-01-10
    • 1970-01-01
    • 2019-01-05
    • 2020-01-31
    • 2020-03-19
    • 2019-04-28
    相关资源
    最近更新 更多