There are times that you may want to programmatically start or stop a cluster. This is often the case when you have periodic data loads, and you do not want to have a cluster running 24/7. In these situations, we can use the API to start or stop a cluster. To build the API request we will need three things:
- An API Token
- The API server endpoint
- The Cluster ID
Generating an API token
An API token can be generated either via API or via the UI by selecting API Tokens from the MORE menu.
After you click Generate you will receive an API token
Determining your API server hostname
The API server can be found from the Clusters tab. After selecting the API cluster, you can copy the endpoint.
Determining your Cluster identifier
The cluster id can be found in the URL of the cluster page
Stopping a Cluster
Now we put together the API server, Auth token, and the Cluster id into a PUT request to stop the cluster
## Stop Cluster
curl -X "PUT" "https://api-<your api server>.upsolver.com/environments/stop/<your cluster id>" \
-H 'Authorization: <your auth token>'
Running a Cluster
Just like stopping it, we use the same components to start
## Run Cluster
curl -X "PUT" "https://api-<your api server>.upsolver.com/environments/run/<your cluster id>" \
-H 'Authorization: <your auth token>'
Comments
0 comments
Article is closed for comments.