Node and Cluster

Node Management

GET /api/v1/node

List machines in cluster

Request JSON Object:
 
  • labels (array) – query node matching labels
  • role (array) – query node matching role
  • state (array) – query node matching state
Response JSON Object:
 
  • name (string) – node’s name that case-insensitive, unique and in pattern of [a-z0-9-_]+
  • ip (string) – node’s IP
  • port (int) – node’s port
  • state (string) – alive, failed
  • role (string) – leader, follower, client
  • labels (array) – compute, storage, election
  • compute (object) – TBD. Swarm inforamtion showing on UI
  • storage (object) – TBD. Ceph inforamtion showing on UI

Example request

$ curl -sq -XGET -b cookies.txt \
    http://${QIP}:${QPORT}/containerstation/api/v1/node

Example response

[
    {"id": "eca0338f4ea31566",
     "name": "member-a",
     "ip": "192.168.0.10",
     "port": 8080,
     "state": "active",
     "role": "leader",
     "label": ["compute", "election"],
     "compute": {"loading": [0.3, 0.5, 0.3]}
    }
]
GET /api/v1/node

List machines in the same network

Parameters:
  • actionscan

Example request

$ curl -sq -XGET -b cookies.txt \
    "http://${QIP}:${QPORT}/containerstation/api/v1/node?action=scan"

Example response

[
    {"name": "member-A",
     "ip": "192.168.0.10",
     "port": 8080,
     "container-station": true
    }
    {"name": "member-B",
     "ip": "192.168.0.11",
     "port": 8080,
     "container-station": false
    }
]
GET /api/v1/node/(string: node_id)

Get node information

Response JSON Object:
 
  • container (array) – containers under this node

Refer to GET /api/v1/node for others parameters.

Example request

$ curl -sq -XGET -b cookies.txt \
    http://${QIP}:${QPORT}/containerstation/api/v1/node/eca0338f4ea31566

Example response

{"id": "eca0338f4ea31566",
 "name": "member-a",
 "ip": "192.168.0.10",
 "port": 8080,
 "state": "active",
 "role": "leader",
 "label": ["compute", "election", "arch=x86"],
 "compute": {"loading": [0.3, 0.5, 0.3]},
 "container": [{"id": "de1abdef23213", "name": "web1", "state": "running"}]
}
POST /api/v1/node

Create a new node

Refer to GET /api/v1/node for others parameters.

Example request

$ curl -sq -XPOST -b cookies.txt -d \
    '{"name": "member-a",
      "ip": "192.168.0.10",
      "port": 8080,
      "password": "aaabbbccc",
      "label": ["compute", "election", "arch=x86"],
    }' http://${QIP}:${QPORT}/containerstation/api/v1/node

Example response

{"id": "eca0338f4ea31566",
 "name": "member-a",
 "ip": "192.168.0.10",
 "port": 8080,
 "state": "active",
 "role": "leader",
 "label": ["compute", "election", "arch=x86"],
 "compute": {"loading": [0.3, 0.5, 0.3]}
}
DELETE /api/v1/node/(string: node_id)

Delete a node

Response JSON Object:
 
  • id (array) – nodes to be deleted

Example request

$ curl -sq -XGET -b cookies.txt \
    http://${QIP}:${QPORT}/containerstation/api/v1/node/eca0338f4ea31566

Example response

[1]
PUT /api/v1/node/(string: node_id)

Update node that only change the keys are given.

It returns GET /api/v1/node/(string:node_id) refering to GET /api/v1/node for others parameters.

Example request

$ curl -sq -XPUT -b cookies.txt -d \
    '{"name": "member-a",
      "ip": "192.168.0.10",
      "port": 8080,
      "label": ["compute", "election", "arch=x86"],
    }' http://${QIP}:${QPORT}/containerstation/api/v1/node/eca0338f4ea31566

Example response

{"id": "eca0338f4ea31566",
 "name": "member-a",
 "ip": "192.168.0.10",
 "port": 8080,
 "state": "active",
 "role": "leader",
 "label": ["compute", "election", "arch=x86"],
 "compute": {"loading": [0.3, 0.5, 0.3]}
}

Cluster App Management

This section refer design Template and Marathon: REST API. UI may refer to FleetUI

Cluster application distribute Docker containers across nodes according to definition of request.

The control of cluster application will follow signle node design as following,

TBD:

  • name conflict
  • non-stop upgrade
  • fixed ip and dns
POST /api/v1/cluster-apps

Create and start containers.

Request JSON Object:
 
  • deployment (object) –
  • scale (int) –
  • node (string) –
  • label (array) –

Example request

$ curl -sq -XPOST -b cookies.txt -d \
    '{
        "name": "redmine-app",
        "deployment": {
            "postgresql": {"scale": 2,
                           "node": ["aaaa", "bbbb", "cccc"]}
        },
        "definition": {
            "postgresql": {
                "label": ["arch=x86"],
                "environment": [
                    "DB_USER=redmine",
                    "DB_PASS=redminewooo",
                    "DB_NAME=myredmine",
                    "constraint:operatingsystem=qts",
                    "constraint:environment=production",
                    "affinity:image==postgresql"
                ],
                "image": "sameersbn/postgresql:9.4-2"
            },
            "redmine": {
                "label": ["arch=x86"],
                "environment": [
                    "DB_USER=redmine",
                    "DB_PASS=redminewooo",
                    "DB_NAME=myredmine"
                ],
                "image": "sameersbn/redmine:3.1.0",
                "links": [
                    "postgresql:postgresql"
                ],
                "ports": [
                    "22234:80"
                ],
            }
        }
    }' http://${QIP}:${QPORT}/containerstation/api/v1/apps

Example response

{
    "name": "redmine-app",
    "deployment": {
        "postgresql": {"scale": 2,
                        "node": ["aaaa", "bbbb", "cccc"]}
    },
    "definition": {
        "postgresql": {
            "label": ["arch=x86"],
            "environment": [
                "DB_USER=redmine",
                "DB_PASS=redminewooo",
                "DB_NAME=myredmine",
                "constraint:operatingsystem=qts",
                "constraint:environment=production",
                "affinity:image==postgresql"
            ],
            "image": "sameersbn/postgresql:9.4-2"
        },
        "redmine": {
            "label": ["arch=x86"],
            "environment": [
                "DB_USER=redmine",
                "DB_PASS=redminewooo",
                "DB_NAME=myredmine"
            ],
            "image": "sameersbn/redmine:3.1.0",
            "links": [
                "postgresql:postgresql"
            ],
            "ports": [
                "22234:80"
            ]
        }
    }
}
GET /api/v1/cluster-apps

List cluster application

PUT /api/v1/cluster-apps

Modify cluster application

DELETE /api/v1/cluster-apps

Delete cluster application

Storage Management

TBD. Read ceph document first.

Network Management

GET /api/v1/cluster-preference

Keys:

  • floating-ip-pool
  • floating-ip-leader

Image Management

Support private registry for image cache