<div dir="ltr">Hey!<div><br></div><div>I started sketching some ideas how HTTP/2 client and the upgrade procedure could work in cloud environment. Before digging in, let me explain some basic concepts and facts:</div><div><ul><li>Kubernetes as well as OpenShift operate on a very simple architecture. We have a group of Pods (Docker Containers), a Service which acts as a load balancer and a Route (which acts as a proxy for serving requests to the outside world).</li><li>Communication between components deployed on the same Kubernetes/OpenShift cluster looks like this: MyApp -&gt; Service (target app) -&gt; one of the Pods</li><li>Communication from the outside world looks like this: MyApp -&gt; the Internet -&gt; Route (target app) -&gt; Service (target app) -&gt; one of the Pods [1]</li><li>Currently Kubernetes/OpenShift Services use round-robin strategy for load balancing, can use Client IP affinity or can use HTTP Cookies for session stickiness.</li><li>OpenShift Route (or Kubernetes Ingress) can support TLS. They can downgrade HTTPS to HTTP (in other words terminate it), pass through an encrypted request without inspecting the content or reencrypt it with different certificate [2].</li><li>HTTP/2 does not have upgrade header. It uses TLS with ALPN to negotiate which protocol should be used [3].</li><li>HTTP/2 can support custom protocols (which allows writing custom Frames, Settings and Error Codes) [4].</li></ul><div>The initial idea of using HTTP 1.1/Upgrade (as I mentioned above HTTP/2 doesn&#39;t have this concept, it uses ALPN) is to support Hot Rod Clients from the outside of the Kubernetes/OpenShift cluster. The client connects to a random Pod (through w Route) using HTTP Protocol and upgrades the connection to Hot Rod Protocol. </div></div><div><br></div><div>After thinking about it for a while, several things don&#39;t fit. A Hot Rod client uses topology information to minimize the amount of hops. When we access the data using a Route (or Ingress) and a Service we don&#39;t control to which Pod we&#39;re connecting to. Moreover, if we switch from HTTP to Hot Rod protocol (which is based on TCP), we lose HTTP Headers which could be possible used for routing inside Kubernetes/OpenShift. Switching protocols is also problematic since HTTP/2 does not support upgrade header (as I mentioned above - it uses ALPN). ALPN support needs to be implemented in Hot Rod Server (this is the only component which has enough data to say which protocols are supported; OpenShift Routes or Kunernetes Ingresses don&#39;t have this knowledge). This means that Routes and Services sees encrypted traffic and won&#39;t be able to help us with Routing.</div><div><br></div><div>So what can we do about it? There are a couple of ideas how to solve those problems.</div><div><br></div><div>The first one is to enhance the Hot Rod Client to initialize a connection pool. The client could periodically initialize a new connection and send PING operation. If the connection is already in the pool - close it. Otherwise add it to the pool. We can call it brute-force-cluster-discovery :) It should be good for any round-robin like load-balancers.</div><div><br></div><div>The second idea is to implement a fully fledged HTTP/2 client for Hot Rod (@Anton - I think you&#39;re working on that aren&#39;t you?). We could use HTTP Headers to control to which Pod we are connecting to (this would require adding some code to Kubernetes/OpenShift but it shouldn&#39;t be very hard). After TLS Handshake we could use topology information and HTTP Headers to initialize connection to all cluster members. In this scenario ALPN won&#39;t be needed (since we will implement separate server and client) which is firewall friendly (operates on HTTP/HTTPS ports).</div><div><br></div><div>Having in mind the raise of stateful apps in the cloud we could also propose PetSets enhancement and donate extra code for supporting them from Ingress/Route perspective. The result should be similar to the previous option (donating some code to Services/Ingresses and Routes). </div><div><br></div><div>The above are only some ideas how all the pieces could work together. I&#39;ll also consult it with the OpenShift Team - maybe they will give us some more hints.</div><div><br></div><div>Think about it for a while and let me know if you have any ideas...</div><div><br></div><div>Thanks</div><div>Sebastian</div><div><br></div><div>[0] <a href="https://issues.jboss.org/browse/ISPN-6676">https://issues.jboss.org/browse/ISPN-6676</a></div><div>[1] <a href="http://www.slideshare.net/SamuelTerburg/open-shift-enterprise-31-paas-on-kubernetes">http://www.slideshare.net/SamuelTerburg/open-shift-enterprise-31-paas-on-kubernetes</a></div><div>[2] <a href="https://docs.openshift.org/latest/architecture/core_concepts/routes.html#secured-routes">https://docs.openshift.org/latest/architecture/core_concepts/routes.html#secured-routes</a></div><div>[3] <a href="https://http2.github.io/http2-spec/#rfc.section.8.1.2.2">https://http2.github.io/http2-spec/#rfc.section.8.1.2.2</a></div><div>[4] <a href="https://http2.github.io/http2-spec/#rfc.section.5.5">https://http2.github.io/http2-spec/#rfc.section.5.5</a></div></div>