You can do all of this in a single node if you want to. Or, as many nodes do, you can use a configuration node to hold the connection which can then be consumed in multiple node instances. Check out the TCP and MQTT nodes for example.
Typically, a node needing an external persistent connection need do nothing special to keep the connection but does need to handle the (re)deploy and removal from the flow cases. This is done using the close event.
Looking at the code in some of the existing nodes will help you understand better. There is, of course, also documentation about handling the close event in the docs.
OK, I didn't pick up on that. No, config nodes are for when you want the admin of the system to enter the configuration. If you want that to be dynamic, you will need a different way. In that case, you would generally want to allow the configuration to be changed by a suitable incoming msg. On such a message being received, your node would need to close the existing connection (if it was a change rather than a new one) and create the new connection. It would also need to keep a record of the new connection so that you can also close them in the close function.