knative domain mapping is not working properly. error: 111 occured. how to use?

138 views Asked by At

I'm studying about kntaive's serving. When i study domain mapping part. I discovered that it doesn't work as expected.

Knative Version

1.11.1

Expected Behavior

When calling a URL connected to Domain Mapping, it must be properly routed to the service.

Actual Behavior

upstream connect error or disconnect/reset before headers. reset reason: connection failure, transport failure reason: delayed connect error: 111 printed.

Steps to Reproduce the Problem

First. I create service and domain mapping object. And edit cm config-domain ebs-app.default.edu.com connect ebs-app service. If i call API. EBS! will be printed.

[root@master knative]# cat domain-mapping.yaml
apiVersion: serving.knative.dev/v1alpha1
kind: DomainMapping
metadata:
  name: www.kt.com
  namespace: default
spec:
  ref:
    name: ebs-app
    kind: Service
    apiVersion: serving.knative.dev/v1
[root@master knative]#
[root@master knative]# cat ebs.yaml
apiVersion: serving.knative.dev/v1
kind: Service
metadata:
  name: ebs-app
  labels:
    domain: ebs
spec:
  template:
    spec:
      containers:
        - image: blahblah/golang:ebs
          ports:
            - containerPort: 80

Result is this. Create well.

[root@master knative]# k get virtualservices.networking.istio.io
NAME                 GATEWAYS                                                                              HOSTS                                                                                                     AGE
ebs-app-ingress      ["knative-serving/knative-ingress-gateway","knative-serving/knative-local-gateway"]   ["ebs-app.default","ebs-app.default.edu.com","ebs-app.default.svc","ebs-app.default.svc.cluster.local"]   143m
ebs-app-mesh         ["mesh"]                                                                              ["ebs-app.default","ebs-app.default.svc","ebs-app.default.svc.cluster.local"]                             143m
www.kt.com-ingress   ["knative-serving/knative-ingress-gateway"]                                           ["www.kt.com"]                                                                                            7m22s
[root@master knative]#
[root@master knative]# k get domainmappings.serving.knative.dev
NAME         URL                 READY   REASON
www.kt.com   http://www.kt.com   True

Second. Call URL.

[root@master knative]# curl -H 'Host: ebs-app.default.edu.com' localhost:30278
EBS!
[root@master knative]#
[root@master knative]# curl -H 'Host: www.kt.com' localhost:30278
upstream connect error or disconnect/reset before headers. reset reason: connection failure, transport failure reason: delayed connect error: 111[root@master knative]#
[root@master knative]#
[root@master knative]#

When i call API adding www.kt.com host header. error: 111 printed.

Upon analysis, I found that the ebs-app-ingress Virtual Service routes the Host Header to the ebs-app External Name. Not Service(ebs-app-0001).

[root@master knative]# k describe virtualservices.networking.istio.io www.kt.com-ingress
Name:         www.kt.com-ingress
Namespace:    default
Labels:       networking.internal.knative.dev/ingress=www.kt.com
Annotations:  networking.knative.dev/ingress.class: istio.ingress.networking.knative.dev
              serving.knative.dev/creator: kubernetes-admin
              serving.knative.dev/lastModifier: kubernetes-admin
API Version:  networking.istio.io/v1beta1
Kind:         VirtualService
Metadata:
  Creation Timestamp:  2023-10-23T07:37:52Z
  Generation:          1
  Owner References:
    API Version:           networking.internal.knative.dev/v1alpha1
    Block Owner Deletion:  true
    Controller:            true
    Kind:                  Ingress
    Name:                  www.kt.com
    UID:                   c25c0a04-f0ee-4896-b996-e8d3242620d9
  Resource Version:        985562
  UID:                     000cdf33-9de1-4a15-a38f-c31b38194167
Spec:
  Gateways:
    knative-serving/knative-ingress-gateway
  Hosts:
    www.kt.com
  Http:
    Headers:
      Request:
        Set:
          K - Network - Hash:  0dddc8f069617a61520c52900aa791305c8fc16be8943157b66a7eb3ba35f9a6
    Match:
      Authority:
        Prefix:  www.kt.com
      Gateways:
        knative-serving/knative-ingress-gateway
      Headers:
        K - Network - Hash:
          Exact:  override
    Retries:
    Rewrite:
      Authority:  ebs-app.default.svc.cluster.local
    Route:
      Destination:
        Host:  ebs-app.default.svc.cluster.local
        Port:
          Number:  80
      Headers:
        Request:
          Set:
            K - Original - Host:  www.kt.com
      Weight:                     100
    Match:
      Authority:
        Prefix:  www.kt.com
      Gateways:
        knative-serving/knative-ingress-gateway
    Retries:
    Rewrite:
      Authority:  ebs-app.default.svc.cluster.local
    Route:
      Destination:
        Host:  ebs-app.default.svc.cluster.local
        Port:
          Number:  80
      Headers:
        Request:
          Set:
            K - Original - Host:  www.kt.com
      Weight:                     100
Events:                           <none>
[root@master knative]# k get svc
NAME                    TYPE           CLUSTER-IP       EXTERNAL-IP                                            PORT(S)                                              AGE
ebs-app                 ExternalName   <none>           knative-local-gateway.istio-system.svc.cluster.local   80/TCP                                               94m
ebs-app-00001           ClusterIP      10.109.151.133   <none>                                                 80/TCP,443/TCP                                       159m
ebs-app-00001-private   ClusterIP      10.103.39.30     <none>                                                 80/TCP,443/TCP,9090/TCP,9091/TCP,8022/TCP,8012/TCP   159m
kubernetes              ClusterIP      10.96.0.1        <none>                                                 443/TCP                                              18d
[root@master knative]#

Question

  1. Since the Virtual Service created due to domain mapping is defined to route to ebs-app Service (External Name) and the name points to knative-local-gateway, it is natural that packets do not reach the application normally. I don't know if this is a current bug or something the Knative developers intended. I don't understand why dynamic routing is set to ebs-app rather than service (ebs-app-0001).
  2. If that was intentional, how do I route it to the application service(ebs-app-0001)? Virtual Service created with knative cannot be changed with edit. Because it will be restored to its original state.

I'm sorry I'm not good at English. I hope you understand my question.

0

There are 0 answers