带有 Istio Ingress 的 Kubernetes 在标准 HTTP 端口 443/80 上不 运行

Kubernetes with Istio Ingress Not Running on Standard HTTP Ports 443/80

我正在尝试在 Kubernetes 上将 Istio 设置为入口控制器。问题是我的两个应用程序似乎可以从 Istio 入口控制器节点端口访问(例如,http://[host]:31380/application1http://[host]:31380/application2) 但无法从 443/80 访问。

我是 Kubernetes 和 Istio 的新手,所以我使用 https://istio.io/docs/guides/bookinfo/ 指南作为参考。按照指南进行操作相当容易,我能够使用提到的节点端口访问 Bookinfo 应用程序。不过我无法从 443/80 访问它。我使用 helm chart 来安装 Istio。我也没有在 Kubernetes 仪表板中的 Ingresses 下看到任何内容。

这里是 gateway/virtual 服务 yaml 的示例:

apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: myapp-gateway
spec:
  selector:
    istio: ingressgateway # use istio default controller
  servers:
  - port:
      number: 80
      name: http
      protocol: HTTP
    hosts:
    - "*"
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: myapp-virtual-service
spec:
  hosts:
  - "*"
  gateways:
  - myapp-gateway
  http:
  - match:
    - uri:
        prefix: /myapp
    route:
    - destination:
        host: myapp-app-service
        port:
          number: 7080
  - match:
    - uri:
        prefix: /
    route:
    - destination:
        host: kibana
        port:
          number: 5601

关于我必须做什么才能让它在 443 上收听有什么想法吗?我是否完全缺少一个组件?

如果需要在 443/80 上 运行 路由到您的应用程序,则您的 Kubernetes 集群必须部署外部负载均衡器。如果不存在,流量将被路由到入口节点端口。

参考-https://istio.io/docs/tasks/traffic-management/ingress/#determining-the-ingress-ip-and-ports(确定入口IP和端口):

"If the EXTERNAL-IP value is set, your environment has an external load balancer that you can use for the ingress gateway. If the EXTERNAL-IP value is (or perpetually ), your environment does not provide an external load balancer for the ingress gateway. In this case, you can access the gateway using the service’s node port."

没有外部负载均衡器的裸机实例示例:

[admin@master1 ~]$ kubectl get svc -n istio-system | grep istio-ingress
istio-ingress              LoadBalancer   10.114.107.196   <pending>     80:32400/TCP,443:31564/TCP                                            5d
istio-ingressgateway       LoadBalancer   10.99.1.148      <pending>     80:31380/TCP,443:31390/TCP,31400:31400/TCP                            5d

如果您要部署到在线云提供商,例如 IBM Bluemix(可能 AWS/Azure/etc),您应该已经配置了一个。如果您的配置是裸机,您可能没有配置负载均衡器。

我的带有外部负载均衡器的 Bluemix 实例的示例:

λ kubectl get svc -n istio-system | grep istio-ingress
istio-ingress              LoadBalancer   172.21.26.25     123.45.67.195   80:32000/TCP,443:31694/TCP                                            6h
istio-ingressgateway       LoadBalancer   172.21.139.142   123.45.67.196   80:31380/TCP,443:31390/TCP,31400:31400/TCP                            6h

我还没有回去将负载均衡器部署到裸机,所以想听听是否有人这样做了。我简单地看过 Metal,但没有花太多时间在上面。

可以在 api-server 清单中修改节点端口范围,如果您使用的是 kubeadm,请编辑 '/etc/kubernetes/manifests/kube-apiserver.yaml' 文件并添加以下行:

- --service-node-port-range=80-32767

然后,编辑'istio-ingressgateway'服务:

  - name: http2
    nodePort: 80
    port: 80
    protocol: TCP
    targetPort: 8080
  - name: https
    nodePort: 443
    port: 443
    protocol: TCP
    targetPort: 8443