Kubernetes中使用Node授权

Node授权是一种特殊授权模式,专门授权由kubelet访问的API请求。

概述

Node授权器允许kubelet执行的API操作包括:

读:

  • services
  • endpoints
  • nodes
  • pods
  • secrets, configmaps, persistent volume claims and persistent volumes related to pods bound to the kubelet’s node

写:

  • Node和Node status(启用NodeRestriction准入插件限制kubelet仅修改当前的Node)
  • Pod和Pod status(启用NodeRestriction准入插件限制kubelet仅修改与当前绑定的pod)
  • events

Auth-related:

  • read/write access to the certificationsigningrequests API for TLS bootstrapping
  • the ability to create tokenreviews and subjectaccessreviews for delegated authentication/authorization checks

在以后的版本中,Node授权器支持添加或删除的权限。

为获得Node授权器的授权,kubelet需要使用system:nodes组中的用户名system:node:<nodeName>。

启用Node授权器方法:apiserver –authorization-mode=Node。

为了限制kubelets能够写入的API对象,可以启动–admission-control=…,NodeRestriction,…准入(admission)插件。

Migration considerations

外部Kubelets system:node组

Node授权模式不授权外部Kubelets system:node组。

使用RBAC来升级

使用RBAC升级,1.7之前按原样运行,因为system:nodes group binding 已经存在。

如果希望开始使用Node授权和NodeRestriction 准入插件来限制对API的访问,则执行:

  1. 启用Node授权模式(–authorization-mode=Node,RBAC)和NodeRestriction 准入插件
  2. 确保所有kubelet的证书符合 group/username 要求
  3. 检查apiserver日志,确保Node授权器接受kubelets的请求(不NODE DENY记录持久性消息)
  4. 删除system:node集群 role binding

RBAC Node权限

在1.6中,使用RBAC授权模式时,system:node群集角色(role)自动绑定到该system:nodes组。

在1.7中,由于Node授权器实现了相同的目的,因此不再支持system:nodes组与system:node角色的自动绑定,从而有利于对secret 和configmap访问的附加限制。

在1.8中,将不会创建binding。

使用RBAC时,将继续创建system:node集群角色,以便兼容使用deployment将其他users或groups绑定到集群角色的方法。

K8S中文社区微信公众号

评论 抢沙发

登录后评论

立即登录