kubernates dashboard管理界面安装及管理员用户配置

网友投稿 1257 2022-11-15

kubernates dashboard管理界面安装及管理员用户配置

kubernates dashboard管理界面安装及管理员用户配置

目录

​​1、执行以下命令安装 kubernetes-dashboard :​​

​​2、使用 kubectl get service --all-namespaces 查看,成功创建​​

​​3、配置dashboard为nodeport类型,便于访问​​

​​4、修改nodeport类型​​

​​5、 再次使用kubectl -n kubernetes-dashboard get service kubernetes-dashboard 查看服务,已成功修改。​​

1、执行以下命令安装 ​​kubernetes-dashboard​​ :

kubectl apply -f kubernates]# kubectl apply -f createdserviceaccount/kubernetes-dashboard createdservice/kubernetes-dashboard createdsecret/kubernetes-dashboard-certs createdsecret/kubernetes-dashboard-csrf createdsecret/kubernetes-dashboard-key-holder createdconfigmap/kubernetes-dashboard-settings createdrole.rbac.authorization.k8s.io/kubernetes-dashboard createdclusterrole.rbac.authorization.k8s.io/kubernetes-dashboard createdrolebinding.rbac.authorization.k8s.io/kubernetes-dashboard createdclusterrolebinding.rbac.authorization.k8s.io/kubernetes-dashboard createddeployment.apps/kubernetes-dashboard createdservice/dashboard-metrics-scraper createddeployment.apps/dashboard-metrics-scraper created

2、使用 kubectl get service --all-namespaces 查看,成功创建

[root@etcd01 kubernates]# kubectl get service --all-namespacesNAMESPACE NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGEdefault kubernetes ClusterIP 10.96.0.1 443/TCP 13dkube-system kube-dns ClusterIP 10.96.0.10 53/UDP,53/TCP,9153/TCP 13dkubernetes-dashboard dashboard-metrics-scraper ClusterIP 10.98.214.124 8000/TCP 52skubernetes-dashboard kubernetes-dashboard ClusterIP 10.106.132.40 443/TCP 52s

3、配置dashboard为nodeport类型,便于访问

查看所有pod

[root@etcd01 kubernates]# kubectl get pods --all-namespacesNAMESPACE NAME READY STATUS RESTARTS AGEdefault test-k8s-7bcd8f88dd-4nhlh 1/1 Running 0 30mdefault test-k8s-7bcd8f88dd-h7wqd 1/1 Running 0 30mdefault test-k8s-7bcd8f88dd-snlhd 1/1 Running 0 30mkube-system coredns-54d67798b7-6q9md 1/1 Running 0 13dkube-system etcd-etcd01 1/1 Running 0 13dkube-system kube-apiserver-etcd01 1/1 Running 0 13dkube-system kube-controller-manager-etcd01 1/1 Running 0 13dkube-system kube-proxy-vkh5d 1/1 Running 0 13dkube-system kube-scheduler-etcd01 1/1 Running 0 13dkube-system storage-provisioner 0/1 ImagePullBackOff 0 13dkubernetes-dashboard dashboard-metrics-scraper-7b59f7d4df-2llpp 1/1 Running 0 26mkubernetes-dashboard kubernetes-dashboard-5dbf55bd9d-2jzt9 1/1 Running 0 26m

4、修改nodeport类型

kubectl edit services -n kubernetes-dashboard kubernetes-dashboard

42 name: kubernetes-dashboard 43 namespace: kubernetes-dashboard 44 resourceVersion: "10695" 45 uid: dc5b4165-433e-4c30-a9ce-989135a0542e 46 spec: 47 clusterIP: 10.106.132.40 48 clusterIPs: 49 - 10.106.132.40 50 externalTrafficPolicy: Cluster 51 ports: 52 - nodePort: 31059 53 port: 443 54 protocol: TCP 55 targetPort: 8443 56 selector: 57 k8s-app: kubernetes-dashboard 58 sessionAffinity: None 59 type: NodePort 60 status: 61 loadBalancer: {}

5、 再次使用kubectl -n kubernetes-dashboard get service kubernetes-dashboard 查看服务,已成功修改。

[root@etcd01 kubernates]# kubectl get service --all-namespaces NAMESPACE NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGEdefault kubernetes ClusterIP 10.96.0.1 443/TCP 13dkube-system kube-dns ClusterIP 10.96.0.10 53/UDP,53/TCP,9153/TCP 13dkubernetes-dashboard dashboard-metrics-scraper ClusterIP 10.98.214.124 8000/TCP 29mkubernetes-dashboard kubernetes-dashboard NodePort 10.106.132.40 443:31059/TCP 29m

使用nodeport端口访问

1、创建admin-user账号 用于登录 kubernetes dashboard ,默认账号没有管理权限

[root@etcd01 kubernates]# cat dashboard-adminuser.yaml apiVersion: v1kind: ServiceAccountmetadata: name: admin-user namespace: kubernetes-dashboard---apiVersion: rbac.authorization.k8s.io/v1kind: ClusterRoleBindingmetadata: name: admin-userroleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole name: cluster-adminsubjects:- kind: ServiceAccount name: admin-user namespace: kubernetes-dashboard

2、创建登录用户

[root@lanweihong k8s]# kubectl apply -f dashboard-adminuser.yamlserviceaccount/admin-user createdclusterrolebinding.rbac.authorization.k8s.io/admin-user created

3、查看用户列表

[root@etcd01 kubernates]# kubectl get serviceaccounts -n kubernetes-dashboardNAME SECRETS AGEadmin-user 1 15mdefault 1 32mkubernetes-dashboard 1 32m

4、查看账号token

kubectl -n kubernetes-dashboard describe secret $(kubectl -n kubernetes-dashboard get secret | grep admin-user | awk '{print $1}')

5、使用token登录界面

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:pytorch 自定义损失函数、优化器(Optimizer)和学习率策略
下一篇:从20s优化到500ms,我用了这三招
相关文章

 发表评论

暂时没有评论,来抢沙发吧~