Gateway Keepalived Group

Create ‘keepalived group’

Description

create new keepalived group, each group has an uniq virtual IP (or virtual IPv6) for public service.

URI

POST /admin-api/gateway/{gateway_id}/virtual_groups

JSON body

  • name

    type: string

    required: yes

    description: name of the keepalived group

  • virtual_ip

    type: string

    required: yes

    description: virtual IP address of the keepalived group

  • virtual_ipv6

    type: string

    required: yes

    description: virtual ipv6 address of the keepalived group

  • status

    type: number

    required: no

    description: 0 stand for resolve DNS to this node and serve to the public, 1 stand for disable DNS resolve, 2 stand for offline.

  • is_healthy

    type: boolean

    required: no

    description: health statue of the virtual IP, if the value is true the virtual IP is served properly, or there is something wrong with the virtual IP.

  • router_id

    type: number

    required: no

    description: auto-generated ID, also referred to as virtual_router_id in the VRRP protocol

  • real_nodes

    type: array

    required: no

    description: real nodes of the keepalived group

  • real_nodes[*].node

    type: number

    required: yes

    description: the node id of the real node

  • real_nodes[*].status

    type: number

    required: no

    description: status of the real node, 1 stand for MASTER, 2 stand for BACKUP

  • real_nodes[*].keepalived_managed

    type: bool

    required: no

    description: Whether the node is managed by keepalived group.

  • real_nodes[*].interface

    type: string

    required: yes

    description: The network interface name of the real node, like eth1 / ens34

  • real_nodes[*].interval

    type: number

    required: no

    description: VRRP interval for sending broadcast / unicast.

  • real_nodes[*].priority

    type: number

    required: yes

    description: priority of the node.

  • real_nodes[*].detail

    type: string

    required: no

    description: other infos of the node (report by the node).

Request example

Shell

curl \
  -X POST \
  -H "API-Token: 1df87165-3593-4eca-a910-9ac20005e6ec" \
  https://admin-site/admin-api/gateway/1/virtual_groups \
  -d '{
      "name": "VG1",
      "virtual_ip": "10.0.0.100",
      "status": 0,
      "real_nodes": [
          {"node": 1, "interface": "eth0", "priority": 254, "status": 2}
      ]
  }'

Response example

Status: 200 OK
{
    "data":{
        "id":3
    },
    "status":0
}

Modify the keepalived group

URI

PUT /admin-api/gateway/{gateway_id}/virtual_groups/{virtual_group_id}

JSON body

  • name

    type: string

    required: yes

    description: name of the keepalived group

  • virtual_ip

    type: string

    required: yes

    description: virtual IP address of the keepalived group

  • virtual_ipv6

    type: string

    required: yes

    description: virtual ipv6 address of the keepalived group

  • status

    type: number

    required: no

    description: 0 stand for resolve DNS to this node and serve to the public, 1 stand for disable DNS resolve, 2 stand for offline.

Request example

Shell

curl \
  -X PUT \
  -H "API-Token: 1df87165-3593-4eca-a910-9ac20005e6ec" \
  https://admin-site/admin-api/gateway/1/virtual_groups/1 \
  -d '{
      "name": "VG1",
      "virtual_ip": "10.0.0.100",
      "status": 1
  }'

Response example

Status: 200 OK
{
    "status":0
}

Fetch keepalived group

URI

GET /admin-api/gateway/{gateway_id}/virtual_groups

Request example

Shell

curl \
  -H "API-Token: 1df87165-3593-4eca-a910-9ac20005e6ec" \
  https://admin-site/admin-api/gateway/1/virtual_groups/1

Response example

Status: 200 OK
{
  "data": {
    "data": [
      {
        "name": "VG1",
        "status": 1,
        "virtual_ip": "1.2.3.4",
        "id": 1,
        "online_status": true,
        "router_id": 1
      }
    ],
    "meta": {
      "count": 1
    }
  },
  "status": 0
}

Remove keepalived group

URI

DELETE /admin-api/gateway/{gateway_id}/virtual_groups/{virtual_group_id}

Request example

curl \
  -X DELETE \
  -H "API-Token: 1df87165-3593-4eca-a910-9ac20005e6ec" \
  https://admin-site/admin-api/gateway/1/virtual_groups/1

Response example

Status: 200 OK
{"status": 0}