Kubernetes原始API资源类型

huangapple go评论84阅读模式
英文:

Kubernetes Raw API resource type

问题

你可以使用以下的 RBAC 角色资源类型来处理原始类型:

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

或者你可以使用原始的 API 调用来处理:

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

What RBAC role resource type would I use for raw type?

ex. 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: ["*"]

or go raw API k8s calls?


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

答案1

得分: 2

API文档将此操作命名为“获取连接代理路径”,并更详细地描述了URL:

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

其中的.../proxy/...部分是有趣的部分。它表示您不是在对Node对象使用基本的CRUD操作,而是访问Node的某个子资源。RBAC设置具有特定的子资源语法

您需要将URL拆分为其组成部分。您可以将其拆分为几个组成部分:

  (无API组)
        v
GET /api/v1/nodes/{name}/proxy/{path}
            ^^^^^        ^^^^^
           资源       子资源

然后在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"]
英文:

The API documentation names this operation "Get Connect Proxy Path" and more specifically describes the URL as

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

The .../proxy/... part is the interesting part. It indicates that you're not using basic CRUD operations on a Node object, but rather accessing some subresource of the Node. The RBAC setup has specific syntax for subresources.

You need to break the URL down into its component parts
You can break this down into several component parts:

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

You then use the resource/subresource name in the RBAC definition

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

huangapple
  • 本文由 发表于 2022年10月23日 08:36:33
  • 转载请务必保留本文链接:https://go.coder-hub.com/74167992.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定