mirror of
https://github.com/LCTT/TranslateProject.git
synced 2025-03-21 02:10:11 +08:00
commit
ac0d671b6a
@ -1,143 +0,0 @@
|
||||
[#]: subject: "How to Install and Access Kubernetes Dashboard Step-by-Step"
|
||||
[#]: via: "https://www.linuxtechi.com/how-to-install-kubernetes-dashboard/"
|
||||
[#]: author: "Pradeep Kumar https://www.linuxtechi.com/author/pradeep/"
|
||||
[#]: collector: "lkxed"
|
||||
[#]: translator: "geekpi"
|
||||
[#]: reviewer: " "
|
||||
[#]: publisher: " "
|
||||
[#]: url: " "
|
||||
|
||||
How to Install and Access Kubernetes Dashboard Step-by-Step
|
||||
======
|
||||
|
||||
Kubernetes, an open-source container orchestration platform, has become the go-to solution for managing containerized applications at scale. While Kubernetes provides powerful command-line tools for managing clusters, sometimes a visual interface can make monitoring and managing your deployments even easier. Kubernetes Dashboard is a web-based user interface that allows you to visualize and interact with your Kubernetes clusters.
|
||||
|
||||
In this blog post, we will walk you through the process of installing and accessing Kubernetes Dashboard step-by-step, empowering you to streamline your Kubernetes management tasks.
|
||||
|
||||
##### Prerequisites
|
||||
|
||||
Before installing Kubernetes Dashboard, ensure that you have a running Kubernetes cluster and have the necessary administrative access.
|
||||
|
||||
### Installing Kubernetes Dashboard
|
||||
|
||||
The easy way to install Kubernetes dashboard for your cluster is via helm chart. Kubernetes Dashboard now has a dependency on cert-manager and nginx-ingress-controller. Fortunately, these dependencies can be automatically installed using the Helm chart. However, if you already have these components installed, you can disable their installation by setting the flags –set=nginx.enabled=false and –set=cert-manager.enabled=false when installing the chart.
|
||||
|
||||
Without any further delay, let’s jump into installation steps,
|
||||
|
||||
##### 1 ) Install Helm
|
||||
|
||||
Access your cluster’s master node using a terminal or command prompt. Install helm if not installed. Run the following commands.
|
||||
|
||||
```
|
||||
$ curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3
|
||||
$ chmod 700 get_helm.sh
|
||||
$ ./get_helm.sh
|
||||
```
|
||||
|
||||
##### 2) Add Kubernetes Dashboard Helm Repository
|
||||
|
||||
Run following helm command to add dashboard repository,
|
||||
|
||||
```
|
||||
$ helm repo add kubernetes-dashboard https://kubernetes.github.io/dashboard/
|
||||
$ helm repo list
|
||||
```
|
||||
|
||||
##### 3) Install Kubernetes Dashboard
|
||||
|
||||
To install Kubernetes dashboard using helm, run following command,
|
||||
|
||||
```
|
||||
$ helm upgrade --install kubernetes-dashboard kubernetes-dashboard/kubernetes-dashboard --create-namespace --namespace kubernetes-dashboard
|
||||
```
|
||||
|
||||
Output above confirms dashboard has been deployed in Kubernetes-dashboard namespace. So, in order to access dashboard, run
|
||||
|
||||
```
|
||||
$ kubectl -n kubernetes-dashboard port-forward svc/kubernetes-dashboard-nginx-controller 8443:443
|
||||
```
|
||||
|
||||
Now, open the web browser of system on which you have run above command, type following url
|
||||
|
||||
https://localhost:8443
|
||||
|
||||
Click on “Accept the Risk and Continue”
|
||||
|
||||
As you can see above, we need a token to login. So, let’s generate the required token in the next step.
|
||||
|
||||
##### 4) Generate Token for Kubernetes Dashboard
|
||||
|
||||
Open one more ssh session to master node and create a service account and assign required permissions using following yaml file,
|
||||
|
||||
```
|
||||
$ vi k8s-dashboard-account.yaml
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
name: admin-user
|
||||
namespace: kube-system
|
||||
---
|
||||
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: kube-system
|
||||
```
|
||||
|
||||
save and exit the file
|
||||
|
||||
Next create service account by running following command
|
||||
|
||||
```
|
||||
$ kubectl create -f k8s-dashboard-account.yaml
|
||||
serviceaccount/admin-user created
|
||||
clusterrolebinding.rbac.authorization.k8s.io/admin-user created
|
||||
$
|
||||
```
|
||||
|
||||
Now, generate the token for admin-user, run
|
||||
|
||||
```
|
||||
$ kubectl -n kube-system create token admin-user
|
||||
```
|
||||
|
||||
Copy this token and head back to browser, paste it on “Enter Token” field as shown below,
|
||||
|
||||
Click on “Sign in”
|
||||
|
||||
##### 5) Access Kubernetes Dashboard
|
||||
|
||||
When we click on “Sign in” in above then we will get the following dashboard,
|
||||
|
||||
Great, you are now logged in to the Kubernetes Dashboard. Here are a few key features and functionalities to explore:
|
||||
|
||||
- Cluster Overview: Gain an overview of your cluster’s health, resource utilization, and running pods.
|
||||
- Workloads: View and manage your deployments, replica sets, stateful sets, and daemon sets.
|
||||
- Services: Monitor and manage your services, including load balancers and external endpoints.
|
||||
- Configurations: Explore your config maps, secrets, and persistent volume claims.
|
||||
- Storage: Manage persistent volumes and storage classes.
|
||||
- Namespaces: Switch between namespaces to view and manage resources across different projects or teams.
|
||||
|
||||
That’s all from this post, I hope you have found it useful and informative. Kindly do post your queries and feedback in below comments section.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.linuxtechi.com/how-to-install-kubernetes-dashboard/
|
||||
|
||||
作者:[Pradeep Kumar][a]
|
||||
选题:[lkxed][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://www.linuxtechi.com/author/pradeep/
|
||||
[b]: https://github.com/lkxed/
|
||||
|
@ -0,0 +1,170 @@
|
||||
[#]: subject: "How to Install and Access Kubernetes Dashboard Step-by-Step"
|
||||
[#]: via: "https://www.linuxtechi.com/how-to-install-kubernetes-dashboard/"
|
||||
[#]: author: "Pradeep Kumar https://www.linuxtechi.com/author/pradeep/"
|
||||
[#]: collector: "lkxed"
|
||||
[#]: translator: "geekpi"
|
||||
[#]: reviewer: " "
|
||||
[#]: publisher: " "
|
||||
[#]: url: " "
|
||||
|
||||
如何逐步安装和访问 Kubernetes 仪表板
|
||||
======
|
||||
|
||||
Kubernetes 是一个开源容器编排平台,已成为大规模管理容器化应用的首选解决方案。虽然 Kubernetes 提供了强大的命令行工具来管理集群,但有时可视化界面可以使监控和管理部署变得更加容易。Kubernetes 仪表板是一个基于 Web 的用户界面,可让你可视化 Kubernetes 集群并与之交互。
|
||||
|
||||
在这篇博文中,我们将逐步引导你完成安装和访问 Kubernetes Dashboard 的过程,使你能够简化 Kubernetes 管理任务。
|
||||
|
||||
##### 先决条件
|
||||
|
||||
在安装 Kubernetes Dashboard 之前,请确保你有一个正在运行的 Kubernetes 集群并具有必要的管理访问权限。
|
||||
|
||||
### 安装 Kubernetes 仪表板
|
||||
|
||||
为集群安装 Kubernetes 仪表板的简单方法是通过 Helm Chart。Kubernetes 仪表板现在依赖于 cert-manager 和 nginx-ingress-controller。幸运的是,可以使用 Helm Chart 自动安装这些依赖项。但是,如果你已经安装了这些组件,则可以在安装 chart 时通过设置标志 –set=nginx.enabled=false 和 –set=cert-manager.enabled=false 来禁用它们的安装。
|
||||
|
||||
事不宜迟,让我们进入安装步骤。
|
||||
|
||||
##### 1)安装 Helm
|
||||
|
||||
使用终端或命令提示符访问集群的主节点。如果没有安装,请安装 helm。运行以下命令。
|
||||
|
||||
```
|
||||
$ curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3
|
||||
$ chmod 700 get_helm.sh
|
||||
$ ./get_helm.sh
|
||||
```
|
||||
|
||||
![][1]
|
||||
|
||||
##### 2)添加 Kubernetes 仪表板 Helm 仓库
|
||||
|
||||
运行以下 helm 命令来添加仪表板仓库:
|
||||
|
||||
```
|
||||
$ helm repo add kubernetes-dashboard https://kubernetes.github.io/dashboard/
|
||||
$ helm repo list
|
||||
```
|
||||
|
||||
![][2]
|
||||
|
||||
##### 3)安装 Kubernetes 仪表板
|
||||
|
||||
要使用 helm 安装 Kubernetes 仪表板,请运行以下命令:
|
||||
|
||||
```
|
||||
$ helm upgrade --install kubernetes-dashboard kubernetes-dashboard/kubernetes-dashboard --create-namespace --namespace kubernetes-dashboard
|
||||
```
|
||||
|
||||
![][3]
|
||||
|
||||
上面的输出确认仪表板已部署在 Kubernetes-dashboard 命名空间中。因此,要访问仪表板,请运行:
|
||||
|
||||
```
|
||||
$ kubectl -n kubernetes-dashboard port-forward svc/kubernetes-dashboard-nginx-controller 8443:443
|
||||
```
|
||||
|
||||
![][4]
|
||||
|
||||
现在,打开运行上述命令的系统的 Web 浏览器,输入以下 url:
|
||||
|
||||
https://localhost:8443
|
||||
|
||||
![][5]
|
||||
|
||||
点击“接受风险并继续”
|
||||
|
||||
![][6]
|
||||
|
||||
正如你在上面看到的,我们需要一个令牌才能登录。因此,让我们在下一步中生成所需的令牌。
|
||||
|
||||
##### 4)为 Kubernetes 仪表板生成令牌
|
||||
|
||||
再打开一个到主节点的 ssh 会话,创建一个服务帐户并使用以下 yaml 文件分配所需的权限:
|
||||
|
||||
```
|
||||
$ vi k8s-dashboard-account.yaml
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
name: admin-user
|
||||
namespace: kube-system
|
||||
---
|
||||
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: kube-system
|
||||
```
|
||||
|
||||
保存并退出文件。
|
||||
|
||||
接下来通过运行以下命令创建服务帐户:
|
||||
|
||||
```
|
||||
$ kubectl create -f k8s-dashboard-account.yaml
|
||||
serviceaccount/admin-user created
|
||||
clusterrolebinding.rbac.authorization.k8s.io/admin-user created
|
||||
$
|
||||
```
|
||||
|
||||
现在,为管理员用户生成令牌,运行:
|
||||
|
||||
```
|
||||
$ kubectl -n kube-system create token admin-user
|
||||
```
|
||||
|
||||
![][7]
|
||||
|
||||
复制此令牌并返回浏览器,将其粘贴到“输入令牌”字段中,如下所示:
|
||||
|
||||
![][8]
|
||||
|
||||
点击“登录”
|
||||
|
||||
##### 5) 访问 Kubernetes 仪表板
|
||||
|
||||
当我们点击上面的“登录”时,我们将看到以下仪表板:
|
||||
|
||||
![][9]
|
||||
|
||||
太好了,你现在已登录 Kubernetes 仪表板。以下是一些需要探索的关键特性和功能:
|
||||
|
||||
- 集群概览:获取集群运行状况、资源利用率和运行 Pod 的概览。
|
||||
- 工作负载:查看和管理你的部署、副本集、有状态集和守护程序集。
|
||||
- 服务:监控和管理你的服务,包括负载均衡器和外部端点。
|
||||
- 配置:探索你的配置映射、密钥和持久卷声明。
|
||||
- 存储:管理持久卷和存储类。
|
||||
- 命名空间:在命名空间之间切换以查看和管理不同项目或团队的资源。
|
||||
|
||||
这就是这篇文章的全部内容,我希望你发现它有用且内容丰富。请在下面的评论部分发表你的疑问和反馈。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.linuxtechi.com/how-to-install-kubernetes-dashboard/
|
||||
|
||||
作者:[Pradeep Kumar][a]
|
||||
选题:[lkxed][b]
|
||||
译者:[geekpi](https://github.com/geekpi)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://www.linuxtechi.com/author/pradeep/
|
||||
[b]: https://github.com/lkxed/
|
||||
[1]: https://www.linuxtechi.com/wp-content/uploads/2023/07/Install-Helm-on-K8s-master-node.png
|
||||
[2]: https://www.linuxtechi.com/wp-content/uploads/2023/07/Helm-Repo-Kubernetes-Dashboard.png
|
||||
[3]: https://www.linuxtechi.com/wp-content/uploads/2023/07/Installing-Kubernetes-Dashboard-Using-Helm-Command.png
|
||||
[4]: https://www.linuxtechi.com/wp-content/uploads/2023/07/Port-Forwarding-Kubernetes-Dashboard-Kubectl-Command.png
|
||||
[5]: https://www.linuxtechi.com/wp-content/uploads/2023/07/Accept-Risk-SSL-Kubernetes-Dashboard.png
|
||||
[6]: https://www.linuxtechi.com/wp-content/uploads/2023/07/Token-For-Kubernetes-Dashboard-Login.png
|
||||
[7]: https://www.linuxtechi.com/wp-content/uploads/2023/07/Generate-Token-K8s-Dashboard-kubectl-Command.png
|
||||
[8]: https://www.linuxtechi.com/wp-content/uploads/2023/07/Click-Signin-After-entering-token-kubernetes-dashboard.png
|
||||
[9]: https://www.linuxtechi.com/wp-content/uploads/2023/07/Kubernetes-Dashboard-Overview-Ubuntu.png
|
||||
|
Loading…
Reference in New Issue
Block a user