Skip to content

bug: HTTPRoute ignores appProtocol setting for ExternalName types #2793

@ronnybremer

Description

@ronnybremer

Current Behavior

A configured HTTPRoute pointing to an internal service can be configured with appProtocol: kubernetes.io/ws. However, if the service is of type ExternalName the same setting gets applied by Kubernetes but not read by the Apisix controller.
This seems to be due to this code:

if service.Spec.Type == corev1.ServiceTypeExternalName {
port := 80
if ref.Port != nil {
port = int(*ref.Port)
}
return adctypes.UpstreamNodes{
{
Host: service.Spec.ExternalName,
Port: port,
Weight: weight,
},
}, protocol, nil
}
var portName *string
if ref.Port != nil {
for _, p := range service.Spec.Ports {
if int(p.Port) == int(*ref.Port) {
portName = ptr.To(p.Name)
protocol = ptr.Deref(p.AppProtocol, "")
break
}
}
if portName == nil {
return adctypes.UpstreamNodes{}, protocol, nil
}
}

Expected Behavior

I expect the appProtocol to be read from both internal end external services.

Error Logs

No response

Steps to Reproduce

  1. Install Apisix with helm chart
  2. configure an internal service
  3. configure an external service
  4. create a HTTPRoute config for the internal service
  5. create a HTTPRoute config for the external service
  6. specify "appProtocol: kubernetes.io/ws" in both services
  7. kubectl apply both services and routes
  8. observe the Kubernetes resources get created correctly
  9. establish a web socket connection to the internal service and observe the connection gets established
  10. establish a web socket connection to the external service and observe the connection receiving an error due to the filtering of "connection: upgrade" form the request to the backend
---
apiVersion: v1
kind: Service
metadata:
  name: test-portal
spec:
  selector:
    app: test-portal
  ports:
    - protocol: TCP
      port: 5000
      targetPort: 5000
      appProtocol: kubernetes.io/ws
---
apiVersion: v1
kind: Service
metadata:
  name: test-portal-ext
spec:
  ports:
    - protocol: TCP
      port: 8000
      appProtocol: kubernetes.io/ws
  type: ExternalName
  externalName: testportal.dev.local

Environment

  • APISIX Ingress controller version: 2.1.0
  • Kubernetes cluster version: 1.35.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions