华为云用户手册

  • URI GET /apis/rbac.authorization.k8s.io/v1/namespaces/{namespace}/rolebindings 表1 路径参数 参数 是否必选 参数类型 描述 namespace 是 String object name and auth scope, such as for teams and projects 表2 Query参数 参数 是否必选 参数类型 描述 allowWatchBookmarks 否 Boolean allowWatchBookmarks requests watch events with type "BOOKMARK". Servers that do not implement bookmarks may ignore this flag and bookmarks are sent at the server's discretion. Clients should not assume bookmarks are returned at any specific interval, nor may they assume the server will send any BOOKMARK event during a session. If this is not a watch, this field is ignored. If the feature gate WatchBookmarks is not enabled in apiserver, this field is ignored. continue 否 String The continue option should be set when retrieving more results from the server. Since this value is server defined, clients may only use the continue value from a previous query result with identical query parameters (except for the value of continue) and the server may reject a continue value it does not recognize. If the specified continue value is no longer valid whether due to expiration (generally five to fifteen minutes) or a configuration change on the server, the server will respond with a 410 ResourceExpired error together with a continue token. If the client needs a consistent list, it must restart their list without the continue field. Otherwise, the client may send another list request with the token received with the 410 error, the server will respond with a list starting from the next key, but from the latest snapshot, which is inconsistent from the previous list results - objects that are created, modified, or deleted after the first list request will be included in the response, as long as their keys are after the "next key". This field is not supported when watch is true. Clients may start a watch from the last resourceVersion value returned by the server and not miss any modifications. fieldSelector 否 String A selector to restrict the list of returned objects by their fields. Defaults to everything. labelSelector 否 String A selector to restrict the list of returned objects by their labels. Defaults to everything. limit 否 Integer limit is a maximum number of responses to return for a list call. If more items exist, the server will set the continue field on the list metadata to a value that can be used with the same initial query to retrieve the next set of results. Setting a limit may return fewer than the requested amount of items (up to zero items) in the event all requested objects are filtered out and clients should only use the presence of the continue field to determine whether more results are available. Servers may choose not to support the limit argument and will return all of the available results. If limit is specified and the continue field is empty, clients may assume that no more results are available. This field is not supported if watch is true. The server guarantees that the objects returned when using continue will be identical to issuing a single list call without a limit - that is, no objects created, modified, or deleted after the first request is issued will be included in any subsequent continued requests. This is sometimes referred to as a consistent snapshot, and ensures that a client that is using limit to receive smaller chunks of a very large result can ensure they see all possible objects. If objects are updated during a chunked list the version of the object that was present at the time the first list result was calculated is returned. resourceVersion 否 String resourceVersion sets a constraint on what resource versions a request may be served from. See https://kubernetes.io/docs/reference/using-api/api-concepts/#resource-versions for details. Defaults to unset resourceVersionMatch 否 String resourceVersionMatch determines how resourceVersion is applied to list calls. It is highly recommended that resourceVersionMatch be set for list calls where resourceVersion is set See https://kubernetes.io/docs/reference/using-api/api-concepts/#resource-versions for details. Defaults to unset timeoutSeconds 否 Integer Timeout for the list/watch call. This limits the duration of the call, regardless of any activity or inactivity. watch 否 Boolean Watch for changes to the described resources and return them as a stream of add, update, and remove notifications. Specify resourceVersion. pretty 否 String If 'true', then the output is pretty printed.
  • 响应示例 状态码: 200 OK { "apiVersion" : "rbac.authorization.k8s.io/v1", "items" : [ { "metadata" : { "creationTimestamp" : "2018-11-27T03:29:52Z", "name" : "read-pods", "namespace" : "default", "resourceVersion" : "16611", "selfLink" : "/apis/rbac.authorization.k8s.io/v1/namespaces/default/rolebindings/secret-reader", "uid" : "b3d1a49a-f1f4-11e8-b449-fa163ec24e06" }, "roleRef" : { "apiGroup" : "rbac.authorization.k8s.io", "kind" : "Role", "name" : "pod-reader" }, "subjects" : [ { "apiGroup" : "rbac.authorization.k8s.io", "kind" : "User", "name" : "jane" } ] } ], "kind" : "RoleBindingList", "metadata" : { "resourceVersion" : "16611", "selfLink" : "/apis/rbac.authorization.k8s.io/v1/namespaces/default/rolebindings" } }
  • 状态码 状态码 描述 200 OK 400 BadRequest 401 Unauthorized 403 Forbidden 404 NotFound 405 MethodNotAllowed 406 NotAcceptable 409 Conflict 415 UnsupportedMediaType 422 Invalid 429 TooManyRequests 500 InternalError 503 ServiceUnavailable 504 ServerTimeout
  • 响应示例 状态码: 200 OK { "apiVersion" : "batch.volcano.sh/v1alpha1", "items" : [ { "apiVersion" : "batch.volcano.sh/v1alpha1", "kind" : "Job", "metadata" : { "creationTimestamp" : "2019-06-26T03:16:26Z", "generation" : 1, "name" : "openmpi-hello-2-com", "namespace" : "cci-namespace-42263891", "resourceVersion" : "7625538", "selfLink" : "/apis/batch.volcano.sh/v1alpha1/namespaces/cci-namespace-42263891/jobs/openmpi-hello-2-com", "uid" : "c84d86f0-97c0-11e9-9d09-dc9914fb58e0" }, "spec" : { "minAvailable" : 1, "plugins" : { "env" : [ ], "ssh" : [ ], "svc" : [ ] }, "queue" : "default", "schedulerName" : "volcano", "tasks" : [ { "name" : "mpimaster", "policies" : [ { "action" : "CompleteJob", "event" : "TaskCompleted" } ], "replicas" : 1, "template" : { "spec" : { "containers" : [ { "command" : [ "/bin/sh", "-c", "MPI_HOST=`cat /etc/volcano/mpiworker.host | tr \"\\n\" \",\"`;\nmkdir -p /var/run/sshd; /usr/sbin/sshd;\nmpiexec --allow-run-as-root --host ${MPI_HOST} -np 2 mpi_hello_world 003e /home/re" ], "image" : "*.*.5.235:20202/swr/openmpi-hello:3.28", "name" : "mpimaster", "ports" : [ { "containerPort" : 22, "name" : "mpijob-port" } ], "resources" : { "limits" : { "cpu" : "250m", "memory" : "1Gi" }, "requests" : { "cpu" : "250m", "memory" : "1Gi" } }, "workingDir" : "/home" } ], "imagePullSecrets" : [ { "name" : "imagepull-secret" } ], "restartPolicy" : "OnFailure" } } }, { "name" : "mpiworker", "replicas" : 2, "template" : { "spec" : { "containers" : [ { "command" : [ "/bin/sh", "-c", "mkdir -p /var/run/sshd; /usr/sbin/sshd -D;" ], "image" : "*.*.*.*:20202/swr/openmpi-hello:3.28", "name" : "mpiworker", "ports" : [ { "containerPort" : 22, "name" : "mpijob-port" } ], "resources" : { "limits" : { "cpu" : "250m", "memory" : "1Gi" }, "requests" : { "cpu" : "250m", "memory" : "1Gi" } }, "workingDir" : "/home" } ], "imagePullSecrets" : [ { "name" : "imagepull-secret" } ], "restartPolicy" : "OnFailure" } } } ] }, "status" : { "minAvailable" : 1, "pending" : 3, "state" : { "phase" : "Inqueue" } } } ], "kind" : "JobList", "metadata" : { "continue" : "", "resourceVersion" : "7678090", "selfLink" : "/apis/batch.volcano.sh/v1alpha1/namespaces/cci-namespace-42263891/jobs" } }
  • URI GET /apis/batch.volcano.sh/v1alpha1/namespaces/{namespace}/jobs 表1 路径参数 参数 是否必选 参数类型 描述 namespace 是 String object name and auth scope, such as for teams and projects 表2 Query参数 参数 是否必选 参数类型 描述 allowWatchBookmarks 否 Boolean allowWatchBookmarks requests watch events with type "BOOKMARK". Servers that do not implement bookmarks may ignore this flag and bookmarks are sent at the server's discretion. Clients should not assume bookmarks are returned at any specific interval, nor may they assume the server will send any BOOKMARK event during a session. If this is not a watch, this field is ignored. If the feature gate WatchBookmarks is not enabled in apiserver, this field is ignored. continue 否 String The continue option should be set when retrieving more results from the server. Since this value is server defined, clients may only use the continue value from a previous query result with identical query parameters (except for the value of continue) and the server may reject a continue value it does not recognize. If the specified continue value is no longer valid whether due to expiration (generally five to fifteen minutes) or a configuration change on the server, the server will respond with a 410 ResourceExpired error together with a continue token. If the client needs a consistent list, it must restart their list without the continue field. Otherwise, the client may send another list request with the token received with the 410 error, the server will respond with a list starting from the next key, but from the latest snapshot, which is inconsistent from the previous list results - objects that are created, modified, or deleted after the first list request will be included in the response, as long as their keys are after the "next key". This field is not supported when watch is true. Clients may start a watch from the last resourceVersion value returned by the server and not miss any modifications. fieldSelector 否 String A selector to restrict the list of returned objects by their fields. Defaults to everything. labelSelector 否 String A selector to restrict the list of returned objects by their labels. Defaults to everything. limit 否 Integer limit is a maximum number of responses to return for a list call. If more items exist, the server will set the continue field on the list metadata to a value that can be used with the same initial query to retrieve the next set of results. Setting a limit may return fewer than the requested amount of items (up to zero items) in the event all requested objects are filtered out and clients should only use the presence of the continue field to determine whether more results are available. Servers may choose not to support the limit argument and will return all of the available results. If limit is specified and the continue field is empty, clients may assume that no more results are available. This field is not supported if watch is true. The server guarantees that the objects returned when using continue will be identical to issuing a single list call without a limit - that is, no objects created, modified, or deleted after the first request is issued will be included in any subsequent continued requests. This is sometimes referred to as a consistent snapshot, and ensures that a client that is using limit to receive smaller chunks of a very large result can ensure they see all possible objects. If objects are updated during a chunked list the version of the object that was present at the time the first list result was calculated is returned. resourceVersion 否 String resourceVersion sets a constraint on what resource versions a request may be served from. See https://kubernetes.io/docs/reference/using-api/api-concepts/#resource-versions for details. Defaults to unset resourceVersionMatch 否 String resourceVersionMatch determines how resourceVersion is applied to list calls. It is highly recommended that resourceVersionMatch be set for list calls where resourceVersion is set See https://kubernetes.io/docs/reference/using-api/api-concepts/#resource-versions for details. Defaults to unset timeoutSeconds 否 Integer Timeout for the list/watch call. This limits the duration of the call, regardless of any activity or inactivity. watch 否 Boolean Watch for changes to the described resources and return them as a stream of add, update, and remove notifications. Specify resourceVersion. pretty 否 String If 'true', then the output is pretty printed.
  • 请求消息体(可选) 该部分可选。请求消息体通常以结构化格式(如JSON或XML)发出,与请求消息头中Content-Type对应,传递除请求消息头之外的内容。若请求消息体中的参数支持中文,则中文字符必须为UTF-8编码。 每个接口的请求消息体内容不同,也并不是每个接口都需要有请求消息体(或者说消息体为空),GET、DELETE操作类型的接口就不需要消息体,消息体具体内容需要根据具体接口而定。 对于获取用户Token接口,您可以从接口的请求部分看到所需的请求参数及参数说明。将消息体加入后的请求如下所示,加粗的斜体字段需要根据实际值填写,其中username为用户名,domainname为用户所属的账号名称,********为用户登录密码,xxxxxxxxxxxxxxxxxx为project的名称,如“cn-north-1”,您可以从地区和终端节点获取。 scope参数定义了Token的作用域,下面示例中获取的Token仅能访问project下的资源。您还可以设置Token的作用域为某个账号下所有资源或账号的某个project下的资源,详细定义请参见获取用户Token。 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 POST https://iam.cn-north-1.myhuaweicloud.com/v3/auth/tokens Content-Type: application/json { "auth": { "identity": { "methods": [ "password" ], "password": { "user": { "name": "username", "password": "********", "domain": { "name": "domainname" } } } }, "scope": { "project": { "name": "xxxxxxxxxxxxxxxxxx" } } } } 到这里为止这个请求需要的内容就具备齐全了,您可以使用curl、Postman或直接编写代码等方式发送请求调用API。对于获取用户Token接口,返回的响应消息头中的“x-subject-token”就是需要获取的用户Token。有了Token之后,您就可以使用Token认证调用其他API。
  • 请求消息头 附加请求头字段,如指定的URI和HTTP方法所要求的字段。例如定义消息体类型的请求头“Content-Type”,请求鉴权信息等。 详细的公共请求消息头字段请参见表3。 表3 公共请求消息头 名称 描述 是否必选 示例 Host 请求的服务器信息,从服务API的URL中获取。值为hostname[:port]。端口缺省时使用默认的端口,https的默认端口为443。 否 使用AK/SK认证时该字段必选。 code.test.com or code.test.com:443 Content-Type 消息体的类型(格式)。推荐用户使用默认值application/json,有其他取值时会在具体接口中专门说明。 是 application/json Content-Length 请求body长度,单位为Byte。 否 3495 X-Project-Id project id,项目编号。请参考获取项目ID章节获取项目编号。 否 如果是专属云场景采用AK/SK认证方式的接口请求,或者多project场景采用AK/SK认证的接口请求,则该字段必选。 e9993fc787d94b6c886cbaa340f9c0f4 X-Auth-Token 用户Token。 用户Token也就是调用获取用户Token接口的响应值,该接口是唯一不需要认证的接口。 请求响应成功后在响应消息头(Headers)中包含的“X-Subject-Token”的值即为Token值。 否 使用Token认证时该字段必选。 注:以下仅为Token示例片段。 MIIPAgYJKoZIhvcNAQcCo...ggg1BBIINPXsidG9rZ API同时支持使用AK/SK认证,AK/SK认证使用SDK对请求进行签名,签名过程会自动往请求中添加Authorization(签名认证信息)和X-Sdk-Date(请求发送的时间)请求头。 AK/SK认证的详细说明请参见认证鉴权的“AK/SK认证”。 对于获取用户Token接口,由于不需要认证,所以只添加“Content-Type”即可,添加消息头后的请求如下所示。 1 2 POST https://iam.cn-north-1.myhuaweicloud.com/v3/auth/tokens Content-Type: application/json
  • 请求方法 HTTP请求方法(也称为操作或动词),它告诉服务您正在请求什么类型的操作。 表2 HTTP方法 方法 说明 GET 请求服务器返回指定资源。 PUT 请求服务器更新指定资源。 POST 请求服务器新增资源或执行特殊操作。 DELETE 请求服务器删除指定资源,如删除对象等。 HEAD 请求服务器资源头部。 PATCH 请求服务器更新资源的部分内容。 当资源不存在的时候,PATCH可能会去创建一个新的资源。 在获取用户Token的URI部分,您可以看到其请求方法为“POST”,则其请求为: 1 POST https://iam.cn-north-1.myhuaweicloud.com/v3/auth/tokens
  • 请求URI 请求URI由如下部分组成: {URI-scheme}://{Endpoint}/{resource-path}?{query-string} 尽管请求URI包含在请求消息头中,但大多数语言或框架都要求您从请求消息中单独传递它,所以在此单独强调。 表1 URI中的参数说明 参数 描述 URI-scheme 表示用于传输请求的协议,当前所有API均采用HTTPS协议。 Endpoint 指定承载REST服务端点的服务器域名或IP,不同服务不同区域的Endpoint不同,您可以从地区和终端节点获取。 例如IAM服务在“华北-北京四”区域的Endpoint为“iam.cn-north-4.myhuaweicloud.com”。 resource-path 资源路径,即API访问路径。从具体API的URI模块获取,例如“获取用户Token”API的resource-path为“/v3/auth/tokens”。 query-string 查询参数,是可选部分,并不是每个API都有查询参数。查询参数前面需要带一个“?”,形式为“参数名=参数取值”,例如“?limit=10”,表示查询不超过10条数据。 例如您需要获取IAM在“华北-北京四”区域的Token,则需使用“华北-北京四”区域的Endpoint(iam.cn-north-4.myhuaweicloud.com),并在获取用户Token的URI部分找到resource-path(/v3/auth/tokens),拼接起来如下所示。 1 https://iam.cn-north-4.myhuaweicloud.com/v3/auth/tokens 图1 URI示意图 为方便查看,在每个具体API的URI部分,只给出resource-path部分,并将请求方法写在一起。这是因为URI-scheme都是HTTPS,而Endpoint在同一个区域也相同,所以简洁起见将这两部分省略。
  • 响应示例 状态码: 200 OK { "apiVersion" : "v1", "groupVersion" : "metrics.k8s.io/v1beta1", "kind" : "APIResourceList", "resources" : [ { "kind" : "NodeMetrics", "name" : "nodes", "namespaced" : false, "singularName" : "", "verbs" : [ "get", "list" ] }, { "kind" : "PodMetrics", "name" : "pods", "namespaced" : true, "singularName" : "", "verbs" : [ "get", "list" ] } ] }
  • 状态码 状态码 描述 200 OK 400 BadRequest 401 Unauthorized 403 Forbidden 404 NotFound 405 MethodNotAllowed 406 NotAcceptable 409 Conflict 415 UnsupportedMediaType 422 Invalid 429 TooManyRequests 500 InternalError 503 ServiceUnavailable 504 ServerTimeout
  • 响应参数 状态码: 200 表2 响应Body参数 参数 参数类型 描述 apiVersion String APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources groupVersion String groupVersion is the group and version this APIResourceList is for. kind String Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds resources Array of io.k8s.apimachinery.pkg.apis.meta.v1.APIResource objects resources contains the name of the resources and if they are namespaced. 表3 io.k8s.apimachinery.pkg.apis.meta.v1.APIResource 参数 参数类型 描述 categories Array of strings categories is a list of the grouped resources this resource belongs to (e.g. 'all') group String group is the preferred group of the resource. Empty implies the group of the containing resource list. For subresources, this may have a different value, for example: Scale". kind String kind is the kind for the resource (e.g. 'Foo' is the kind for a resource 'foo') name String name is the plural name of the resource. namespaced Boolean namespaced indicates if a resource is namespaced or not. shortNames Array of strings shortNames is a list of suggested short names of the resource. singularName String singularName is the singular name of the resource. This allows clients to handle plural and singular opaquely. The singularName is more correct for reporting status on a single item and both singular and plural are allowed from the kubectl CLI interface. storageVersionHash String The hash value of the storage version, the version this resource is converted to when written to the data store. Value must be treated as opaque by clients. Only equality comparison on the value is valid. This is an alpha feature and may change or be removed in the future. The field is populated by the apiserver only if the StorageVersionHash feature gate is enabled. This field will remain optional even if it graduates. verbs Array of strings verbs is a list of supported kube verbs (this includes get, list, watch, create, update, patch, delete, deletecollection, and proxy) version String version is the preferred version of the resource. Empty implies the version of the containing resource list For subresources, this may have a different value, for example: v1 (while inside a v1beta1 version of the core resource's group)".
  • 响应示例 状态码: 200 OK { "apiVersion" : "rbac.authorization.k8s.io/v1", "kind" : "RoleBinding", "metadata" : { "creationTimestamp" : "2020-04-07T08:25:46Z", "name" : "clusterrole_view_User_07b82a44a680d5661f01c00b448f8f50", "namespace" : "rbac-test", "resourceVersion" : "230511279", "selfLink" : "/apis/rbac.authorization.k8s.io/v1/namespaces/rbac-test/rolebindings/clusterrole_view_User_07b82a44a680d5661f01c00b448f8f50", "uid" : "6163c216-78a9-11ea-bcc5-340a9837e2a7" }, "roleRef" : { "apiGroup" : "rbac.authorization.k8s.io", "kind" : "ClusterRole", "name" : "view" }, "subjects" : [ { "apiGroup" : "rbac.authorization.k8s.io", "kind" : "User", "name" : "07b82a44a680d5661f01c00b448f8f50" } ] }
  • URI GET /apis/rbac.authorization.k8s.io/v1/namespaces/{namespace}/rolebindings/{name} 表1 路径参数 参数 是否必选 参数类型 描述 name 是 String name of the RoleBinding namespace 是 String object name and auth scope, such as for teams and projects 表2 Query参数 参数 是否必选 参数类型 描述 pretty 否 String If 'true', then the output is pretty printed.
  • 状态码 状态码 描述 200 OK 400 BadRequest 401 Unauthorized 403 Forbidden 404 NotFound 405 MethodNotAllowed 406 NotAcceptable 409 Conflict 415 UnsupportedMediaType 422 Invalid 429 TooManyRequests 500 InternalError 503 ServiceUnavailable 504 ServerTimeout
  • 状态码 状态码 描述 200 OK 400 BadRequest 401 Unauthorized 403 Forbidden 404 NotFound 405 MethodNotAllowed 406 NotAcceptable 409 Conflict 415 UnsupportedMediaType 422 Invalid 429 TooManyRequests 500 InternalError 503 ServiceUnavailable 504 ServerTimeout
  • URI GET /api/v1/pods 表1 Query参数 参数 是否必选 参数类型 描述 allowWatchBookmarks 否 Boolean allowWatchBookmarks requests watch events with type "BOOKMARK". Servers that do not implement bookmarks may ignore this flag and bookmarks are sent at the server's discretion. Clients should not assume bookmarks are returned at any specific interval, nor may they assume the server will send any BOOKMARK event during a session. If this is not a watch, this field is ignored. If the feature gate WatchBookmarks is not enabled in apiserver, this field is ignored. continue 否 String The continue option should be set when retrieving more results from the server. Since this value is server defined, clients may only use the continue value from a previous query result with identical query parameters (except for the value of continue) and the server may reject a continue value it does not recognize. If the specified continue value is no longer valid whether due to expiration (generally five to fifteen minutes) or a configuration change on the server, the server will respond with a 410 ResourceExpired error together with a continue token. If the client needs a consistent list, it must restart their list without the continue field. Otherwise, the client may send another list request with the token received with the 410 error, the server will respond with a list starting from the next key, but from the latest snapshot, which is inconsistent from the previous list results - objects that are created, modified, or deleted after the first list request will be included in the response, as long as their keys are after the "next key". This field is not supported when watch is true. Clients may start a watch from the last resourceVersion value returned by the server and not miss any modifications. fieldSelector 否 String A selector to restrict the list of returned objects by their fields. Defaults to everything. labelSelector 否 String A selector to restrict the list of returned objects by their labels. Defaults to everything. limit 否 Integer limit is a maximum number of responses to return for a list call. If more items exist, the server will set the continue field on the list metadata to a value that can be used with the same initial query to retrieve the next set of results. Setting a limit may return fewer than the requested amount of items (up to zero items) in the event all requested objects are filtered out and clients should only use the presence of the continue field to determine whether more results are available. Servers may choose not to support the limit argument and will return all of the available results. If limit is specified and the continue field is empty, clients may assume that no more results are available. This field is not supported if watch is true. The server guarantees that the objects returned when using continue will be identical to issuing a single list call without a limit - that is, no objects created, modified, or deleted after the first request is issued will be included in any subsequent continued requests. This is sometimes referred to as a consistent snapshot, and ensures that a client that is using limit to receive smaller chunks of a very large result can ensure they see all possible objects. If objects are updated during a chunked list the version of the object that was present at the time the first list result was calculated is returned. pretty 否 String If 'true', then the output is pretty printed. resourceVersion 否 String resourceVersion sets a constraint on what resource versions a request may be served from. See https://kubernetes.io/docs/reference/using-api/api-concepts/#resource-versions for details. Defaults to unset resourceVersionMatch 否 String resourceVersionMatch determines how resourceVersion is applied to list calls. It is highly recommended that resourceVersionMatch be set for list calls where resourceVersion is set See https://kubernetes.io/docs/reference/using-api/api-concepts/#resource-versions for details. Defaults to unset timeoutSeconds 否 Integer Timeout for the list/watch call. This limits the duration of the call, regardless of any activity or inactivity. watch 否 Boolean Watch for changes to the described resources and return them as a stream of add, update, and remove notifications. Specify resourceVersion.
  • 响应示例 状态码: 200 OK { "apiVersion" : "v1", "items" : [ { "metadata" : { "annotations" : { "kubernetes.io/created-by" : "{\"kind\":\"SerializedReference\",\"apiVersion\":\"v1\",\"reference\":{\"kind\":\"ReplicationController\",\"namespace\":\"default\",\"name\":\"fdsfsd\",\"uid\":\"7539c329-57c4-11e7-afb7-fa163e218692\",\"apiVersion\":\"v1\",\"resourceVersion\":\"956153\"}}", "kubernetes.io/limit-ranger" : "LimitRanger plugin set: cpu request for container container01" }, "creationTimestamp" : "2017-06-23T03:31:35Z", "generateName" : "fdsfsd-", "labels" : { "cce/appgroup" : "gfsad", "name" : "fdsfsd" }, "name" : "fdsfsd-ddnft", "namespace" : "default", "ownerReferences" : [ { "apiVersion" : "v1", "controller" : true, "kind" : "ReplicationController", "name" : "fdsfsd", "uid" : "7539c329-57c4-11e7-afb7-fa163e218692" } ], "resourceVersion" : "1449034", "selfLink" : "/api/v1/namespaces/default/pods/fdsfsd-ddnft", "uid" : "753a45bc-57c4-11e7-afb7-fa163e218692" }, "spec" : { "containers" : [ { "image" : "10.154.52.159:443/test/apache-php:latest", "imagePullPolicy" : "Always", "name" : "container01", "ports" : [ { "containerPort" : 80, "protocol" : "TCP" } ], "resources" : { "requests" : { "cpu" : "100m" } }, "terminationMessagePath" : "/dev/termination-log", "volumeMounts" : [ { "mountPath" : "/var/run/secrets/kubernetes.io/serviceaccount", "name" : "default-token-863rh", "readOnly" : true } ] } ], "dnsPolicy" : "ClusterFirst", "imagePullSecrets" : [ { "name" : "myregistry" } ], "nodeName" : "192.168.12.187", "restartPolicy" : "Always", "securityContext" : { }, "serviceAccount" : "default", "serviceAccountName" : "default", "volumes" : [ { "name" : "default-token-863rh", "secret" : { "defaultMode" : 420, "secretName" : "default-token-863rh" } } ] }, "status" : { "conditions" : [ { "lastProbeTime" : null, "lastTransitionTime" : "2017-06-23T03:31:36Z", "status" : "True", "type" : "Initialized" }, { "lastProbeTime" : null, "lastTransitionTime" : "2017-06-28T06:34:51Z", "status" : "True", "type" : "Ready" }, { "lastProbeTime" : null, "lastTransitionTime" : "2017-06-23T03:31:35Z", "status" : "True", "type" : "PodScheduled" } ], "containerStatuses" : [ { "containerID" : "docker://f3daa802f753d123fe66b2cba2e917725702f8d446c17541822a68f9d2414c6d", "image" : "10.154.52.159:443/test/apache-php:latest", "imageID" : "docker://sha256:2e233ad9329bd7f65572dd6acb1a03e8839c36abfdb1d1f9012d84d13cecf9fc", "lastState" : { }, "name" : "container01", "ready" : true, "restartCount" : 0, "state" : { "running" : { "startedAt" : "2017-06-28T06:34:46Z" } } } ], "hostIP" : "192.168.12.187", "phase" : "Running", "podIP" : "172.16.56.4", "startTime" : "2017-06-23T03:31:36Z" } } ], "kind" : "PodList", "metadata" : { "resourceVersion" : "1550321", "selfLink" : "/api/v1/pods" } }
  • 状态码 状态码 描述 200 OK 400 BadRequest 401 Unauthorized 403 Forbidden 404 NotFound 405 MethodNotAllowed 406 NotAcceptable 409 Conflict 415 UnsupportedMediaType 422 Invalid 429 TooManyRequests 500 InternalError 503 ServiceUnavailable 504 ServerTimeout
  • 响应参数 状态码: 200 表4 响应Body参数 参数 参数类型 描述 apiVersion String APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources code Integer Suggested HTTP return code for this status, 0 if not set. details io.k8s.apimachinery.pkg.apis.meta.v1.StatusDetails object Extended data associated with the reason. Each reason may define its own extended details. This field is optional and the data returned is not guaranteed to conform to any schema except that defined by the reason type. kind String Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds message String A human-readable description of the status of this operation. metadata io.k8s.apimachinery.pkg.apis.meta.v1.ListMeta object Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds reason String A machine-readable description of why this operation is in the "Failure" status. If this value is empty there is no information available. A Reason clarifies an HTTP status code but does not override it. status String Status of the operation. One of: "Success" or "Failure". More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status 表5 io.k8s.apimachinery.pkg.apis.meta.v1.StatusDetails 参数 参数类型 描述 causes Array of io.k8s.apimachinery.pkg.apis.meta.v1.StatusCause objects The Causes array includes more details associated with the StatusReason failure. Not all StatusReasons may provide detailed causes. group String The group attribute of the resource associated with the status StatusReason. kind String The kind attribute of the resource associated with the status StatusReason. On some operations may differ from the requested resource Kind. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds name String The name attribute of the resource associated with the status StatusReason (when there is a single name which can be described). retryAfterSeconds Integer If specified, the time in seconds before the operation should be retried. Some errors may indicate the client must take an alternate action for those errors this field may indicate how long to wait before taking the alternate action. uid String UID of the resource. (when there is a single resource which can be described). More info: http://kubernetes.io/docs/user-guide/identifiers#uids 表6 io.k8s.apimachinery.pkg.apis.meta.v1.StatusCause 参数 参数类型 描述 field String The field of the resource that has caused this error, as named by its JSON serialization. May include dot and postfix notation for nested attributes. Arrays are zero-indexed. Fields may appear more than once in an array of causes due to fields having multiple errors. Optional. Examples: "name" - the field "name" on the current resource "items[0].name" - the field "name" on the first array entry in "items" message String A human-readable description of the cause of the error. This field may be presented as-is to a reader. reason String A machine-readable description of the cause of the error. If this value is empty there is no information available. 表7 io.k8s.apimachinery.pkg.apis.meta.v1.ListMeta 参数 参数类型 描述 continue String continue may be set if the user set a limit on the number of items returned, and indicates that the server has more data available. The value is opaque and may be used to issue another request to the endpoint that served this list to retrieve the next set of available objects. Continuing a consistent list may not be possible if the server configuration has changed or more than a few minutes have passed. The resourceVersion field returned when using this continue value will be identical to the value in the first response, unless you have received this token from an error message. remainingItemCount Long remainingItemCount is the number of subsequent items in the list which are not included in this list response. If the list request contained label or field selectors, then the number of remaining items is unknown and the field will be left unset and omitted during serialization. If the list is complete (either because it is not chunking or because this is the last chunk), then there are no more remaining items and this field will be left unset and omitted during serialization. Servers older than v1.15 do not set this field. The intended use of the remainingItemCount is estimating the size of a collection. Clients should not rely on the remainingItemCount to be set or to be exact. resourceVersion String String that identifies the server's internal version of this object that can be used by clients to determine when objects have changed. Value must be treated as opaque by clients and passed unmodified back to the server. Populated by the system. Read-only. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#concurrency-control-and-consistency selfLink String selfLink is a URL representing this object. Populated by the system. Read-only. DEPRECATED Kubernetes will stop propagating this field in 1.20 release and the field is planned to be removed in 1.21 release.
  • 响应示例 状态码: 200 OK { "apiVersion" : "batch.volcano.sh/v1alpha1", "items" : [ { "apiVersion" : "batch.volcano.sh/v1alpha1", "kind" : "Job", "metadata" : { "creationTimestamp" : "2019-06-26T03:16:26Z", "generation" : 1, "labels" : { "app" : "patchlabel" }, "name" : "openmpi-hello-2-com", "namespace" : "cci-namespace-42263891", "resourceVersion" : "7695210", "selfLink" : "/apis/batch.volcano.sh/v1alpha1/namespaces/cci-namespace-42263891/jobs/openmpi-hello-2-com", "uid" : "c84d86f0-97c0-11e9-9d09-dc9914fb58e0" }, "spec" : { "minAvailable" : 1, "plugins" : { "env" : [ ], "ssh" : [ ], "svc" : [ ] }, "queue" : "default", "schedulerName" : "volcano", "tasks" : [ { "name" : "mpimaster", "policies" : [ { "action" : "CompleteJob", "event" : "TaskCompleted" } ], "replicas" : 1, "template" : { "spec" : { "containers" : [ { "command" : [ "/bin/sh", "-c", "MPI_HOST=`cat /etc/volcano/mpiworker.host | tr \"\\n\" \",\"`;\nmkdir -p /var/run/sshd; /usr/sbin/sshd;\nmpiexec --allow-run-as-root --host ${MPI_HOST} -np 2 mpi_hello_world 003e /home/re" ], "image" : "*.*.*.*:20202/l00427178/openmpi-hello:3.28", "name" : "mpimaster", "ports" : [ { "containerPort" : 22, "name" : "mpijob-port" } ], "resources" : { "limits" : { "cpu" : "250m", "memory" : "1Gi" }, "requests" : { "cpu" : "250m", "memory" : "1Gi" } }, "workingDir" : "/home" } ], "imagePullSecrets" : [ { "name" : "imagepull-secret" } ], "restartPolicy" : "OnFailure" } } }, { "name" : "mpiworker", "replicas" : 2, "template" : { "spec" : { "containers" : [ { "command" : [ "/bin/sh", "-c", "mkdir -p /var/run/sshd; /usr/sbin/sshd -D;" ], "image" : "*.*.*.*:20202/l00427178/openmpi-hello:3.28", "name" : "mpiworker", "ports" : [ { "containerPort" : 22, "name" : "mpijob-port" } ], "resources" : { "limits" : { "cpu" : "250m", "memory" : "1Gi" }, "requests" : { "cpu" : "250m", "memory" : "1Gi" } }, "workingDir" : "/home" } ], "imagePullSecrets" : [ { "name" : "imagepull-secret" } ], "restartPolicy" : "OnFailure" } } } ] }, "status" : { "minAvailable" : 1, "pending" : 3, "state" : { "phase" : "Inqueue" } } } ], "kind" : "JobList", "metadata" : { "continue" : "", "resourceVersion" : "7732232", "selfLink" : "/apis/batch.volcano.sh/v1alpha1/namespaces/cci-namespace-42263891/jobs" } }
  • URI DELETE /apis/batch.volcano.sh/v1alpha1/namespaces/{namespace}/jobs 表1 路径参数 参数 是否必选 参数类型 描述 namespace 是 String object name and auth scope, such as for teams and projects 表2 Query参数 参数 是否必选 参数类型 描述 allowWatchBookmarks 否 Boolean allowWatchBookmarks requests watch events with type "BOOKMARK". Servers that do not implement bookmarks may ignore this flag and bookmarks are sent at the server's discretion. Clients should not assume bookmarks are returned at any specific interval, nor may they assume the server will send any BOOKMARK event during a session. If this is not a watch, this field is ignored. If the feature gate WatchBookmarks is not enabled in apiserver, this field is ignored. continue 否 String The continue option should be set when retrieving more results from the server. Since this value is server defined, clients may only use the continue value from a previous query result with identical query parameters (except for the value of continue) and the server may reject a continue value it does not recognize. If the specified continue value is no longer valid whether due to expiration (generally five to fifteen minutes) or a configuration change on the server, the server will respond with a 410 ResourceExpired error together with a continue token. If the client needs a consistent list, it must restart their list without the continue field. Otherwise, the client may send another list request with the token received with the 410 error, the server will respond with a list starting from the next key, but from the latest snapshot, which is inconsistent from the previous list results - objects that are created, modified, or deleted after the first list request will be included in the response, as long as their keys are after the "next key". This field is not supported when watch is true. Clients may start a watch from the last resourceVersion value returned by the server and not miss any modifications. fieldSelector 否 String A selector to restrict the list of returned objects by their fields. Defaults to everything. labelSelector 否 String A selector to restrict the list of returned objects by their labels. Defaults to everything. limit 否 Integer limit is a maximum number of responses to return for a list call. If more items exist, the server will set the continue field on the list metadata to a value that can be used with the same initial query to retrieve the next set of results. Setting a limit may return fewer than the requested amount of items (up to zero items) in the event all requested objects are filtered out and clients should only use the presence of the continue field to determine whether more results are available. Servers may choose not to support the limit argument and will return all of the available results. If limit is specified and the continue field is empty, clients may assume that no more results are available. This field is not supported if watch is true. The server guarantees that the objects returned when using continue will be identical to issuing a single list call without a limit - that is, no objects created, modified, or deleted after the first request is issued will be included in any subsequent continued requests. This is sometimes referred to as a consistent snapshot, and ensures that a client that is using limit to receive smaller chunks of a very large result can ensure they see all possible objects. If objects are updated during a chunked list the version of the object that was present at the time the first list result was calculated is returned. resourceVersion 否 String resourceVersion sets a constraint on what resource versions a request may be served from. See https://kubernetes.io/docs/reference/using-api/api-concepts/#resource-versions for details. Defaults to unset resourceVersionMatch 否 String resourceVersionMatch determines how resourceVersion is applied to list calls. It is highly recommended that resourceVersionMatch be set for list calls where resourceVersion is set See https://kubernetes.io/docs/reference/using-api/api-concepts/#resource-versions for details. Defaults to unset timeoutSeconds 否 Integer Timeout for the list/watch call. This limits the duration of the call, regardless of any activity or inactivity. watch 否 Boolean Watch for changes to the described resources and return them as a stream of add, update, and remove notifications. Specify resourceVersion. pretty 否 String If 'true', then the output is pretty printed.
  • 状态码 状态码 描述 200 OK 201 Created 400 BadRequest 401 Unauthorized 403 Forbidden 404 NotFound 405 MethodNotAllowed 406 NotAcceptable 409 Conflict 415 UnsupportedMediaType 422 Invalid 429 TooManyRequests 500 InternalError 503 ServiceUnavailable 504 ServerTimeout
  • 响应示例 状态码: 200 OK { "apiVersion" : "v1", "kind" : "Service", "metadata" : { "annotations" : { "kubernetes.io/elb.class" : "dnat", "kubernetes.io/natgateway.id" : "4ed25dd6-1887-439f-aef6-b1e3f2b57b5c", "tenant.kubernetes.io/domain-id" : "08a2c8ef8180d4150ff5c0012463ee60", "tenant.kubernetes.io/project-id" : "08a2c8ef8d80d4152ff8c001d0281c03" }, "creationTimestamp" : "2022-09-06T06:28:09Z", "finalizers" : [ "service.kubernetes.io/load-balancer-cleanup" ], "labels" : { "app" : "service-test" }, "name" : "service-test", "namespace" : "namespace-test", "resourceVersion" : "41521168", "selfLink" : "/api/v1/namespaces/namespace-test/services/service-test", "uid" : "7dfc42ef-f938-401c-b44a-1f7bd79b3fcb" }, "spec" : { "clusterIP" : "10.247.64.172", "externalTrafficPolicy" : "Cluster", "loadBalancerIP" : "100.93.1.98", "ports" : [ { "name" : "service0", "nodePort" : 31966, "port" : 30157, "protocol" : "TCP", "targetPort" : 80 } ], "selector" : { "app" : "service-test" }, "sessionAffinity" : "None", "type" : "LoadBalancer" }, "status" : { "loadBalancer" : { } } }
  • URI PUT /api/v1/namespaces/{namespace}/services/{name} 表1 路径参数 参数 是否必选 参数类型 描述 name 是 String name of the Service namespace 是 String object name and auth scope, such as for teams and projects 表2 Query参数 参数 是否必选 参数类型 描述 dryRun 否 String When present, indicates that modifications should not be persisted. An invalid or unrecognized dryRun directive will result in an error response and no further processing of the request. Valid values are: - All: all dry run stages will be processed fieldManager 否 String fieldManager is a name associated with the actor or entity that is making these changes. The value must be less than or 128 characters long, and only contain printable characters, as defined by https://golang.org/pkg/unicode/#IsPrint. pretty 否 String If 'true', then the output is pretty printed.
  • 请求示例 将已创建Service的名称替换为“service-test”。 { "apiVersion" : "v1", "kind" : "Service", "metadata" : { "annotations" : { "kubernetes.io/elb.class" : "dnat", "kubernetes.io/natgateway.id" : "4ed25dd6-1887-439f-aef6-b1e3f2b57b5c", "tenant.kubernetes.io/domain-id" : "08a2c8ef8180d4150ff5c0012463ee60", "tenant.kubernetes.io/project-id" : "08a2c8ef8d80d4152ff8c001d0281c03" }, "creationTimestamp" : "2022-09-06T06:28:09Z", "finalizers" : [ "service.kubernetes.io/load-balancer-cleanup" ], "labels" : { "app" : "service-test" }, "name" : "service-test", "namespace" : "namespace-test", "resourceVersion" : "41521168", "selfLink" : "/api/v1/namespaces/namespace-test/services/service-test", "uid" : "7dfc42ef-f938-401c-b44a-1f7bd79b3fcb" }, "spec" : { "clusterIP" : "10.247.64.172", "externalTrafficPolicy" : "Cluster", "loadBalancerIP" : "100.93.1.98", "ports" : [ { "name" : "service0", "nodePort" : 31966, "port" : 30157, "protocol" : "TCP", "targetPort" : 80 } ], "selector" : { "app" : "service-test" }, "sessionAffinity" : "None", "type" : "LoadBalancer" }, "status" : { "loadBalancer" : { } } }
  • 响应示例 状态码: 200 OK { "apiVersion" : "v1", "kind" : "APIGroup", "name" : "batch.volcano.sh", "preferredVersion" : { "groupVersion" : "batch.volcano.sh/v1alpha1", "version" : "v1alpha1" }, "versions" : [ { "groupVersion" : "batch.volcano.sh/v1alpha1", "version" : "v1alpha1" } ] }
  • 状态码 状态码 描述 200 OK 400 BadRequest 401 Unauthorized 403 Forbidden 404 NotFound 405 MethodNotAllowed 406 NotAcceptable 409 Conflict 415 UnsupportedMediaType 422 Invalid 429 TooManyRequests 500 InternalError 503 ServiceUnavailable 504 ServerTimeout
  • 响应参数 状态码: 200 表2 响应Body参数 参数 参数类型 描述 apiVersion String APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources kind String Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds name String name is the name of the group. preferredVersion io.k8s.apimachinery.pkg.apis.meta.v1.GroupVersionForDiscovery object preferredVersion is the version preferred by the API server, which probably is the storage version. serverAddressByClientCIDRs Array of io.k8s.apimachinery.pkg.apis.meta.v1.ServerAddressByClientCIDR objects a map of client CIDR to server address that is serving this group. This is to help clients reach servers in the most network-efficient way possible. Clients can use the appropriate server address as per the CIDR that they match. In case of multiple matches, clients should use the longest matching CIDR. The server returns only those CIDRs that it thinks that the client can match. For example: the master will return an internal IP CIDR only, if the client reaches the server using an internal IP. Server looks at X-Forwarded-For header or X-Real-Ip header or request.RemoteAddr (in that order) to get the client IP. versions Array of io.k8s.apimachinery.pkg.apis.meta.v1.GroupVersionForDiscovery objects versions are the versions supported in this group. 表3 io.k8s.apimachinery.pkg.apis.meta.v1.GroupVersionForDiscovery 参数 参数类型 描述 groupVersion String groupVersion specifies the API group and version in the form "group/version" version String version specifies the version in the form of "version". This is to save the clients the trouble of splitting the GroupVersion. 表4 io.k8s.apimachinery.pkg.apis.meta.v1.ServerAddressByClientCIDR 参数 参数类型 描述 clientCIDR String The CIDR with which clients can match their IP to figure out the server address that they should use. serverAddress String Address of this server, suitable for a client that matches the above CIDR. This can be a hostname, hostname:port, IP or IP:port.
  • 响应示例 状态码: 200 OK { "apiVersion" : "v1", "items" : [ { "metadata" : { "creationTimestamp" : "2017-06-24T02:05:16Z", "name" : "default", "resourceVersion" : "6", "selfLink" : "/api/v1/namespaces/default", "uid" : "90dd5244-5881-11e7-b5d7-fa163e08a2fd" }, "spec" : { "finalizers" : [ "kubernetes" ] }, "status" : { "phase" : "Active" } }, { "metadata" : { "creationTimestamp" : "2017-06-24T02:05:17Z", "name" : "kube-system", "resourceVersion" : "25", "selfLink" : "/api/v1/namespaces/kube-system", "uid" : "9178fce6-5881-11e7-b5d7-fa163e08a2fd" }, "spec" : { "finalizers" : [ "kubernetes" ] }, "status" : { "phase" : "Active" } } ], "kind" : "NamespaceList", "metadata" : { "resourceVersion" : "594181", "selfLink" : "/api/v1/namespaces" } }
共100000条