Rancher adopts the standard Docker Compose terminology for services and defines a basic service as one or more containers created from the same Docker image. Once a service (consumer) is linked to another service (producer) within the same stack, a DNS record mapped to each container instance is automatically created and discoverable by containers from the “consuming” service. Other benefits of creating a service under Rancher include”
| Field | Type | Create | Update | Default | Notes |
|---|---|---|---|---|---|
| assignServiceIpAddress | boolean | Optional | - | - | |
| description | string | Optional | Yes | - | |
| environmentId | environment | Yes | - | - | |
| externalId | string | Optional | - | - | |
| launchConfig | launchConfig | Optional | - | - | |
| metadata | map[json] | Optional | Yes | - | |
| name | string | Yes | Yes | - | |
| retainIp | boolean | Optional | Yes | - | |
| scale | int | Optional | Yes | 1 | |
| scalePolicy | scalePolicy | Optional | Yes | - | |
| secondaryLaunchConfigs | array[secondaryLaunchConfig] | Optional | - | - | |
| selectorContainer | string | Optional | Yes | - | |
| selectorLink | string | Optional | Yes | - | |
| startOnCreate | boolean | Optional | - | - | |
| vip | string | Optional | - | - |
| Field | Type | Notes |
|---|---|---|
| createIndex | int | |
| currentScale | int | |
| data | map[json] | |
| fqdn | string | |
| healthState | string | |
| id | int | The unique identifier for the service |
| publicEndpoints | array[publicEndpoint] | |
| upgrade | serviceUpgrade |
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.
/v1/projects/${PROJECT_ID}/services/${ID}?action=activate
curl -u "${RANCHER_ACCESS_KEY}:${RANCHER_SECRET_KEY}" \
-X POST \
'http://${RANCHER_URL}:8080/v1/projects/${PROJECT_ID}/services/${ID}?action=activate'/v1/projects/${PROJECT_ID}/services/${ID}?action=addservicelink
curl -u "${RANCHER_ACCESS_KEY}:${RANCHER_SECRET_KEY}" \
-X POST \
-H 'Content-Type: application/json' \
-d '{
"serviceLink": {
"name": "string",
"serviceId": "reference[service]",
"uuid": "string"
}
}' 'http://${RANCHER_URL}:8080/v1/projects/${PROJECT_ID}/services/${ID}?action=addservicelink'/v1/projects/${PROJECT_ID}/services/${ID}?action=cancelrollback
curl -u "${RANCHER_ACCESS_KEY}:${RANCHER_SECRET_KEY}" \
-X POST \
'http://${RANCHER_URL}:8080/v1/projects/${PROJECT_ID}/services/${ID}?action=cancelrollback'/v1/projects/${PROJECT_ID}/services/${ID}?action=cancelupgrade
curl -u "${RANCHER_ACCESS_KEY}:${RANCHER_SECRET_KEY}" \
-X POST \
'http://${RANCHER_URL}:8080/v1/projects/${PROJECT_ID}/services/${ID}?action=cancelupgrade'/v1/projects/${PROJECT_ID}/services/${ID}?action=deactivate
curl -u "${RANCHER_ACCESS_KEY}:${RANCHER_SECRET_KEY}" \
-X POST \
'http://${RANCHER_URL}:8080/v1/projects/${PROJECT_ID}/services/${ID}?action=deactivate'/v1/projects/${PROJECT_ID}/services/${ID}?action=finishupgrade
curl -u "${RANCHER_ACCESS_KEY}:${RANCHER_SECRET_KEY}" \
-X POST \
'http://${RANCHER_URL}:8080/v1/projects/${PROJECT_ID}/services/${ID}?action=finishupgrade'/v1/projects/${PROJECT_ID}/services/${ID}?action=removeservicelink
curl -u "${RANCHER_ACCESS_KEY}:${RANCHER_SECRET_KEY}" \
-X POST \
-H 'Content-Type: application/json' \
-d '{
"serviceLink": {
"name": "string",
"serviceId": "reference[service]",
"uuid": "string"
}
}' 'http://${RANCHER_URL}:8080/v1/projects/${PROJECT_ID}/services/${ID}?action=removeservicelink'/v1/projects/${PROJECT_ID}/services/${ID}?action=restart
curl -u "${RANCHER_ACCESS_KEY}:${RANCHER_SECRET_KEY}" \
-X POST \
-H 'Content-Type: application/json' \
-d '{
"rollingRestartStrategy": {
"batchSize": 1,
"intervalMillis": 2000
}
}' 'http://${RANCHER_URL}:8080/v1/projects/${PROJECT_ID}/services/${ID}?action=restart'/v1/projects/${PROJECT_ID}/services/${ID}?action=rollback
curl -u "${RANCHER_ACCESS_KEY}:${RANCHER_SECRET_KEY}" \
-X POST \
'http://${RANCHER_URL}:8080/v1/projects/${PROJECT_ID}/services/${ID}?action=rollback'/v1/projects/${PROJECT_ID}/services/${ID}?action=setservicelinks
curl -u "${RANCHER_ACCESS_KEY}:${RANCHER_SECRET_KEY}" \
-X POST \
-H 'Content-Type: application/json' \
-d '{
"serviceLinks": "array[serviceLink]"
}' 'http://${RANCHER_URL}:8080/v1/projects/${PROJECT_ID}/services/${ID}?action=setservicelinks'/v1/projects/${PROJECT_ID}/services/${ID}?action=upgrade
curl -u "${RANCHER_ACCESS_KEY}:${RANCHER_SECRET_KEY}" \
-X POST \
-H 'Content-Type: application/json' \
-d '{
"inServiceStrategy": {
"batchSize": 1,
"intervalMillis": 2000,
"launchConfig": {
"accountId": "reference[account]",
"agentId": "reference[agent]",
"allocationState": "string",
"blkioDeviceOptions": "map[blkioDeviceOption]",
"build": {
"context": "string",
"dockerfile": "string",
"forcerm": false,
"nocache": false,
"remote": "string",
"rm": false
},
"capAdd": "array[enum]",
"capDrop": "array[enum]",
"command": [
"string1",
"...stringN"
],
"count": 0,
"cpuSet": "string",
"cpuShares": 0,
"createIndex": 0,
"created": "date",
"data": {
"key": "value-pairs"
},
"dataVolumeMounts": "map[reference[volume]]",
"dataVolumes": [
"string1",
"...stringN"
],
"dataVolumesFrom": "array[reference[container]]",
"dataVolumesFromLaunchConfigs": [
"string1",
"...stringN"
],
"deploymentUnitUuid": "string",
"description": "string",
"devices": [
"string1",
"...stringN"
],
"disks": "array[virtualMachineDisk]",
"dns": [
"string1",
"...stringN"
],
"dnsSearch": [
"string1",
"...stringN"
],
"domainName": "string",
"entryPoint": [
"string1",
"...stringN"
],
"environment": {
"key": "value-pairs"
},
"expose": [
"string1",
"...stringN"
],
"externalId": "string",
"extraHosts": [
"string1",
"...stringN"
],
"firstRunning": "date",
"healthCheck": {
"healthyThreshold": 0,
"initializingTimeout": 0,
"interval": 0,
"name": "string",
"port": 0,
"recreateOnQuorumStrategyConfig": {
"quorum": 0
},
"reinitializingTimeout": 0,
"requestLine": "string",
"responseTimeout": 0,
"strategy": "recreate",
"unhealthyThreshold": 0
},
"healthState": "enum",
"hostId": "reference[host]",
"hostname": "string",
"id": 0,
"imageUuid": "string",
"instanceLinks": "map[reference[instance]]",
"kind": "container",
"labels": {
"key": "value-pairs"
},
"logConfig": {
"config": {
"key": "value-pairs"
},
"driver": "string"
},
"lxcConf": {
"key": "value-pairs"
},
"memory": 0,
"memoryMb": 0,
"memorySwap": 0,
"nativeContainer": false,
"networkContainerId": "reference[container]",
"networkIds": "array[reference[network]]",
"networkLaunchConfig": "string",
"networkMode": "managed",
"pidMode": "enum",
"ports": [
"string1",
"...stringN"
],
"primaryIpAddress": "string",
"privileged": false,
"publishAllPorts": false,
"readOnly": false,
"registryCredentialId": "reference[registryCredential]",
"removeTime": "date",
"removed": "date",
"requestedHostId": "reference[host]",
"requestedIpAddress": "string",
"securityOpt": [
"string1",
"...stringN"
],
"startCount": 0,
"startOnCreate": true,
"state": "enum",
"stdinOpen": false,
"systemContainer": "enum",
"token": "string",
"transitioning": "enum",
"transitioningMessage": "string",
"transitioningProgress": 0,
"tty": false,
"user": "string",
"userdata": "string",
"uuid": "string",
"vcpu": 1,
"version": "0",
"volumeDriver": "string",
"workingDir": "string"
},
"previousLaunchConfig": {
"accountId": "reference[account]",
"agentId": "reference[agent]",
"allocationState": "string",
"blkioDeviceOptions": "map[blkioDeviceOption]",
"build": {
"context": "string",
"dockerfile": "string",
"forcerm": false,
"nocache": false,
"remote": "string",
"rm": false
},
"capAdd": "array[enum]",
"capDrop": "array[enum]",
"command": [
"string1",
"...stringN"
],
"count": 0,
"cpuSet": "string",
"cpuShares": 0,
"createIndex": 0,
"created": "date",
"data": {
"key": "value-pairs"
},
"dataVolumeMounts": "map[reference[volume]]",
"dataVolumes": [
"string1",
"...stringN"
],
"dataVolumesFrom": "array[reference[container]]",
"dataVolumesFromLaunchConfigs": [
"string1",
"...stringN"
],
"deploymentUnitUuid": "string",
"description": "string",
"devices": [
"string1",
"...stringN"
],
"disks": "array[virtualMachineDisk]",
"dns": [
"string1",
"...stringN"
],
"dnsSearch": [
"string1",
"...stringN"
],
"domainName": "string",
"entryPoint": [
"string1",
"...stringN"
],
"environment": {
"key": "value-pairs"
},
"expose": [
"string1",
"...stringN"
],
"externalId": "string",
"extraHosts": [
"string1",
"...stringN"
],
"firstRunning": "date",
"healthCheck": {
"healthyThreshold": 0,
"initializingTimeout": 0,
"interval": 0,
"name": "string",
"port": 0,
"recreateOnQuorumStrategyConfig": {
"quorum": 0
},
"reinitializingTimeout": 0,
"requestLine": "string",
"responseTimeout": 0,
"strategy": "recreate",
"unhealthyThreshold": 0
},
"healthState": "enum",
"hostId": "reference[host]",
"hostname": "string",
"id": 0,
"imageUuid": "string",
"instanceLinks": "map[reference[instance]]",
"kind": "container",
"labels": {
"key": "value-pairs"
},
"logConfig": {
"config": {
"key": "value-pairs"
},
"driver": "string"
},
"lxcConf": {
"key": "value-pairs"
},
"memory": 0,
"memoryMb": 0,
"memorySwap": 0,
"nativeContainer": false,
"networkContainerId": "reference[container]",
"networkIds": "array[reference[network]]",
"networkLaunchConfig": "string",
"networkMode": "managed",
"pidMode": "enum",
"ports": [
"string1",
"...stringN"
],
"primaryIpAddress": "string",
"privileged": false,
"publishAllPorts": false,
"readOnly": false,
"registryCredentialId": "reference[registryCredential]",
"removeTime": "date",
"removed": "date",
"requestedHostId": "reference[host]",
"requestedIpAddress": "string",
"securityOpt": [
"string1",
"...stringN"
],
"startCount": 0,
"startOnCreate": true,
"state": "enum",
"stdinOpen": false,
"systemContainer": "enum",
"token": "string",
"transitioning": "enum",
"transitioningMessage": "string",
"transitioningProgress": 0,
"tty": false,
"user": "string",
"userdata": "string",
"uuid": "string",
"vcpu": 1,
"version": "0",
"volumeDriver": "string",
"workingDir": "string"
},
"previousSecondaryLaunchConfigs": "array[secondaryLaunchConfig]",
"secondaryLaunchConfigs": "array[secondaryLaunchConfig]",
"startFirst": false
},
"toServiceStrategy": {
"batchSize": 1,
"finalScale": 1,
"intervalMillis": 2000,
"toServiceId": "reference[service]",
"updateLinks": false
}
}' 'http://${RANCHER_URL}:8080/v1/projects/${PROJECT_ID}/services/${ID}?action=upgrade'