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

make /api/ h2c compatible #590

Merged
merged 1 commit into from
Jul 24, 2023
Merged

make /api/ h2c compatible #590

merged 1 commit into from
Jul 24, 2023

Conversation

therealak12
Copy link
Contributor

This pull request tries to solve issue#452.

Based on envoy docs the gprc-web filter just translates grpc-web sent over HTTP/1.1 to the same format over HTTP/2.

As grpc-web uses GRPC format (not for example JSON format used by grpc-gateway), making the API compatible with HTTP/2 should be enough to solve the issue.

The h2c.NewHandler would handle h2c requests and simply forward HTTP/1.1 requests to the wrapped http.Handler.

The code should work with an HTTPProxy object of Contour with the following spec:

apiVersion: projectcontour.io/v1
kind: HTTPProxy
metadata:
  name: hubble-ui
  namespace: cilium-system
spec:
  routes:
  - conditions:
    - prefix: /api/
    enableWebsockets: true
    services:
    - name: hubble-ui-grpc
      port: 80
      protocol: h2c
  - enableWebsockets: true
    services:
    - name: hubble-ui
      port: 80
  virtualhost:
    fqdn: sample.example.com

The hubble-ui-grpc service referenced above is a service that targets the backend ports of hubble-ui pods. It may look like this:

apiVersion: v1
kind: Service
metadata:
  name: hubble-ui-grpc
  namespace: cilium-system
spec:
  ports:
  - name: grpc
    port: 80
    protocol: TCP
    targetPort: 8090
  selector:
    k8s-app: hubble-ui
  type: ClusterIP

@therealak12 therealak12 requested a review from a team as a code owner July 21, 2023 20:11
@therealak12 therealak12 requested review from yandzee and removed request for a team July 21, 2023 20:11
@geakstr
Copy link
Collaborator

geakstr commented Jul 24, 2023

Thanks!

@geakstr geakstr merged commit 4b35b3d into cilium:master Jul 24, 2023
8 checks passed
@vflaux
Copy link

vflaux commented Aug 3, 2023

Hi,

I can confirm that it fixes the issue #452, so thank you!

I also had to increase the default timeout of envoy which is 15s as it causes frequent disconnection/reconnection error messages :

spec:
  routes:
  - timeoutPolicy:
      response: 1h

So with your example:

apiVersion: projectcontour.io/v1
kind: HTTPProxy
metadata:
  name: hubble-ui
  namespace: cilium-system
spec:
  routes:
  - conditions:
    - prefix: /api/
    enableWebsockets: true
    services:
    - name: hubble-ui-grpc
      port: 80
      protocol: h2c
    timeoutPolicy:
      response: 1h
  - enableWebsockets: true
    services:
    - name: hubble-ui
      port: 80
  virtualhost:
    fqdn: sample.example.com

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants