ZBLOG

apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: name: prometheus rules: - apiGroups: [""] resources: - nodes - nodes/proxy - services - endpoints - pods verbs: ["get", "list", "watch"] - apiGroups: - extensi...

这是一个定义名为”prometheus”的ClusterRole的示例。该ClusterRole授予了一些常见资源的get、list和watch权限,并且还授予了”/metrics”路径上的非资源URL访问权限。

  • 对于apiGroups为空字符串”“的规则,它授权对以下资源的get、list和watch操作:

    • nodes
    • nodes/proxy
    • services
    • endpoints
    • pods
  • 对于apiGroups为”extensions”的规则,它授权对ingresses资源的get、list和watch操作。

  • 对于nonResourceURLs为”/metrics”的规则,它授权对该路径下的非资源URL进行get操作。

要创建此ClusterRole,将上述内容保存在一个YAML文件(例如cluster-role.yaml)中,并运行以下命令:

kubectl apply -f cluster-role.yaml

这将使用cluster-role.yaml文件中定义的内容来创建ClusterRole对象。你可以通过运行kubectl get clusterroles验证是否成功创建了名为”prometheus”的ClusterRole。

请根据你的需求和环境进行相应修改和调整。另外,请确保将该ClusterRole与适当的绑定(如RoleBinding或ClusterRoleBinding)相关联,以便将其分配给用户、组或ServiceAccount。


内容由零声教学AI助手提供,问题来源于学员提问

本站部分文章来源于网络,版权归原作者所有,如有侵权请联系站长删除。
转载请注明出处:https://golang.0voice.com/?id=11027

分享:
扫描分享到社交APP
上一篇
下一篇
发表列表
游客 游客
此处应有掌声~
评论列表

还没有评论,快来说点什么吧~

联系我们

在线咨询: 点击这里给我发消息

微信号:3007537140

上班时间: 10:30-22:30

关注我们
x

注册

已经有帐号?