An “environment” in the API is referred to as a stack in the UI and the Rancher documentation. In the API documentation, we’ll use the UI terminology. A Rancher stack mirrors the same concept as a docker-compose project. It represents a group of services that make up a typical application or workload.
| Field | Type | Create | Update | Default | Notes |
|---|---|---|---|---|---|
| description | string | Optional | Yes | - | |
| dockerCompose | string | Optional | - | - | |
| environment | map[string] | Optional | - | - | |
| externalId | string | Optional | Yes | - | |
| name | string | Yes | Yes | - | |
| outputs | map[string] | Optional | Yes | - | |
| previousEnvironment | map[string] | Optional | Yes | - | |
| previousExternalId | string | Optional | Yes | - | |
| rancherCompose | string | Optional | - | - | |
| startOnCreate | boolean | Optional | - | - |
| Field | Type | Notes |
|---|---|---|
| healthState | string | |
| id | int | The unique identifier for the environment |
Please read more about the common resource fields. These fields are read only and applicable to almost every resource. We have segregated them from the list above.
CreatePOST: /v1/environments
curl -u "${RANCHER_ACCESS_KEY}:${RANCHER_SECRET_KEY}" \
-X POST \
-H 'Content-Type: application/json' \
-d '{
"description": "string",
"dockerCompose": "string",
"environment": {
"key": "value-pairs"
},
"externalId": "string",
"name": "string",
"outputs": {
"key": "value-pairs"
},
"previousEnvironment": {
"key": "value-pairs"
},
"previousExternalId": "string",
"rancherCompose": "string",
"startOnCreate": false
}' 'http://${RANCHER_URL}:8080/v1/environments'
DeleteDELETE: /v1/environments/${ID}
curl -u "${RANCHER_ACCESS_KEY}:${RANCHER_SECRET_KEY}" \
-X DELETE \
'http://${RANCHER_URL}:8080/v1/environments/${ID}'
UpdatePUT: /v1/environments/${ID}
curl -u "${RANCHER_ACCESS_KEY}:${RANCHER_SECRET_KEY}" \
-X PUT \
-H 'Content-Type: application/json' \
-d '{
"description": "string",
"externalId": "string",
"name": "string",
"outputs": {
"key": "value-pairs"
},
"previousEnvironment": {
"key": "value-pairs"
},
"previousExternalId": "string"
}' 'http://${RANCHER_URL}:8080/v1/environments/${ID}'
activateservices
POST: /v1/environments/${ID}?action=activateservices
Input:This action has no inputs
curl -u "${RANCHER_ACCESS_KEY}:${RANCHER_SECRET_KEY}" \
-X POST \
'http://${RANCHER_URL}:8080/v1/environments/${ID}?action=activateservices'
Output: An updated copy of the environment resource
cancelrollback
POST: /v1/environments/${ID}?action=cancelrollback
Input:This action has no inputs
curl -u "${RANCHER_ACCESS_KEY}:${RANCHER_SECRET_KEY}" \
-X POST \
'http://${RANCHER_URL}:8080/v1/environments/${ID}?action=cancelrollback'
Output: An updated copy of the environment resource
cancelupgrade
POST: /v1/environments/${ID}?action=cancelupgrade
Input:This action has no inputs
curl -u "${RANCHER_ACCESS_KEY}:${RANCHER_SECRET_KEY}" \
-X POST \
'http://${RANCHER_URL}:8080/v1/environments/${ID}?action=cancelupgrade'
Output: An updated copy of the environment resource
deactivateservices
POST: /v1/environments/${ID}?action=deactivateservices
Input:This action has no inputs
curl -u "${RANCHER_ACCESS_KEY}:${RANCHER_SECRET_KEY}" \
-X POST \
'http://${RANCHER_URL}:8080/v1/environments/${ID}?action=deactivateservices'
Output: An updated copy of the environment resource
exportconfig
POST: /v1/environments/${ID}?action=exportconfig
Input: ComposeConfigInput
| Field | Type | Required | Default | Notes |
|---|---|---|---|---|
| serviceIds | array[service] | No |
curl -u "${RANCHER_ACCESS_KEY}:${RANCHER_SECRET_KEY}" \
-X POST \
-H 'Content-Type: application/json' \
-d '{
"serviceIds": "array[reference[service]]"
}' 'http://${RANCHER_URL}:8080/v1/environments/${ID}?action=exportconfig'
Output: An updated copy of the composeConfig resource
finishupgrade
POST: /v1/environments/${ID}?action=finishupgrade
Input:This action has no inputs
curl -u "${RANCHER_ACCESS_KEY}:${RANCHER_SECRET_KEY}" \
-X POST \
'http://${RANCHER_URL}:8080/v1/environments/${ID}?action=finishupgrade'
Output: An updated copy of the environment resource
rollback
POST: /v1/environments/${ID}?action=rollback
Input:This action has no inputs
curl -u "${RANCHER_ACCESS_KEY}:${RANCHER_SECRET_KEY}" \
-X POST \
'http://${RANCHER_URL}:8080/v1/environments/${ID}?action=rollback'
Output: An updated copy of the environment resource