Kubernetes中使用Node授權_Kubernetes中文社群
阿新 • • 發佈:2018-12-27
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的訪問,則執行:
- 啟用Node授權模式(–authorization-mode=Node,RBAC)和NodeRestriction 准入外掛
- 確保所有kubelet的證書符合 group/username 要求
- 檢查apiserver日誌,確保Node授權器接受kubelets的請求(不NODE DENY記錄永續性訊息)
- 刪除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繫結到叢集角色的方法。