Knative 服务组件权限

请通过本页面了解 Knative 服务组件为了维护对集群的访问权限而持有的 RBAC 权限。这些权限在 Knative 提供中是必需的,并且默认处于启用状态;请勿尝试停用。

组件 命名空间 服务账号
activator knative-serving controller
autoscaler knative-serving controller
controller knative-serving controller
webhook knative-serving controller
storage-version-migration-serving knative-serving controller
webhook knative-serving controller
cloud-run-operator cloud-run-system cloud-run-operator

请注意,cloud-run-operator 服务账号与 controller 具有相同的一组权限。Operator 负责部署所有 Knative 服务组件,包括自定义资源定义和控制器。

适用于 Knative 服务账号的 RBAC

使用以下 apiGroup 定义,了解对于 controllercloud-run-operator 服务帐号,每个资源在 Knative 服务中具有哪些访问权限控制权限。

- apiGroups:
  - ""
  resources:
  - pods
  - secrets
  verbs:
  - deletecollection
- apiGroups:
  - ""
  resources:
  - nodes
  verbs:
  - get
  - watch
  - list
- apiGroups:
  - ""
  resources:
  - pods
  - namespaces
  - secrets
  - configmaps
  - endpoints
  - services
  - events
  - serviceaccounts
  verbs:
  - get
  - list
  - create
  - update
  - delete
  - patch
  - watch
- apiGroups:
  - ""
  resources:
  - endpoints/restricted
  verbs:
  - create
- apiGroups:
  - ""
  resources:
  - namespaces/finalizers
  verbs:
  - update
- apiGroups:
  - apps
  resources:
  - deployments
  - deployments/finalizers
  verbs:
  - get
  - list
  - create
  - update
  - delete
  - patch
  - watch
- apiGroups:
  - admissionregistration.k8s.io
  resources:
  - mutatingwebhookconfigurations
  - validatingwebhookconfigurations
  verbs:
  - get
  - list
  - create
  - update
  - delete
  - patch
  - watch
- apiGroups:
  - apiextensions.k8s.io
  resources:
  - customresourcedefinitions
  - customresourcedefinitions/status
  verbs:
  - get
  - list
  - create
  - update
  - delete
  - patch
  - watch
- apiGroups:
  - autoscaling
  resources:
  - horizontalpodautoscalers
  verbs:
  - get
  - list
  - create
  - update
  - delete
  - patch
  - watch
- apiGroups:
  - coordination.k8s.io
  resources:
  - leases
  verbs:
  - get
  - list
  - create
  - update
  - delete
  - patch
  - watch
- apiGroups:
  - admissionregistration.k8s.io
  resources:
  - validatingwebhookconfigurations
  verbs:
  - get
  - list
  - create
  - update
  - delete
  - patch
  - watch

下表列出了如何在 Knative 服务中使用 RBAC 权限,其中:

  • view 包括以下动词:get、list、watch
  • modify 包括以下动词:create、update、delete、patch
权限 原因
可查看所有 secrets 网络钩子需要从 knative-serving 命名空间中读取 Secret。DomainMapping 控制器需要读取通过自动 TLS 功能生成的证书 Secret,然后将其复制到 gke-system 命名空间。
可修改 pods DomainMapping 控制器需要创建一个 Pod,以处理用于执行 HTTP01 人机验证的请求。
可修改 secrets DomainMapping 控制器需要创建或更新证书 Secret。网络钩子需要从 knative-serving 命名空间中读取 Secret。
可修改 configmaps 用于默认的网址功能。控制器需要更新“knative-serving”命名空间内的“config-domain” configmap 以添加“nip.io”网址。
可修改 endpoints Serverlessservice 控制器需要创建、更新或删除端点。Route 控制器需要创建、更新或删除端点。
可修改 services Route 控制器需要创建、更新或删除服务。Serverless 控制器需要创建、更新或删除服务。DomainMapping 控制器需要创建一项服务来处理 HTTP01 人机验证请求。
可修改 events Knative 服务控制器为由 Knative 管理的资源创建并发出事件。
可修改 serviceaccounts Knative 服务需要间接读取服务帐号。
可修改 endpoints/restricted 启用 RestrictedEndpointAdmission 后,Knative 服务需要创建端点。
可修改 deployments Revision 控制器需要为 Knative 服务创建或更新部署。
可修改 mutatingwebhookconfiguration Knative 网络钩子会将 caBundle 添加到 Knative 拥有的 mutatingwebhookconfigurations 中。
可修改 validatingwebhookconfiguration Knative 网络钩子会将 caBundle 添加到 Knative 拥有的 validatingwebhookconfigurations 中。
可修改 customresourcedifinitions customresourcedefinitions/status Knative 安装后作业需要将 Knative 相关的 CRD 升级到 v1 版。
可修改 horizontalpodautoscalers Knative 支持基于 HPA 的自动扩缩。
可修改 namespace/finalizer Knative 服务需要将 Ownerreference 设为 Knative-serving 命名空间。