Kubernetes原始API资源类型

xcitsw88  于 2022-11-02  发布在  Kubernetes
关注(0)|答案(1)|浏览(147)

对于原始类型,我应该使用什么RBAC角色资源类型?
例如kubectl get --raw "/api/v1/nodes/(your-node-name)/proxy/stats/summary"

kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: k8s-ephemeral-storage-metrics-debug
rules:
  - apiGroups: [""]
    resources: ["*"]
    verbs: ["*"]

还是直接调用API k8s?

content, err := clientset.RESTClient().Get().AbsPath(fmt.Sprintf("/api/v1/nodes/%s/proxy/stats/summary", currentNode)).DoRaw(context.Background())
gmol1639

gmol16391#

API文档将此操作命名为“获取Connect代理路径”,并将URL具体描述为

GET /api/v1/nodes/{name}/proxy/{path}

.../proxy/...部分是有趣的部分。它表明您没有在Node对象上使用基本的CRUD操作,而是访问Node的某些 subresource。RBAC设置有针对子资源的特定语法。
您需要将URL分解为几个组成部分您可以将其分解为几个组成部分:

(no API group)
        v
GET /api/v1/nodes/{name}/proxy/{path}
            ^^^^^        ^^^^^
           resource   subresource

然后,在RBAC定义中使用resource/subresource名称

kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: k8s-ephemeral-storage-metrics-debug
rules:
  - apiGroups: [""]
    resources: ["node/proxy"]
    verbs: ["get"]

相关问题