Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Kubernetes 1.21.0 how to deploy administrative interface Dashboard 2

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains "Kubernetes 1.21.0 how to deploy management interface Dashboard 2", the content of the article is simple and clear, easy to learn and understand, now please follow the editor's ideas slowly in depth, together to study and learn "Kubernetes 1.21.0 how to deploy management interface Dashboard 2" bar!

Dashboard is the basic Web management tool of Kubernetes. The Dashboard 1.x series can only be used with versions prior to Kubernetes 1.16. Since Kubernetes 1.16, Dashboard 2 has been required, and its deployment has changed greatly (mainly standalone deployment, namespaces and login authorization have changed).

1. Install the service

Installation:

Kubectl apply-f https://raw.githubusercontent.com/kubernetes/dashboard/v2.2.0/aio/deploy/recommended.yaml

Pull the images of Dashboard:

Docker pull kubernetesui/metrics-scraper:v1.0.6docker pull kubernetesui/dashboard:v2.2.0

Note that there are several changes:

Now there are two mirrors, but there used to be only one.

The location name of kubernetes-dashboard 's docker mirror library has changed.

The namespace changed from kube-system to kubernetes-dashboard.

The login authorization method has changed, and the specific methods will be described below.

2. Access permission settings

It includes the steps of creating a service account, setting the role of the service account, obtaining token, and so on.

2.1 create a service access account

Create a Service Account, name it admin-user, and put it in namespace kubernetes-dashboard.

ApiVersion: v1kind: ServiceAccountmetadata: name: admin-user namespace: kubernetes-dashboard

Save the above as a file dashboard-adminuser.yaml.

2.2 create ClusterRoleBinding

In most cases, after deploying the cluster using kops or kubeadm, ClusterRole admin-Role already exists in the cluster and we can use it by creating a ClusterRoleBinding to our ServiceAccount.

Note: apiVersion of ClusterRoleBinding resources may vary from version to version of Kubernetes. Before Kubernetes v1.8, apiVersion was rbac.authorization.k8s.io/v1beta1.

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

Save the above contents to the file dashboard-adminrole.yaml.

2.3 Bearer Token

First, apply the two files above. As follows:

Kubectl apply-f dashboard-adminuser.yamlkubectl apply-f dashboard-adminrole.yaml

Find token to log in to Dashboard's Web interface. Execute the following command:

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

Copy the token content and use it in the WebUI below.

3. Access method

You need to expose Dashboard services for client access, including running agents and using NodePort methods. You can also use Ingress and other methods. Not described here, you can refer to:

Create a LoadBalancer service for a private Kubernetes cluster

Kubernetes dashboard provides HTTPS access through Ingress

3.1 Agent access mode

Run the agent service:

$kubectl proxy

Then open the following connection:

Http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/.

Select token mode to log in on the page, and then fill in the token copied in the above steps.

3.2 NodePort mode

Use kubectl get svc/dashboardxxxxx-n kubernetes-dashboard to get the service ID of dashboard.

Use kubectl edit svc/dashboardxxxxx-n kubernetes-dashboard to edit the parameters of the service, change the network type to NodePort, and increase port 30800.

Then open http://localhost:30800 to access it.

Select token mode to log in on the page, and then fill in the token copied in the above steps.

Thank you for reading, the above is the content of "Kubernetes 1.21.0 how to deploy management interface Dashboard 2". After the study of this article, I believe you have a deeper understanding of how Kubernetes 1.21.0 deploys management interface Dashboard 2, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report