一、前言
一般情况下Tiller 管理访问整个集群。当然,Tiller 正常工作并不一定要为它设置集群管理员访问权限。我们可以指定 Role 和 RoleBinding 来将 Tiller 的范围限制为特定的 namespace,而不是指定 ClusterRole 或 ClusterRoleBinding。
二、部署
$ kubectl create namespace tiller-world
namespace "tiller-world" created
$ kubectl create serviceaccount tiller --namespace tiller-world
serviceaccount "tiller" created
定义允许 Tiller 管理 namespace tiller-world
中所有资源的角色 ,文件 role-tiller.yaml
:
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: tiller-manager
namespace: tiller-world
rules:
- apiGroups: ["","extensions","apps"]
resources: ["*"]
verbs: ["*"]
$ kubectl create -f role-tiller.yaml
role "tiller-manager" created
文件 rolebinding-tiller.yaml
,
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: tiller-binding
namespace: tiller-world
subjects:
- kind: ServiceAccount
name: tiller
namespace: tiller-world
roleRef:
kind: Role
name: tiller-manager
apiGroup: rbac.authorization.k8s.io
$ kubectl create -f rolebinding-tiller.yaml
rolebinding "tiller-binding" created
之后,运行 helm init
来在 tiller-world
namespace 中安装 Tiller 。
三、参考文章
https://whmzsu.github.io/helm-doc-zh-cn/quickstart/rbac-zh_cn.html