In the ‘cattle’ repo, under the ‘examples’ folder is an example of a rancher agent written in shell script. My questions:
Is this example still relevant (ie works) with latest Rancher releases
Can you provide a brief explanation of how the Rancher Host Agent - communicates with the Rancher Master when executing container/stack actions. It looks like it is all done over permanent WebSocket connections, but I am not sure if the websockets are only used for the the Rancher UI to Rancher Host interactions, such as logs, exec, performance, etc.
I don’t think that hypervisor.sh example is relevant anymore. I should probably delete it. Agents subscribe to event from the server through a persistent websocket connection but reply through doing HTTP POST back to the server.
On each node there are two key processes running, python-agent and host-api. python-agent does request/reply to handle most operations like starting/stopping containers. host-api is used when we want a direct connection to the node to do things like get stats, exec a shell, get raw access to the docker socket. That is accomplished by host-api keeping a persistent websocket connection open to the rancher server. The client will make a connection to the rancher server that then tunnels back to the node through the persistent websocket connection.
Is it possible to make a distinction between an Agent that is a ‘true infra host’ - ie sits in front of some controller like Docker - vs an Agent that is just listening to Rancher ‘traffic’ for existing hosts. If so how can this be achieved and can it be done with the existing python agent codebase