Kubernetes Dashboard deploys applications and accesses

  1. Environment and version description:
    centos7.6, docker-18.09.8, kubernetes-1.15.1, kubernetes-dashboard-v2.0.0-beta2
    Please view the corresponding relationship between k8s and docker versions: View the corresponding relationship between k8s-docker versions
    View the corresponding relationship between kubernetes and kubernetes-dashboard versions: K8s-kubernetes-dashboard version corresponding view
    Insert image description here

  2. hosts configuration
    Check the IP corresponding to raw.githubusercontent.com in https://ipaddress.com/, and then configure it in hosts
    vim /etc/hosts
    185.199.108.133 raw.githubusercontent.com
    Insert image description here
    3.kubernetes-dashboard arranges file downloads and configures necessary items
    wget https://raw.githubusercontent.com/kubernetes/dashboard/v2.0.0-beta2/aio/deploy/recommended.yaml
    vim recommended.yaml configuration file Three modifications:
    The first modification: Add a port exposed to the outside world
    Insert image description here
    The second modification: Set up deployment to the master node
    Insert image description here
    The third modification:
    Insert image description here

  3. Certificate settings

    Execute the following commands in sequence

    openssl genrsa -out dashboard.key 2048
    #ip设置
    openssl req -new -out dashboard.csr -key dashboard.key -subj '/CN=192.168.8.125' 192.168.8.125为主节点ip,根据需要这是你自己的即可
    
    openssl x509 -req -in dashboard.csr -signkey dashboard.key -out dashboard.crt
    
    #删除之前的证书
    kubectl delete secret kubernetes-dashboard-certs -n kube-system
    #删除旧的证书
    kubectl delete secret kubernetes-dashboard-certs -n kubernetes-dashboard
    #创建新的证书
    kubectl create secret generic kubernetes-dashboard-certs --from-file=dashboard.key --from-file=dashboard.crt -n kubernetes-dashboard
    
  4. Start service
    kubectl apply -f recommended.yaml

  5. Create an administrative account and bind a role
    Create vim dashboard-adminuser.yaml file

    apiVersion: v1
    kind: ServiceAccount
    metadata:
      name: admin-user
      namespace: kubernetes-dashboard
    
    ---
    
    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
    

    Execute creation and binding: kubectl apply -f dashboard-adminuser.yaml

  6. Login
    https://masterip:3. Modify the port set in one place
    View and output the login token

    kubectl -n kube-system describe $(kubectl -n kube-system get secret -n kube-system -o name | grep namespace) | grep token
    

Insert image description here

おすすめ

転載: blog.csdn.net/yangfenggh/article/details/125996950