How to enable http2/grpc on port 80 (i.e. without TLS) with nginx ingress?

5/7/2021

As per these two issues on ingress-nginx Github, it seems that the only way to get grpc/http2 working on port 80 without TLS is by using a custom config template:

  1. ingress does not supporting http2 at port 80 without tls #6313
  2. Add new annotation to support listen 80 http2 #6736

Unfortunately I could not find any straightforward examples on how to set-up a custom nginx-ingress config. Here are the links I tried:

  1. Custom NGINX template
  2. Custom Templates

Can anyone help me with the exact steps and config on how to get grpc/http2 working with nginx-ingress on port 80 without TLS?

-- Saurabh Nanda
grpc
http2
kubernetes
nginx
nginx-ingress

1 Answer

5/17/2021

This is a community wiki answer posted for better visibility. Feel free to expand it.

As already mentioned in the comments, the steps to make it work are as follows:

  1. Launch a separate nginx controller in an empty namespace to avoid issues with the main controller.

  2. Create custom templates, using these as a reference.

  3. Put them in a ConfigMap like this.

  4. Mount the templates into the controller pod as in this example.

-- WytrzymaƂy Wiktor
Source: StackOverflow