【问题标题】:Error "no Route matched with those values" with the Kong ingress controllerKong 入口控制器出现错误“没有与这些值匹配的路由”
【发布时间】:2020-08-05 21:25:08
【问题描述】:

尝试连接到在使用 Kong 作为入口控制器的云托管 Kubernetes 服务上运行的 Jupyter Lab 容器(最终也包括其他应用程序)。在对 Kong 的公共 IP 的 http 响应中接收 "no Route matched with those values" 并且入口控制器日志表明:

service kong/rjup2 does not have any active endpoints
no configuration change, skipping sync to Kong

部署配置:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: rjup2
  namespace: kong
spec:
  selector:
    matchLabels:
      run: rjup2
  replicas: 1
  template:
    metadata:
      labels:
        run: rjup2
    spec:
      restartPolicy: Always
      containers:
        - name: rjup2
          image: jupyter/minimal-notebook
          imagePullPolicy: Always
          ports:
            - containerPort: 8888
              protocol: TCP

服务配置:

apiVersion: v1
kind: Service
metadata:  
  name: rjup2
  namespace: kong
spec:
  selector:    
    app: rjup2
  type: ClusterIP
  ports:  
  - name: http
    port: 80
    targetPort: 8888
    protocol: TCP

入口资源配置:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: rjup2
  namespace: kong
spec:
  tls:
  - hosts:
      - <AKS API server address>
  rules:
  - host: <AKS API server address>
    http:
      paths:
      - path: /
        backend:
          serviceName: rjup2
          servicePort: 80

API Server Address 已正确填充到已部署的 YAML 中。在将它们合并到 Kong 的默认命名空间下之前,我尝试了不同的命名空间,并尝试将服务端口设置为 8888 以及容器的目标端口。

感谢您在调试时提供的任何帮助。

【问题讨论】:

    标签: kubernetes kubernetes-ingress kong kubernetes-networking kong-ingress


    【解决方案1】:

    您的 rjup2 Service 没有有效的选择器。请注意,您尝试公开的Pods 标有run: rjup2 标签,而您的Service 具有app: rjup2 选择器。

    顺便说一句。您会收到非常清晰的错误消息,指出问题可能出在哪里:

    service kong/rjup2 does not have any active endpoints
    

    如果kong 命名空间中的rjup2 服务没有任何活动端点,这意味着它没有正确公开您的Pods,这可能表明您的配置可能不匹配。

    你可以通过运行来检查它:

    kubectl get ep -n kong
    

    通常您应该看到匹配的Endpoints 对象。在您的情况下,您不会看到它,因为您的 Service 无法公开任何 pod,直到它具有有效的选择器。

    如果你修正了你的 Service 定义,一切都会正常工作:

    apiVersion: v1
    kind: Service
    metadata:  
      name: rjup2
      namespace: kong
    spec:
      selector:    
        run: rjup2
      type: ClusterIP
      ports:  
      - name: http
        port: 80
        targetPort: 8888
        protocol: TCP
    

    【讨论】:

    • 谢谢。这是错误的主要来源。此外,至少在没有 DNS 主机名的 Azure 上,不需要入口配置中的主机:API 服务器地址信息。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-11-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多