您好,登錄后才能下訂單哦!
本篇文章為大家展示了k8s用戶管理工具Permissionmanager怎么用,內容簡明扼要并且容易理解,絕對能使你眼前一亮,通過這篇文章的詳細介紹希望你能有所收獲。
Permission Manager
Permission Manager是一個為Kubernetes RBAC和用戶管理提供Web UI的項目,為Kubernetes權限管理提供友好的可視化界面。
安裝
從 https://github.com/sighupio/permission-manager/tree/master/deployments/kubernetes 把yaml文件下載下來,如下
[root@qd01-stop-k8s-master001 kubernetes]# ll total 4 -rw-r--r-- 1 root root 2697 Jan 28 11:08 deploy.yml drwxr-xr-x 2 root root 37 Jan 28 11:14 seeds
創建namespace
[root@qd01-stop-k8s-master001 kubernetes]# kubectl create namespace permission-manager namespace/permission-manager created
創建秘密并進行相應更新
[rancher@qd01-stop-k8snode011 permission-manager]$ cat secret.yaml
---
apiVersion: v1
kind: Secret
metadata:
name: permission-manager
namespace: permission-manager
type: Opaque
stringData:
PORT: "4000" # port where server is exposed
CLUSTER_NAME: "kubernetes-cluster" # name of the cluster to use in the generated kubeconfig file
CONTROL_PLANE_ADDRESS: "https://10.26.29.208:6443" # full address of the control plane to use in the generated kubeconfig file
BASIC_AUTH_PASSWORD: "Admin" # password used by basic auth (username is `admin`)
[root@qd01-stop-k8s-master001 kubernetes]# kubectl apply -f secret.yaml secret/permission-manager created
部署
[root@qd01-stop-k8s-master001 seeds]# kubectl apply -f crd.yml Warning: apiextensions.k8s.io/v1beta1 CustomResourceDefinition is deprecated in v1.16+, unavailable in v1.22+; use apiextensions.k8s.io/v1 CustomResourceDefinition customresourcedefinition.apiextensions.k8s.io/permissionmanagerusers.permissionmanager.user created [root@qd01-stop-k8s-master001 seeds]# kubectl apply -f seed.yml clusterrole.rbac.authorization.k8s.io/template-namespaced-resources___operation created clusterrole.rbac.authorization.k8s.io/template-namespaced-resources___developer created clusterrole.rbac.authorization.k8s.io/template-cluster-resources___read-only created clusterrole.rbac.authorization.k8s.io/template-cluster-resources___admin created [root@qd01-stop-k8s-master001 kubernetes]# kubectl apply -f deploy.yml service/permission-manager created deployment.apps/permission-manager created serviceaccount/permission-manager created clusterrole.rbac.authorization.k8s.io/permission-manager created Warning: rbac.authorization.k8s.io/v1beta1 ClusterRoleBinding is deprecated in v1.17+, unavailable in v1.22+; use rbac.authorization.k8s.io/v1 ClusterRoleBinding clusterrolebinding.rbac.authorization.k8s.io/permission-manager created
以上就把permission-manager部署好了,Warning信息可忽略或者自行修改yaml文件中api版本為rbac.authorization.k8s.io/v1
使用ingress暴露服務
創建ingress.yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: permission-manager-ingress
namespace: permission-manager
annotations:
kubernetes.io/ingress.class: nginx
spec:
rules:
- host: permission.kubeops.net
http:
paths:
- pathType: Prefix
path: /
backend:
service:
name: permission-manager
port:
number: 4000
[root@qd01-stop-k8s-master001 kubernetes]# kubectl apply -f ingress.yaml [root@qd01-stop-k8s-master001 kubernetes]# kubectl get ing -n permission-manager Warning: extensions/v1beta1 Ingress is deprecated in v1.14+, unavailable in v1.22+; use networking.k8s.io/v1 Ingress NAME CLASS HOSTS ADDRESS PORTS AGE permission-manager-ingress <none> permission.kubeops.net 10.26.29.202,10.26.29.203 80 4m8s
自行添加dns解析,然后瀏覽器訪問permission.kubeops.net,使用用戶名密碼(在secret中設置的)登錄
登錄
目前沒有任何的用戶,我們可以創建一個普通用戶測試下
創建用戶
點擊Create New User
填寫相關信息
然后點擊Save即可
在用戶信息下可以查看生成的config文件
測試
保存config文件,然后使用這個配置文件訪問集群
我這里把config文件拷貝到本地,重命名為scofield,使用kubectl測試
[root@qd01-stop-k8s-master001 kubernetes]# kubectl --kubeconfig=scofield get po No resources found in default namespace. [root@qd01-stop-k8s-master001 kubernetes]# kubectl --kubeconfig=scofield get po -n argo Error from server (Forbidden): pods is forbidden: User "system:serviceaccount:permission-manager:scofield" cannot list resource "pods" in API group "" in the namespace "argo"
從以上輸出可以看出,我分別查詢的兩個namespace,分別是default和argo,但是只有default這個命名空間有權限,而argo這個命名空間是沒有權限操作的。這跟我們在創建用戶是賦予的權限是一致的。
上述內容就是k8s用戶管理工具Permissionmanager怎么用,你們學到知識或技能了嗎?如果還想學到更多技能或者豐富自己的知識儲備,歡迎關注億速云行業資訊頻道。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。