【问题标题】:Kubernetes Raw API resource typeKubernetes 原始 API 资源类型
【发布时间】:2022-10-23 19:00:44
【问题描述】:

我将使用哪种 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())

【问题讨论】:

    标签: go kubernetes


    【解决方案1】:

    API documentation 将此操作命名为“获取连接代理路径”,并将 URL 更具体地描述为

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

    .../proxy/... 部分是有趣的部分。它表明您没有在 Node 对象上使用基本的 CRUD 操作,而是访问一些子资源的节点。 RBAC 设置有specific syntax for subresources

    您需要将 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"]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-06-14
      • 1970-01-01
      • 2015-11-18
      • 1970-01-01
      • 1970-01-01
      • 2019-08-06
      • 2018-07-09
      相关资源
      最近更新 更多