文档首页 > > API参考> Kubernetes API> RBAC> Role> 获取Role列表

获取Role列表

分享
更新时间:2020/06/23 GMT+08:00

功能介绍

This API is used to list or watch objects of kind Role

URL

GET /apis/rbac.authorization.k8s.io/v1/roles

参数解释描述该API的参数。

表1 参数解释

参数

是否必选

描述

continue

No

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 indicating the client must restart their list without the continue field. 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

No

A selector to restrict the list of returned objects by their fields. Defaults to everything.

includeUninitialized

No

If true, partially initialized resources are included in the response.

labelSelector

No

A selector to restrict the list of returned objects by their labels. Defaults to everything.

limit

No

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

No

If true, then the output is pretty printed.

resourceVersion

No

When specified with a watch call, shows changes that occur after that particular version of a resource. Defaults to changes from the beginning of history. When specified for list: - if unset, then the result is returned from remote storage based on quorum-read flag; - if it's 0, then we simply return what we currently have in cache, no guarantee; - if set to non zero, then the result is at least as fresh as given rv.

timeoutSeconds

No

Timeout for the list/watch call.

watch

No

Watch for changes to the described resources and return them as a stream of add, update, and remove notifications. Specify resourceVersion.

请求消息

N/A

响应消息

响应参数:

响应参数的详细描述请参见请求参数

响应示例:

{
    "kind" : "RoleList",
    "apiVersion" : "rbac.authorization.k8s.io/v1",
    "metadata" : {
        "selfLink" : "/apis/rbac.authorization.k8s.io/v1/roles",
        "resourceVersion" : "4628"
    },
    "items" : [ {
        "metadata" : {
            "name" : "pod-reader",
            "namespace" : "default",
            "selfLink" : "/apis/rbac.authorization.k8s.io/v1/namespaces/default/roles/secret-reader",
            "uid" : "8e7afa24-f1e7-11e8-b449-fa163ec24e06",
            "resourceVersion" : "4627",
            "creationTimestamp" : "2018-11-27T01:55:46Z"
        },
        "rules" : [ {
            "verbs" : [ "get", "watch", "list" ],
            "apiGroups" : [ "" ],
            "resources" : [ "pods" ]
        } ]
    }, {
    "metadata" : {
        "name" : "system:controller:bootstrap-signer",
        "namespace" : "kube-public",
        "selfLink" : "/apis/rbac.authorization.k8s.io/v1/namespaces/kube-public/roles/system%3Acontroller%3Abootstrap-signer",
        "uid" : "c3c553ae-f1e2-11e8-b449-fa163ec24e06",
        "resourceVersion" : "127",
        "creationTimestamp" : "2018-11-27T01:21:28Z",
        "labels" : {
            "kubernetes.io/bootstrapping" : "rbac-defaults"
        },
        "annotations" : {
            "rbac.authorization.k8s.io/autoupdate" : "true"
        }
    },
    "rules" : [ {
        "verbs" : [ "get", "list", "watch" ],
        "apiGroups" : [ "" ],
        "resources" : [ "configmaps" ]
    }, {
    "verbs" : [ "update" ],
    "apiGroups" : [ "" ],
    "resources" : [ "configmaps" ],
    "resourceNames" : [ "cluster-info" ]
    }, {
    "verbs" : [ "create", "patch", "update" ],
    "apiGroups" : [ "" ],
    "resources" : [ "events" ]
    } ]
    }, {
    "metadata" : {
        "name" : "extension-apiserver-authentication-reader",
        "namespace" : "kube-system",
        "selfLink" : "/apis/rbac.authorization.k8s.io/v1/namespaces/kube-system/roles/extension-apiserver-authentication-reader",
        "uid" : "c398c5a1-f1e2-11e8-b449-fa163ec24e06",
        "resourceVersion" : "121",
        "creationTimestamp" : "2018-11-27T01:21:28Z",
        "labels" : {
            "kubernetes.io/bootstrapping" : "rbac-defaults"
        },
        "annotations" : {
            "rbac.authorization.k8s.io/autoupdate" : "true"
        }
    },
    "rules" : [ {
        "verbs" : [ "get" ],
        "apiGroups" : [ "" ],
        "resources" : [ "configmaps" ],
        "resourceNames" : [ "extension-apiserver-authentication" ]
    } ]
    }, {
    "metadata" : {
        "name" : "system::leader-locking-kube-controller-manager",
        "namespace" : "kube-system",
        "selfLink" : "/apis/rbac.authorization.k8s.io/v1/namespaces/kube-system/roles/system%3A%3Aleader-locking-kube-controller-manager",
        "uid" : "c3bf1246-f1e2-11e8-b449-fa163ec24e06",
        "resourceVersion" : "125",
        "creationTimestamp" : "2018-11-27T01:21:28Z",
        "labels" : {
        "kubernetes.io/bootstrapping" : "rbac-defaults"
        },
        "annotations" : {
            "rbac.authorization.k8s.io/autoupdate" : "true"
        }
    },
    "rules" : [ {
        "verbs" : [ "watch" ],
        "apiGroups" : [ "" ],
        "resources" : [ "configmaps" ]
    }, {
    "verbs" : [ "get", "update" ],
    "apiGroups" : [ "" ],
    "resources" : [ "configmaps" ],
    "resourceNames" : [ "kube-controller-manager" ]
    } ]
    }, {
    "metadata" : {
        "name" : "system::leader-locking-kube-scheduler",
        "namespace" : "kube-system",
        "selfLink" : "/apis/rbac.authorization.k8s.io/v1/namespaces/kube-system/roles/system%3A%3Aleader-locking-kube-scheduler",
        "uid" : "c3c1ddd6-f1e2-11e8-b449-fa163ec24e06",
        "resourceVersion" : "126",
        "creationTimestamp" : "2018-11-27T01:21:28Z",
        "labels" : {
             "kubernetes.io/bootstrapping" : "rbac-defaults"
        },
        "annotations" : {
            "rbac.authorization.k8s.io/autoupdate" : "true"
        }
    },
    "rules" : [ {
        "verbs" : [ "watch" ],
        "apiGroups" : [ "" ],
        "resources" : [ "configmaps" ]
    }, {
    "verbs" : [ "get", "update" ],
    "apiGroups" : [ "" ],
    "resources" : [ "configmaps" ],
    "resourceNames" : [ "kube-scheduler" ]
    } ]
    }, {
    "metadata" : {
        "name" : "system:controller:bootstrap-signer",
        "namespace" : "kube-system",
        "selfLink" : "/apis/rbac.authorization.k8s.io/v1/namespaces/kube-system/roles/system%3Acontroller%3Abootstrap-signer",
        "uid" : "c39edcc9-f1e2-11e8-b449-fa163ec24e06",
        "resourceVersion" : "122",
        "creationTimestamp" : "2018-11-27T01:21:28Z",
        "labels" : {
            "kubernetes.io/bootstrapping" : "rbac-defaults"
        },
        "annotations" : {
            "rbac.authorization.k8s.io/autoupdate" : "true"
        }
    },
    "rules" : [ {
        "verbs" : [ "get", "list", "watch" ],
        "apiGroups" : [ "" ],
        "resources" : [ "secrets" ]
    } ]
    }, {
    "metadata" : {
        "name" : "system:controller:cloud-provider",
        "namespace" : "kube-system",
        "selfLink" : "/apis/rbac.authorization.k8s.io/v1/namespaces/kube-system/roles/system%3Acontroller%3Acloud-provider",
        "uid" : "c3a4f1e3-f1e2-11e8-b449-fa163ec24e06",
        "resourceVersion" : "123",
        "creationTimestamp" : "2018-11-27T01:21:28Z",
        "labels" : {
            "kubernetes.io/bootstrapping" : "rbac-defaults"
        },
        "annotations" : {
            "rbac.authorization.k8s.io/autoupdate" : "true"
        }
    },
    "rules" : [ {
        "verbs" : [ "create", "get", "list", "watch" ],
        "apiGroups" : [ "" ],
        "resources" : [ "configmaps" ]
    } ]
    }, {
    "metadata" : {
        "name" : "system:controller:token-cleaner",
        "namespace" : "kube-system",
        "selfLink" : "/apis/rbac.authorization.k8s.io/v1/namespaces/kube-system/roles/system%3Acontroller%3Atoken-cleaner",
        "uid" : "c3bb6b6b-f1e2-11e8-b449-fa163ec24e06",
        "resourceVersion" : "124",
        "creationTimestamp" : "2018-11-27T01:21:28Z",
        "labels" : {
            "kubernetes.io/bootstrapping" : "rbac-defaults"
        },
        "annotations" : {
            "rbac.authorization.k8s.io/autoupdate" : "true"
        }
    },
    "rules" : [ {
        "verbs" : [ "delete", "get", "list", "watch" ],
        "apiGroups" : [ "" ],
        "resources" : [ "secrets" ]
        }, {
        "verbs" : [ "create", "patch", "update" ],
        "apiGroups" : [ "" ],
        "resources" : [ "events" ]
        } 
    ]
    } ]
}

状态码

状态码描述API的状态码。

表2 状态码

状态码

描述

200

OK

异常状态码请参见状态码

分享:

    相关文档

    相关产品

文档是否有解决您的问题?

提交成功!

非常感谢您的反馈,我们会继续努力做到更好!

反馈提交失败,请稍后再试!

*必选

请至少选择或填写一项反馈信息

字符长度不能超过200

提交反馈 取消

如您有其它疑问,您也可以通过华为云社区问答频道来与我们联系探讨

智能客服提问云社区提问