k8s响应

资源不存在

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# curl -i 127.0.0.1:8080/api/v1/namespaces/aa
HTTP/1.1 404 Not Found
Content-Type: application/json
Date: Fri, 16 Jun 2017 07:50:48 GMT
Content-Length: 231

{
"kind": "Status",
"apiVersion": "v1",
"metadata": {},
"status": "Failure",
"message": "namespaces \"aa\" not found",
"reason": "NotFound",
"details": {
"name": "aa",
"kind": "namespaces"
},
"code": 404
}

请求超时

创建数据错误

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# curl -i -X POST 127.0.0.1:8080/api/v1/namespaces
HTTP/1.1 400 Bad Request
Content-Type: application/json
Date: Fri, 16 Jun 2017 07:55:08 GMT
Content-Length: 301

{
"kind": "Status",
"apiVersion": "v1",
"metadata": {},
"status": "Failure",
"message": "the object provided is unrecognized (must be of type Namespace): couldn't get version/kind; json parse error: unexpected end of JSON input (\u003cempty\u003e)",
"reason": "BadRequest",
"code": 400
}

创建已存在

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# curl -i -H "Content-type: application/json" -X POST -d '{"apiVersion":"v1","kind":"Namespace","metadata":{"name":"kube-system"}}' 127.0.0.1:8080/api/v1/namespaces
HTTP/1.1 409 Conflict
Content-Type: application/json
Date: Fri, 16 Jun 2017 08:17:05 GMT
Content-Length: 259

{
"kind": "Status",
"apiVersion": "v1",
"metadata": {},
"status": "Failure",
"message": "namespaces \"kube-system\" already exists",
"reason": "AlreadyExists",
"details": {
"name": "kube-system",
"kind": "namespaces"
},
"code": 409
}

路径不合法

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# curl -i -X POST 127.0.0.1:8080/api/v1/namespaces/aa
HTTP/1.1 405 Method Not Allowed
Content-Type: application/json
Date: Fri, 16 Jun 2017 07:53:01 GMT
Content-Length: 229

{
"kind": "Status",
"apiVersion": "v1",
"metadata": {},
"status": "Failure",
"message": "the server does not allow this method on the requested resource",
"reason": "MethodNotAllowed",
"details": {},
"code": 405
}

url path上的名称与数据不符合

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# curl -i -H "Content-type: application/json" -X POST -d '{"apiVersion":"v1","kind":"Pod","metadata":{"name":"testpod","namespace":"noexists"},"spec":{"containers":[{"name":"nginx","image":"nginx:1.10.1-alpine"}]}}' 127.0.0.1:8080/api/v1/namespaces/default/pods
HTTP/1.1 400 Bad Request
Content-Type: application/json
Date: Fri, 16 Jun 2017 08:20:16 GMT
Content-Length: 228

{
"kind": "Status",
"apiVersion": "v1",
"metadata": {},
"status": "Failure",
"message": "the namespace of the provided object does not match the namespace sent on the request",
"reason": "BadRequest",
"code": 400
}

删除不存在资源

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# curl -i -X DELETE 127.0.0.1:8080/api/v1/namespaces/aaa
HTTP/1.1 404 Not Found
Content-Type: application/json
Date: Fri, 16 Jun 2017 08:37:49 GMT
Content-Length: 233

{
"kind": "Status",
"apiVersion": "v1",
"metadata": {},
"status": "Failure",
"message": "namespaces \"aaa\" not found",
"reason": "NotFound",
"details": {
"name": "aaa",
"kind": "namespaces"
},
"code": 404
}
显示 Gitment 评论