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綁定到集羣角色的方法。

本文轉自中文社區-Kubernetes中使用Node授權

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章