Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use gatewayapi to route websocket services #6678

Closed
Bryce-huang opened this issue Sep 19, 2024 · 2 comments
Closed

How to use gatewayapi to route websocket services #6678

Bryce-huang opened this issue Sep 19, 2024 · 2 comments
Labels
kind/question Categorizes an issue as a user question. lifecycle/needs-triage Indicates that an issue needs to be triaged by a project contributor.

Comments

@Bryce-huang
Copy link

What question do you have?:

websocket service is not working, following is my yaml file, if using httpproxy it works fine

Anything else you would like to add:
[Miscellaneous information that will assist in solving the issue.]

---
apiVersion: v1
kind: Service
metadata:
  name: mysvc
spec:
  ports:
  - name: http
    port: 80
    protocol: TCP
    appProtocol: kubernetes.io/ws
    targetPort: 8012
  - name: https
    port: 443
    protocol: TCP
    targetPort: 8112
    appProtocol: kubernetes.io/ws
  sessionAffinity: None
  type: ClusterIP

---

apiVersion: v1
kind: Endpoints
metadata:
  name: mysvc
subsets:
- addresses:
  - ip: 10.244.0.42
    nodeName: minikube
    targetRef:
      kind: Pod
      name: activator-567c684888-82226
      namespace: knative-serving
      uid: 8991fec0-d258-4b5b-a4f2-ae1a42a6db74
  ports:
  - name: http
    port: 8012
    protocol: TCP
    appProtocol: kubernetes.io/ws
  - name: https
    appProtocol: kubernetes.io/ws
    port: 8112
    protocol: TCP
---
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
  name: vscode-route
spec:
  parentRefs:
  - name: contour
    namespace: contour-external
  hostnames:
  - "code-server.com"
  rules:
    - matches:
        - path:
            type: PathPrefix
            value: /
      filters:
        - type: RequestHeaderModifier
          requestHeaderModifier:
            add:
              - name: host
                value: code-server-00002.default.svc.cluster.local
      backendRefs:
        - name: mysvc
          port: 80

Environment:

  • Contour version: 1.30.0
  • Kubernetes version: (use kubectl version): v1.30.0
  • Kubernetes installer & version:
  • Cloud provider or hardware configuration:
  • OS (e.g. from /etc/os-release):
@Bryce-huang Bryce-huang added kind/question Categorizes an issue as a user question. lifecycle/needs-triage Indicates that an issue needs to be triaged by a project contributor. labels Sep 19, 2024
@Bryce-huang
Copy link
Author

area/gateway-api

@Bryce-huang
Copy link
Author

I noticed this sentence: If you are using Gateway API, websockets are enabled by default at the Listener level. But it doesn't seem to work for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/question Categorizes an issue as a user question. lifecycle/needs-triage Indicates that an issue needs to be triaged by a project contributor.
Projects
None yet
Development

No branches or pull requests

1 participant