【kubernets】——特定namespace 中部署 Tiller

一、前言

       一般情況下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

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