我正在尝试访问部署在远程机器上的现有kubernetes集群中的服务。我已将群集配置为可以从本地Mac通过kubectl访问。

$ kubectl cluster-info
Kubernetes master is running at https://192.168.58.114:6443
KubeDNS is running at https://192.168.58.114:6443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy


我要连接的服务的入口配置为:

kind: Ingress
apiVersion: extensions/v1beta1
metadata:
  name: gw-ingress
  namespace: vick-system
  selfLink: /apis/extensions/v1beta1/namespaces/vick-system/ingresses/gw-ingress
  uid: 52b62da6-01c1-11e9-9f59-fa163eb296d8
  resourceVersion: '2695'
  generation: 1
  creationTimestamp: '2018-12-17T06:02:23Z'
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: >
      {"apiVersion":"extensions/v1beta1","kind":"Ingress","metadata":{"annotations":{"kubernetes.io/ingress.class":"nginx","nginx.ingress.kubernetes.io/affinity":"cookie","nginx.ingress.kubernetes.io/session-cookie-hash":"sha1","nginx.ingress.kubernetes.io/session-cookie-name":"route"},"name":"gw-ingress","namespace":"vick-system"},"spec":{"rules":[{"host":"wso2-apim-gateway","http":{"paths":[{"backend":{"serviceName":"gateway","servicePort":8280},"path":"/"}]}}],"tls":[{"hosts":["wso2-apim-gateway"]}]}}
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/affinity: cookie
    nginx.ingress.kubernetes.io/session-cookie-hash: sha1
    nginx.ingress.kubernetes.io/session-cookie-name: route
spec:
  tls:
    - hosts:
        - wso2-apim-gateway
  rules:
    - host: wso2-apim-gateway
      http:
        paths:
          - path: /
            backend:
              serviceName: gateway
              servicePort: 8280
status:
  loadBalancer:
    ingress:
      - ip: 172.17.17.100


我的服务列表是:


我的/etc/hosts文件如下所示:

##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1   localhost
255.255.255.255 broadcasthost
::1             localhost

172.17.17.100 wso2-apim-gateway wso2-apim wso2sp-dashboard


从本地浏览器访问此服务应使用的URL是什么?我应该再进行其他配置吗?

#1 楼

https://wso2-apim-gateway/是根据您的配置指向gateway服务的URL。这由配置的host: wso2-apim-gateway部分定义。请注意,您的负载均衡器(172.17.17.100)是一个专用IP地址,因此您需要位于同一网络上才能访问它。

我看不到任何其他需要的配置,除了TLS认证-如果收到5xx响应,则可能要检查ingress-nginx部署/复制案例的日志。

评论


是。问题出在我正在使用的节点端口的外部IP上。我将其编辑为正在运行的远程主机的实际IP,并用该IP替换了/ etc / hosts中的条目,并且一切正常。

– Pasan W.
18/12/23在3:35