In this use case, you add a third container to the new deployment.
Notes:
-
This topic shows how to use cURL and the REST API to perform a specific use case. For more information about cURL, see Use cURL
-
The commands in this topic use the URL structure https://rest_server_url/resource-path, where rest_server_url is the Oracle Public Cloud or Oracle Cloud Machine REST server to contact for your identity domain or tenant name. See Send Requests for the appropriate URL structure to use for Oracle Public Cloud.
- Create a JSON file called
scale_deployment.json that defines two redis-slave containers.
For example:
{
"deployment_id":"Redis-Cluster-20161102-211246",
"deployment_name":"Redis Cluster",
"desired_state":1,
"placement":{"pool_id":"default"},
"quantities":{"redis-master":1,"redis-slave":2},
"stack":{"content":"version: 2\nservices:\n redis-master:\n image: \"redis:3.2.1-alpine\"\n ports:\n - \"6379:6379/tcp\"\n environment:\n - OCCS_PHASE_ID=0\n - CMD_INFO=redis-cli -p 6379 -a mypass info replication\n - SETUP_MASTER=requirepass mypass\n - \"occs:availability=per-tag\"\n - \"occs:availability_context=master\"\n - \"occs:scheduler=random\"\n - \"occs:description=This is a clustered Redis master-slave stack. This stack depends on the user tagging the master host with master and slaves as slave. Because this service has a static host-bound port, only one deployment can be done per host without getting port conflicts. This example is provided as-is for educational purposes and should not be used in production.\"\n - \"OCCS_HEALTHCHECK_REDIS=tcp://:6379/?timeout=10s&interval=30s\"\n command: \"sh -c \\\"echo $SETUP_MASTER >/tmp/redis.conf; redis-server /tmp/redis.conf\\\"\"\n redis-slave:\n image: \"redis:3.2.1-alpine\"\n ports:\n - \"6379:6379/tcp\"\n environment:\n - OCCS_PHASE_ID=1\n - CMD_INFO=redis-cli -p 6379 -a mypass info replication\n - \"SETUP_SLAVE=slaveof $(echo {{ proxy \\\"redis-master:6379\\\" }} | tr \\\":\\\" \\\" \\\" )\"\n - SETUP_PASS=masterauth mypass\n - \"SETUP=(eval echo $SETUP_SLAVE; echo $SETUP_PASS)>/tmp/redis.conf\"\n - \"occs:availability=per-tag\"\n - \"occs:availability_context=slave\"\n - \"occs:scheduler=random\"\n - \"occs:description=Because this service has a static host-bound port, only one deployment can be done per host without getting port conflicts. This example is provided as-is for educational purposes and should not be used in production.\"\n - \"OCCS_HEALTHCHECK_REDIS=tcp://:6379/?timeout=10s&interval=30s\"\n command: \"sh -c \\\"eval $SETUP; cat /tmp/redis.conf; redis-server /tmp/redis.conf\\\"\"\n",
"service_id":"Redis-Cluster",
"service_name":"Redis Cluster",
"subtype":"stack"}}
- Submit the following PUT method using the
/v2/deployments/{deployment_id} endpoint.
For example:
curl -k
-X PUT -H "Authorization: Bearer e8c9254bb0220055"
"https://rest_server_url/api/v2/deployments/Redis-Cluster-20161102-211246"
-d @scale_deployment.json
- In the response body, verify that the quantities property is updated as you expected.