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
- Install Apisix with helm chart
- configure an internal service
- configure an external service
- create a HTTPRoute config for the internal service
- create a HTTPRoute config for the external service
- specify "appProtocol: kubernetes.io/ws" in both services
- kubectl apply both services and routes
- observe the Kubernetes resources get created correctly
- establish a web socket connection to the internal service and observe the connection gets established
- 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
Current Behavior
A configured HTTPRoute pointing to an internal service can be configured with
appProtocol: kubernetes.io/ws. However, if the service is of typeExternalNamethe same setting gets applied by Kubernetes but not read by the Apisix controller.This seems to be due to this code:
apisix-ingress-controller/internal/adc/translator/httproute.go
Lines 420 to 446 in 11635a1
Expected Behavior
I expect the appProtocol to be read from both internal end external services.
Error Logs
No response
Steps to Reproduce
Environment