k8s
add a k8s cluster
Description
Add a k8s cluster
URI
POST /admin-api/global/k8s
JSON body
name
type: string
required: yes
description: name of the k8s
host
type: string
required: yes
description: IP of the k8s
domain
type: string
required: yes
description: domain of the k8s, only one of IP and domain can be specified.
connect_timeout
type: string
required: yes
description: connect timeout, unit second
read_timeout
type: string
required: yes
description: read timeout, unit second
port
type: integer
required: yes
description: port of the k8s
ssl_verify
type: boolean
required: yes
description: enable ssl verify
token
type: string
required: yes
description: k8s access token
Example Request
Shell
curl \
-H "API-Token: 1df87165-3593-4eca-a910-9ac20005e6ec" \
https://admin-site/admin-api/global/k8s \
-d '
{
"name":"test",
"host":"10.68.0.1",
"connect_timeout": 5,
"read_timeout": 5,
"port":443,
"ssl_verify":false,
"token":"eyJhbGciOiJSUzI1NiIsImtpZCI6InJOZkJvNWItMDhYOXBfUGw2czBleWxNWXZBWi1KOXFqQ05GdjVCWUdpc3cifQ.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJkZWZhdWx0Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZWNyZXQubmFtZSI6Im9wZW5yZXN0eS1lZGdlLXNlcnZpY2VhY2NvdW50LXRva2VuLTdkMjk5Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZXJ2aWNlLWFjY291bnQubmFtZSI6Im9wZW5yZXN0eS1lZGdlLXNlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZXJ2aWNlLWFjY291bnQudWlkIjoiYjkzZTI0MzAtNGFjMi00Y2ZjLWExYzktNzEyZjMxZmM4ZTUzIiwic3ViIjoic3lzdGVtOnNlcnZpY2VhY2NvdW50OmRlZmF1bHQ6b3BlbnJlc3R5LWVkZ2Utc2VydmljZWFjY291bnQifQ.I0x3A0Z1Oe_WQVKtCooYqas6JcQbvSxd0sFpFLecLT4vACDFyB3TsxAoVg1WPIzIue-VXoWUSij9Fa-RCHM_5k_mbY9nyuaJDjq8ziMZdlOHHRcgoACcCjUIK_2-o0D8PaNpHs5X3JZYmbQTXMMjs81Sd0sNsSJ2XIvhwN4Qkg9FCngFxPf_xBWYUh8EbMALde53GyB3LgKwgXu_538skCvoH2SGWXCr6oYc7W1wngHrrmy7Wzq_NlTlL-hQtEz9ST8Rik1zHbItrfQpgmW4d2UOrZ6IL91ZpKDGNS4gNt7pJ8opEvMascg92O28H9Y9kAIgJtOZFBHSQl10DADHBw"
}
'
Example Response
Status: 200 OK
{
"data": {
"id": 1
},
"status": 0
}
Get k8s cluster list
Description
get k8s cluster list
URI
GET /admin-api/global/k8s
JSON body
Example Request
Shell
curl \
-H "API-Token: 1df87165-3593-4eca-a910-9ac20005e6ec" \
https://admin-site/admin-api/global/k8s
Example Response
Status: 200 OK
{
"data": [
{
"id" : 1,
"name":"test",
"host":"10.68.0.1",
"port":443,
"connect_timeout": 5,
"read_timeout": 5,
"ssl_verify":false,
"status" : "NORMAL"
}
],
"status": 0
}
Query k8s cluster info
Description
query k8s cluster info
URI
GET /admin-api/global/k8s/{id}
JSON body
Example Request
Shell
curl \
-H "API-Token: 1df87165-3593-4eca-a910-9ac20005e6ec" \
https://admin-site/admin-api/global/k8s/1
Example Response
Status: 200 OK
{
"data": {
"id" : 1,
"name":"test",
"host":"10.68.0.1",
"connect_timeout": 5,
"read_timeout": 5,
"port":443,
"ssl_verify":false,
"status" : "NORMAL",
},
"status": 0
}
Update k8s cluster configuration
Description
update k8s cluster configuration
URI
PUT /admin-api/global/k8s/{id}
JSON body
name
type: string
required: yes
description: name of the k8s
host
type: string
required: yes
description: IP of the k8s
domain
type: string
required: yes
description: domain of the k8s, only one of host and domain can be specified.
connect_timeout
type: string
required: yes
description: connect timeout, unit second
read_timeout
type: string
required: yes
description: read timeout, unit second
port
type: integer
required: yes
description: port of the k8s
ssl_verify
type: boolean
required: yes
description: enable ssl verify
token
type: string
required: yes
description: access token of the k8s
Example Request
Shell
curl \
-H "API-Token: 1df87165-3593-4eca-a910-9ac20005e6ec" \
-XPUT https://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"
}
'
Example Response
Status: 200 OK
{
"status": 0
}
Delete k8s cluster
Delete k8s cluster
URI
DELETE /admin-api/global/k8s/{id}
Example Request
Shell
curl \
-H "API-Token: 1df87165-3593-4eca-a910-9ac20005e6ec" \
-XDELETE https://admin-site/admin-api/global/k8s/1
Example Response
Status: 200 OK
{
"status": 0
}
Query k8s namespace list
Description
Query k8s namespace list
URI
GET /admin-api/k8s/{id}/namespaces
Example Request
Shell
curl \
-H "API-Token: 1df87165-3593-4eca-a910-9ac20005e6ec" \
-XGET https://admin-site/admin-api/k8s/1/namespaces
Example Response
Status: 200 OK
{
"data" : [
"default", "kube-public", "kube-system"
],
"status": 0
}
Query service list in a namespace
简介
Query service list in a namespace
URI
GET /admin-api/k8s/{id}/namespaces/{namespace}/services
Example Request
Shell
curl \
-H "API-Token: 1df87165-3593-4eca-a910-9ac20005e6ec" \
-XGET https://admin-site/admin-api/k8s/1/namespaces/default/services
Example Response
Status: 200 OK
{
"data" : [
"test-hello", "test-nginx"
],
"status": 0
}
Query port list of the service in a namespace
简介
Query port list of the service in a namespace
URI
GET /admin-api/k8s/{id}/namespaces/{namespace}/services/{service}/ports
Example Request
Shell
curl \
-H "API-Token: 1df87165-3593-4eca-a910-9ac20005e6ec" \
-XGET https://admin-site/admin-api/k8s/1/namespaces/default/services
Example Response
Status: 200 OK
{
"data" : [
80, 8080
],
"status": 0
}
Add a k8s upstream
简介
Add a k8s upstream binding to a k8s service.
URI
POST /admin-api/applications/http/{id}/k8s_upstreams
JSON body
name
type: string
required: yes
description: name of the upstream
k8s_services
type: array
required: yes
description: k8s service list
k8s_services.k8s
type: integer
required: yes
description: k8s id
k8s_services.k8s_namespace
type: string
required: yes
description: k8s namespace
k8s_services.k8s_service
type: string
required: yes
description: k8s service name
k8s_services.k8s_service_port
type: string
required: yes
description: k8s service port
Example Request
Shell
curl \
-H "API-Token: 1df87165-3593-4eca-a910-9ac20005e6ec" \
-XPOST https://admin-site/admin-api/applications/http/1/clusters \
-d '
{
"name":"test",
"enable_checker": false,
"is_k8s_service" : true,
"k8s_services" : [
{
"k8s" : 1,
"k8s_namespace" : "default",
"k8s_service" : "test-hello",
"k8s_service_port" : 80
}
]
}
'
Example Response
Status: 200 OK
{
"data" : {
"id" : 1
},
"status": 0
}
Update a k8s upstream
简介
Update a k8s upstream
URI
PUT /admin-api/applications/http/{applicationid}/clusters/{clusterid}
JSON body
name
type: string
required: yes
description: name of the k8s upstream
k8s_services
type: array
required: yes
description: service list of the k8s upstream
k8s_services.k8s
type: integer
required: yes
description: k8s id
k8s_services.k8s_namespace
type: string
required: yes
description: k8s namespace
k8s_services.k8s_service
type: string
required: yes
description: k8s service name
k8s_services.k8s_service_port
type: string
required: yes
description: k8s service port
Example Request
Shell
curl \
-H "API-Token: 1df87165-3593-4eca-a910-9ac20005e6ec" \
-XPUT https://admin-site/admin-api/applications/http/1/k8s_upstreams/1 \
-d '
{
"name":"test",
"enable_checker": false,
"is_k8s_service" : true,
"k8s_services" : [
{
"k8s" : 1,
"k8s_namespace" : "default",
"k8s_service" : "test-hello",
"k8s_service_port" : 80
}
]
}
'
Example Response
Status: 200 OK
{
"status": 0
}