云其它

关注公众号 jb51net

关闭
首页 > 网站技巧 > 服务器 > 云和虚拟化 > 云其它 > k8s dashboard安装

k8s dashboard安装过程记录

作者:曾燕辉

这篇文章主要介绍了k8s dashboard安装过程记录,本案例k8s版本为v1.22.17,所以安装v2.7.0版本的dashboard,需要的朋友可以参考下

本案例,k8s版本为v1.22.17,所以安装v2.7.0版本的dashboard

1、下载dashboard的yaml文件

curl -O https://raw.githubusercontent.com/kubernetes/dashboard/v2.7.0/aio/deploy/recommended.yaml

2、修改recommended.yaml文件

修改定义的Service,将type由ClusterIP修改为NodePort,以便我们直接通过地址+端口进行访问,并配置访问端口。添加的内如为:

type: NodePortnodePort: 31111

如下图 :

3、kubectl create 生成pod

执行

kubectl create -f recommended.yaml 

查看 pod

kubectl  get pods --all-namespaces

4、访问https://192.168.0.107:31111

5、生成token

1)创建dashboard-adminuser.yaml

apiVersion: v1
kind: ServiceAccount
metadata:
  name: admin-user
  namespace: kubernetes-dashboard

2)执行 kubectl apply -f dashboard-adminuser.yaml

kubectl apply -f dashboard-adminuser.yaml

3)创建admin-user-role-binding.yaml

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: admin-user
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: cluster-admin
subjects:
  - kind: ServiceAccount
    name: admin-user
    namespace: kubernetes-dashboard
 

4)执行kubectl create -f admin-user-role-binding.yaml

5)生成token

kubectl -n kubernetes-dashboard get secret $(kubectl -n kubernetes-dashboard get sa/admin-user -o jsonpath="{.secrets[0].name}") -o go-template="{{.data.token | base64decode}}"
root@k8s-master:/usr/java/k8s-dashboard# kubectl -n kubernetes-dashboard get secret $(kubectl -n kubernetes-dashboard get sa/admin-user -o jsonpath="{.secrets[0].name}") -o go-template="{{.data.token | base64decode}}"
eyJhbGciOiJSUzI1NiIsImtpZCI6Il9IS0x1SE9WOUhrcExlcS1oeWF5azNoMEhlT3M3bzVqZlRwN3Q0eU9meWMifQ.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJrdWJlcm5ldGVzLWRhc2hib2FyZCIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VjcmV0Lm5hbWUiOiJhZG1pbi11c2VyLXRva2VuLXc2N2IyIiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZXJ2aWNlLWFjY291bnQubmFtZSI6ImFkbWluLXVzZXIiLCJrdWJlcm5ldGVzLmlvL3NlcnZpY2VhY2NvdW50L3NlcnZpY2UtYWNjb3VudC51aWQiOiJkYzg2NTM3OS02MDFjLTRmYWEtYTQzOS01N2I1ZTUxMThlMzIiLCJzdWIiOiJzeXN0ZW06c2VydmljZWFjY291bnQ6a3ViZXJuZXRlcy1kYXNoYm9hcmQ6YWRtaW4tdXNlciJ9.Hf9srfqYATgpYDlhkIdwRanFaOj2KID6P3iDzJwTINJpG2dJaROkbQql29Iier8Qp1yu0xCLjWve-9e3Zn_GY8d8r_bzqkvrckXkXwfWLoDmUJPlhewRa0EQxzQm9Pua2Ym0UcsJqGNFRtJeAFYHaR-3BvkXQ1DMnOT_slEWqOrvnoNN1PDyd6ooFdc4PTJ787FbQPO5_5geUeZn2DvA1-dHcMMADcqxW_f1rSP6fJeEVGUgwWjBt_8UyX0c9D5wjCOq7OpitS2tLZbvw2nr_BsmcOyal4G0EV0NFogADxclRUi21o5am1wjqvWsvq-LJiRKfnd6OJsCahISumyz2A

6)在页面上输入生成的token

到此这篇关于k8s dashboard安装的文章就介绍到这了,更多相关k8s dashboard安装内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!

您可能感兴趣的文章:
阅读全文