github.com/jingruilea/kubeedge@v1.2.0-beta.0.0.20200410162146-4bb8902b3879/docs/modules/cloud/cloudhub.md (about) 1 # CloudHub 2 3 ## CloudHub Overview 4 5 CloudHub is one module of cloudcore and is the mediator between Controllers and the Edge side. It supports both web-socket based connection as well as a [QUIC](https://quicwg.org/ops-drafts/draft-ietf-quic-applicability.html) protocol access at the same time. 6 The edgehub can choose one of the protocols to access to the cloudhub. CloudHub's function is to enable the communication between edge and the Controllers. 7 8 The connection to the edge(through EdgeHub module) is done through the HTTP over websocket connection. 9 For internal communication it directly communicates with the Controllers. 10 All the request send to CloudHub are of context object which are stored in channelQ along with the 11 mapped channels of event object marked to its nodeID. 12 13 14 The main functions performed by CloudHub are :- 15 16 - Get message context and create ChannelQ for events 17 - Create http connection over websocket 18 - Serve websocket connection 19 - Read message from edge 20 - Write message to edge 21 - Publish message to Controller 22 23 24 ### Get message context and create ChannelQ for events: 25 26 The context object is stored in a channelQ. 27 For all nodeID channel is created and the message is converted to event object 28 Event object is then passed through the channel. 29 30 ### Create http connection over websocket: 31 32 - TLS certificates are loaded through the path provided in the context object 33 - HTTP server is started with TLS configurations 34 - Then HTTP connection is upgraded to websocket connection receiving conn object. 35 - ServeConn function the serves all the incoming connections 36 37 ### Read message from edge: 38 39 - First a deadline is set for keepalive interval 40 - Then the JSON message from connection is read 41 - After that Message Router details are set 42 - Message is then converted to event object for cloud internal communication 43 - In the end the event is published to Controllers 44 45 ### Write Message to Edge: 46 47 - First all event objects are received for the given nodeID 48 - The existence of same request and the liveness of the node is checked 49 - The event object is converted to message structure 50 - Write deadline is set. Then the message is passed to the websocket connection 51 52 ### Publish Message to Controllers: 53 54 - A default message with timestamp, clientID and event type is sent to controller 55 every time a request is made to websocket connection 56 - If the node gets disconnected then error is thrown and an event describing 57 node failure is published to the controller. 58 59 ## Usage 60 61 The CloudHub can be configured in three ways as mentioned below : 62 63 - **Start the websocket server only**: Click [here](https://github.com/kubeedge/kubeedge/blob/master/docs/proposals/quic-design.md#start-the-websocket-server-only) to see the details. 64 - **Start the quic server only**: Click [here](https://github.com/kubeedge/kubeedge/blob/master/docs/proposals/quic-design.md#start-the-quic-server-only) to see the details. 65 - **Start the websocket and quic server at the same time**: Click [here](https://github.com/kubeedge/kubeedge/blob/master/docs/proposals/quic-design.md#start-the-quic-server-only) to see the details