# k8s 服务

# 添加k8s服务

# 简介

添加新的k8s服务

# URI

POST /admin-api/global/k8s

# JSON body

  • name

    type: string

    required: yes

    description: k8s的名称

  • host

    type: string

    required: yes

    description: k8s的服务地址

  • port

    type: integer

    required: yes

    description: k8s的服务端口

  • ssl_verify

    type: boolean

    required: yes

    description: 是否做ssl校验(默认否)

  • token

    type: string

    required: yes

    description: 访问k8s的token

# 请求示例

# Shell

curl \
  -H "API-Token: 1df87165-3593-4eca-a910-9ac20005e6ec" \
  http://admin-site/admin-api/global/k8s \
  -d '
{
    "name":"test",
    "host":"10.68.0.1",
    "port":443,
    "ssl_verify":false,
    "token":"eyJhbGciOiJSUzI1NiIsImtpZCI6InJOZkJvNWItMDhYOXBfUGw2czBleWxNWXZBWi1KOXFqQ05GdjVCWUdpc3cifQ.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJkZWZhdWx0Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZWNyZXQubmFtZSI6Im9wZW5yZXN0eS1lZGdlLXNlcnZpY2VhY2NvdW50LXRva2VuLTdkMjk5Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZXJ2aWNlLWFjY291bnQubmFtZSI6Im9wZW5yZXN0eS1lZGdlLXNlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZXJ2aWNlLWFjY291bnQudWlkIjoiYjkzZTI0MzAtNGFjMi00Y2ZjLWExYzktNzEyZjMxZmM4ZTUzIiwic3ViIjoic3lzdGVtOnNlcnZpY2VhY2NvdW50OmRlZmF1bHQ6b3BlbnJlc3R5LWVkZ2Utc2VydmljZWFjY291bnQifQ.I0x3A0Z1Oe_WQVKtCooYqas6JcQbvSxd0sFpFLecLT4vACDFyB3TsxAoVg1WPIzIue-VXoWUSij9Fa-RCHM_5k_mbY9nyuaJDjq8ziMZdlOHHRcgoACcCjUIK_2-o0D8PaNpHs5X3JZYmbQTXMMjs81Sd0sNsSJ2XIvhwN4Qkg9FCngFxPf_xBWYUh8EbMALde53GyB3LgKwgXu_538skCvoH2SGWXCr6oYc7W1wngHrrmy7Wzq_NlTlL-hQtEz9ST8Rik1zHbItrfQpgmW4d2UOrZ6IL91ZpKDGNS4gNt7pJ8opEvMascg92O28H9Y9kAIgJtOZFBHSQl10DADHBw"
}
'

# 响应示例

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

# 查询k8s服务列表

# 简介

查询k8s服务列表

# URI

GET /admin-api/global/k8s

# JSON body

# 请求示例

# Shell

curl \
  -H "API-Token: 1df87165-3593-4eca-a910-9ac20005e6ec" \
  http://admin-site/admin-api/global/k8s

# 响应示例

Status: 200 OK
{
    "data": [
        {
            "id" : 1,
            "name":"test",
            "host":"10.68.0.1",
            "port":443,
            "ssl_verify":false,
            "status" : "NORMAL"
        }
    ],
    "status": 0
}

# 查询k8s单个服务信息

# 简介

查询k8s单个服务

# URI

GET /admin-api/global/k8s/{id}

# JSON body

# 请求示例

# Shell

curl \
  -H "API-Token: 1df87165-3593-4eca-a910-9ac20005e6ec" \
  http://admin-site/admin-api/global/k8s/1

# 响应示例

Status: 200 OK
{
    "data": {
            "id" : 1,
            "name":"test",
            "host":"10.68.0.1",
            "port":443,
            "ssl_verify":false,
            "status" : "NORMAL",
    },
    "status": 0
}

# 更新k8s信息

# 简介

更新k8s单个服务信息

# URI

PUT /admin-api/global/k8s/{id}

# JSON body

  • name

    type: string

    required: yes

    description: k8s的名称

  • host

    type: string

    required: yes

    description: k8s的服务地址

  • port

    type: integer

    required: yes

    description: k8s的服务端口

  • ssl_verify

    type: boolean

    required: yes

    description: 是否做ssl校验(默认否)

  • token

    type: string

    required: yes

    description: 访问k8s的token

# 请求示例

# Shell

curl \
  -H "API-Token: 1df87165-3593-4eca-a910-9ac20005e6ec" \
  -XPUT http://admin-site/admin-api/global/k8s/1 \
  -d '
{
    "name":"test",
    "host":"10.68.0.1",
    "port":443,
    "ssl_verify":false,
    "token":"eyJhbGciOiJSUzI1NiIsImtpZCI6InJOZkJvNWItMDhYOXBfUGw2czBleWxNWXZBWi1KOXFqQ05GdjVCWUdpc3cifQ.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJkZWZhdWx0Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZWNyZXQubmFtZSI6Im9wZW5yZXN0eS1lZGdlLXNlcnZpY2VhY2NvdW50LXRva2VuLTdkMjk5Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZXJ2aWNlLWFjY291bnQubmFtZSI6Im9wZW5yZXN0eS1lZGdlLXNlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZXJ2aWNlLWFjY291bnQudWlkIjoiYjkzZTI0MzAtNGFjMi00Y2ZjLWExYzktNzEyZjMxZmM4ZTUzIiwic3ViIjoic3lzdGVtOnNlcnZpY2VhY2NvdW50OmRlZmF1bHQ6b3BlbnJlc3R5LWVkZ2Utc2VydmljZWFjY291bnQifQ.I0x3A0Z1Oe_WQVKtCooYqas6JcQbvSxd0sFpFLecLT4vACDFyB3TsxAoVg1WPIzIue-VXoWUSij9Fa-RCHM_5k_mbY9nyuaJDjq8ziMZdlOHHRcgoACcCjUIK_2-o0D8PaNpHs5X3JZYmbQTXMMjs81Sd0sNsSJ2XIvhwN4Qkg9FCngFxPf_xBWYUh8EbMALde53GyB3LgKwgXu_538skCvoH2SGWXCr6oYc7W1wngHrrmy7Wzq_NlTlL-hQtEz9ST8Rik1zHbItrfQpgmW4d2UOrZ6IL91ZpKDGNS4gNt7pJ8opEvMascg92O28H9Y9kAIgJtOZFBHSQl10DADHBw"
}
'

# 响应示例

Status: 200 OK
{
    "status": 0
}

# 删除k8s信息

# 简介

删除k8s单个服务信息

# URI

DELETE /admin-api/global/k8s/{id}

# 请求示例

# Shell

curl \
  -H "API-Token: 1df87165-3593-4eca-a910-9ac20005e6ec" \
  -XDELETE http://admin-site/admin-api/global/k8s/1

# 响应示例

Status: 200 OK
{
    "status": 0
}

# 查询某个k8s的命名空间列表

# 简介

查询某个k8s的命名空间列表

# URI

GET /admin-api/k8s/{id}/namespaces

# 请求示例

# Shell

curl \
  -H "API-Token: 1df87165-3593-4eca-a910-9ac20005e6ec" \
  -XGET http://admin-site/admin-api/k8s/1/namespaces

# 响应示例

Status: 200 OK
{
    "data" : [
        "default", "kube-public", "kube-system"
    ],

    "status": 0
}

# 查询某个k8s的某个命名空间下的服务列表

# 简介

查询某个k8s的某个命名空间下的服务列表

# URI

GET /admin-api/k8s/{id}/namespaces/{namespace}/services

# 请求示例

# Shell

curl \
  -H "API-Token: 1df87165-3593-4eca-a910-9ac20005e6ec" \
  -XGET http://admin-site/admin-api/k8s/1/namespaces/default/services

# 响应示例

Status: 200 OK
{
    "data" : [
        "test-hello", "test-nginx"
    ],

    "status": 0
}

# 查询某个k8s的某个命名空间下的某个服务的服务端口列表

# 简介

查询某个k8s的某个命名空间下的某个服务的端口列表

# URI

GET /admin-api/k8s/{id}/namespaces/{namespace}/services/{service}/ports

# 请求示例

# Shell

curl \
  -H "API-Token: 1df87165-3593-4eca-a910-9ac20005e6ec" \
  -XGET http://admin-site/admin-api/k8s/1/namespaces/default/services

# 响应示例

Status: 200 OK
{
    "data" : [
        80, 8080
    ],

    "status": 0
}

# 添加一个upstream, 将这个upstream设置为k8s中的某个服务。

# 简介

添加一个upstream, 将这个upstream设置为k8s中的某个服务。 edge会自动从k8s中获取upstream的节点,并实时检测upstream节点的变动。

# URI

POST /admin-api/applications/http/{id}/clusters

# JSON body

  • name

    type: string

    required: yes

    description: upstream的名称

  • is_k8s_service

    type: boolean

    required: yes

    description: 这个upstream是否是一个k8s服务

  • k8s

    type: integer

    required: yes

    description: k8s id

  • k8s_namespace

    type: string

    required: yes

    description: k8s的命名空间

  • k8s_service

    type: string

    required: yes

    description: k8s的服务名称

  • k8s_service_port

    type: string

    required: yes

    description: k8s服务的服务端口

# 请求示例

# Shell

curl \
  -H "API-Token: 1df87165-3593-4eca-a910-9ac20005e6ec" \
  -XPOST http://admin-site/admin-api/applications/http/1/clusters \
  -d '
{
        "name":"test",
        "enable_checker": false,
        "is_k8s_service" : true,
        "k8s" : 1,
        "k8s_namespace" : "default",
        "k8s_service" : "test-hello",
        "k8s_service_port" : 80
}
'

# 响应示例

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

# 更新一个upstream, 将这个upstream设置为k8s中的某个服务。

# 简介

更新一个upstream, 将这个upstream设置为k8s中的某个服务。 edge会自动从k8s中获取upstream的节点,并实时检测upstream节点的变动。

# URI

PUT /admin-api/applications/http/{applicationid}/clusters/{clusterid}

# JSON body

  • name

    type: string

    required: yes

    description: upstream的名称

  • is_k8s_service

    type: boolean

    required: yes

    description: 这个upstream是否是一个k8s服务

  • k8s

    type: integer

    required: yes

    description: k8s id

  • k8s_namespace

    type: string

    required: yes

    description: k8s的命名空间

  • k8s_service

    type: string

    required: yes

    description: k8s的服务名称

  • k8s_service_port

    type: string

    required: yes

    description: k8s服务的服务端口

# 请求示例

# Shell

curl \
  -H "API-Token: 1df87165-3593-4eca-a910-9ac20005e6ec" \
  -XPUT http://admin-site/admin-api/applications/http/1/clusters/1 \
  -d '
{
        "name":"test",
        "enable_checker": false,
        "is_k8s_service" : true,
        "k8s" : 1,
        "k8s_namespace" : "default",
        "k8s_service" : "test-hello",
        "k8s_service_port" : 80
}
'

# 响应示例

Status: 200 OK
{
    "status": 0
}