• 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 https://raw.githubusercontent.com/kubernetes/dashboard/v2.0.3/aio/deploy/recommended.yaml

    安装效果如下:

    1. [root@etcd01 kubernates]# kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.0.3/aio/deploy/recommended.yaml
    2. namespace/kubernetes-dashboard created
    3. serviceaccount/kubernetes-dashboard created
    4. service/kubernetes-dashboard created
    5. secret/kubernetes-dashboard-certs created
    6. secret/kubernetes-dashboard-csrf created
    7. secret/kubernetes-dashboard-key-holder created
    8. configmap/kubernetes-dashboard-settings created
    9. role.rbac.authorization.k8s.io/kubernetes-dashboard created
    10. clusterrole.rbac.authorization.k8s.io/kubernetes-dashboard created
    11. rolebinding.rbac.authorization.k8s.io/kubernetes-dashboard created
    12. clusterrolebinding.rbac.authorization.k8s.io/kubernetes-dashboard created
    13. deployment.apps/kubernetes-dashboard created
    14. service/dashboard-metrics-scraper created
    15. deployment.apps/dashboard-metrics-scraper created

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

    1. [root@etcd01 kubernates]# kubectl get service --all-namespaces
    2. NAMESPACE NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
    3. default kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 13d
    4. kube-system kube-dns ClusterIP 10.96.0.10 <none> 53/UDP,53/TCP,9153/TCP 13d
    5. kubernetes-dashboard dashboard-metrics-scraper ClusterIP 10.98.214.124 <none> 8000/TCP 52s
    6. kubernetes-dashboard kubernetes-dashboard ClusterIP 10.106.132.40 <none> 443/TCP 52s

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

     查看所有pod

    1. [root@etcd01 kubernates]# kubectl get pods --all-namespaces
    2. NAMESPACE NAME READY STATUS RESTARTS AGE
    3. default test-k8s-7bcd8f88dd-4nhlh 1/1 Running 0 30m
    4. default test-k8s-7bcd8f88dd-h7wqd 1/1 Running 0 30m
    5. default test-k8s-7bcd8f88dd-snlhd 1/1 Running 0 30m
    6. kube-system coredns-54d67798b7-6q9md 1/1 Running 0 13d
    7. kube-system etcd-etcd01 1/1 Running 0 13d
    8. kube-system kube-apiserver-etcd01 1/1 Running 0 13d
    9. kube-system kube-controller-manager-etcd01 1/1 Running 0 13d
    10. kube-system kube-proxy-vkh5d 1/1 Running 0 13d
    11. kube-system kube-scheduler-etcd01 1/1 Running 0 13d
    12. kube-system storage-provisioner 0/1 ImagePullBackOff 0 13d
    13. kubernetes-dashboard dashboard-metrics-scraper-7b59f7d4df-2llpp 1/1 Running 0 26m
    14. kubernetes-dashboard kubernetes-dashboard-5dbf55bd9d-2jzt9 1/1 Running 0 26m

    4、修改nodeport类型

    kubectl edit services -n kubernetes-dashboard kubernetes-dashboard
    1. 42 name: kubernetes-dashboard
    2. 43 namespace: kubernetes-dashboard
    3. 44 resourceVersion: "10695"
    4. 45 uid: dc5b4165-433e-4c30-a9ce-989135a0542e
    5. 46 spec:
    6. 47 clusterIP: 10.106.132.40
    7. 48 clusterIPs:
    8. 49 - 10.106.132.40
    9. 50 externalTrafficPolicy: Cluster
    10. 51 ports:
    11. 52 - nodePort: 31059
    12. 53 port: 443
    13. 54 protocol: TCP
    14. 55 targetPort: 8443
    15. 56 selector:
    16. 57 k8s-app: kubernetes-dashboard
    17. 58 sessionAffinity: None
    18. 59 type: NodePort
    19. 60 status:
    20. 61 loadBalancer: {}

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

    1. [root@etcd01 kubernates]# kubectl get service --all-namespaces
    2. NAMESPACE NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
    3. default kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 13d
    4. kube-system kube-dns ClusterIP 10.96.0.10 <none> 53/UDP,53/TCP,9153/TCP 13d
    5. kubernetes-dashboard dashboard-metrics-scraper ClusterIP 10.98.214.124 <none> 8000/TCP 29m
    6. kubernetes-dashboard kubernetes-dashboard NodePort 10.106.132.40 <none> 443:31059/TCP 29m

    使用nodeport端口访问

     

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

    1. [root@etcd01 kubernates]# cat dashboard-adminuser.yaml
    2. apiVersion: v1
    3. kind: ServiceAccount
    4. metadata:
    5. name: admin-user
    6. namespace: kubernetes-dashboard
    7. ---
    8. apiVersion: rbac.authorization.k8s.io/v1
    9. kind: ClusterRoleBinding
    10. metadata:
    11. name: admin-user
    12. roleRef:
    13. apiGroup: rbac.authorization.k8s.io
    14. kind: ClusterRole
    15. name: cluster-admin
    16. subjects:
    17. - kind: ServiceAccount
    18. name: admin-user
    19. namespace: kubernetes-dashboard

    2、创建登录用户

    1. [root@lanweihong k8s]# kubectl apply -f dashboard-adminuser.yaml
    2. serviceaccount/admin-user created
    3. clusterrolebinding.rbac.authorization.k8s.io/admin-user created

    3、查看用户列表

    1. [root@etcd01 kubernates]# kubectl get serviceaccounts -n kubernetes-dashboard
    2. NAME SECRETS AGE
    3. admin-user 1 15m
    4. default 1 32m
    5. kubernetes-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登录界面

     

  • 相关阅读:
    前端代码评审规则
    Spring注解驱动之@Resource注解和@Inject注解
    聊聊logback的ShutdownHook
    艾美捷Bio-Helix CCH321 超敏ECL化学发光试剂盒(皮克级)特点
    【C语言初阶】switch语句的基本语法
    Vue技术9.3
    小程序容器怎样助力智能家居
    Hbuilder打包安卓H5-APP,APP与程序分离,更新无需重新打包
    修炼k8s+flink+hdfs+dlink(四:k8s(一)概念)
    [附源码]SSM计算机毕业设计影院售票系统JAVA
  • 原文地址:https://blog.csdn.net/weixin_42350212/article/details/125460396