Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/azure/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在Azure Kubernetes服务上公开http/https应用程序_Azure_Kubernetes_Azure Aks - Fatal编程技术网

如何在Azure Kubernetes服务上公开http/https应用程序

如何在Azure Kubernetes服务上公开http/https应用程序,azure,kubernetes,azure-aks,Azure,Kubernetes,Azure Aks,我正在将我的dockerized应用程序移植到kubernetes,而我在使用aks创建负载平衡器时遇到了一个问题: The Service "lbalance" is invalid: spec.ports[0].nodePort: Invalid value: 80: provided port is not in the valid range. The range of valid ports is 30000-32767 配置非常简单 apiVersion: v1 kind: Se

我正在将我的dockerized应用程序移植到kubernetes,而我在使用aks创建负载平衡器时遇到了一个问题:

The Service "lbalance" is invalid: spec.ports[0].nodePort: Invalid value: 80: provided port is not in the valid range. 
The range of valid ports is 30000-32767
配置非常简单

apiVersion: v1
kind: Service
metadata:
  name: lbalance
spec:
  selector:
    app: lbalance
  ports:
  - protocol: TCP
    port: 80
    targetPort: 80
    nodePort: 80
    name: http
  - protocol: TCP
    port: 443
    targetPort: 443
    nodePort: 443
    name: https
  type: LoadBalancer
后面是一个haproxy,它通过ssl终止指向集群中公开的其他服务

在我的测试环境中,我有一个属性来控制要打开的端口(--service node port range),但我在门户页面或Azure文档中都找不到该属性


是否有一种方法可以在默认端口上提供服务,或者有一种推荐的方法可以连接回该端点端口?

您需要从yaml中删除
节点端口
声明,它将由kubernetes从错误文本中提到的池(您唯一可以使用的池)中分配


通过这种方式,您的服务将在80\443上可用,并且一切正常运行

30000-32767是kubernetes中的默认节点端口范围。您已定义为,nodePort:443。它不受支持,因此引发了错误

按照以下步骤操作

  • 将NodePort替换为ClusterIP作为服务类型
  • 部署入口控制器
  • 部署默认后端
  • 从dns证书创建机密(对于https)
  • 部署入口规则(包括机密)以将用户请求路由到后端服务
    lbalance LoadBalancer 10.0.141.113 80:30933/TCP,443:32460/TCP 6s如果删除节点端口,它们不会在80/443上公开,但在一些随机的30k+端口上,这可能意味着您的设置错误,无法在azure中创建负载平衡器,可能您的SP配置错误。我信任kubectl输出,但实际上服务器的响应与enpoint所告诉的端口无关
    apiVersion: v1
    kind: Service
    metadata:
      name: lbalance
    spec:
      selector:
        app: lbalance
      ports:
      - protocol: TCP
        port: 80
        targetPort: 80
        name: http
      - protocol: TCP
        port: 443
        targetPort: 443
        name: https
      type: LoadBalancer