Automate Jira DC Zero Downtime Upgrade

I am planning to automate Jira and Confluence DC zero downtime upgrade.

Looking for suggestions. I am mostly curious on how to assign a node into upgrade mode from a terminal. cli instead of doing it over UI. May be there is an API call that can do it?

Any hint/suggestion is appreciated