This commit is contained in:
Xiaobin.Liu 2023-05-02 23:25:29 +08:00
parent 92cd149bd9
commit baa40be59a

View File

@ -7,33 +7,33 @@
[#]: publisher: " "
[#]: url: " "
Monitoring and Debugging Kubernetes with Lens Desktop
使用 Lens Desktop 监控和调试 Kubernetes
======
*Lens Desktop is an exciting platform for working with Kubernetes. It is a distribution of the OpenLens repository with specific customisations. In this article we will see what Lens Desktop can do and how it works.*
*Lens Desktop 是一个令人兴奋的 Kubernetes 工作平台。它是基于 OpenLens 资源库的一个定制化发行版本。通过本文来了解下 Lens Desktop 能做什么以及它是如何工作的。*
Lens Desktop is free of charge. For more details, you can visit *https://k8slens.dev/pricing.html.* A few benefits of using Lens Desktop are:
Lens Desktop 是免费的。你可以查看 https://k8slens.dev/pricing.html 来了解更多内容。Lens Desktop 有如下优势:
* Simplicity and increased productivity no need to learn kubectl commands
* Visibility in existing Kubernetes resources
* Built on open source
* Observability — live statistics, events, and log streams in real-time
* Errors and warnings are directly available on the Lens dashboard
* Supports EKS, AKS, GKE, Minikube, Rancher, k0s, k3s, OpenShift
* Huge community support — 450,000 users and 17,000 stars on GitHub
* 简单高效——你无需学习 kubectl 命令
* 可视化已有的 Kubernetes 资源
* 基于开源构建
* 可观测性——实时的统计数据、事件和日志流
* 错误和警告可以直接在 Lens 仪表盘上看到
* 支持 EKS、AKS、GKE、Minikube、Rancher、k0s、k3s、OpenShift
* 强大的社区支持——共有 450000 用户,在 GitHub 上共获得 17000 星
### Minikube installation
### Minikube 安装
Minikube is a tool that is used to run Kubernetes locally. It runs a single-node Kubernetes cluster so that hands-on work can be done on Kubernetes for daily software development.
Minikube 是一个用于本地运行 Kubernetes 的工具。它运行一个单节点的 Kubernetes 集群,这样就可以在 Kubernetes 上进行日常软件开发的实践工作。
We will use minikube and verify the usage of Lens. Lets install minikube on a Windows based system first. You can also install it on other operating systems, virtual machines or laptops.
我们将使用 minikube 并验证 Lens 的用法。首先让我们在基于 Windows 的系统上安装 minikube。你也可以把它安装在其他操作系统、虚拟机或笔记本电脑上。
* Two or more CPUs
* 2GB of RAM
* 20GB of free disk space
* Internet connectivity
* Container or virtual machine manager such as Docker or VirtualBox
* 2 核以上 CPU
* 2GB RAM
* 20GB 空闲硬盘空间
* 能连接网络
* 容器或虚拟机管理器,如 Docker、VirtualBox
From a terminal or command prompt, execute the minikube start command.
在终端或命令提示符处,运行 minikube 启动命令。
```
minikube start --driver=virtualbox
@ -52,11 +52,11 @@ minikube start --driver=virtualbox
* Done! kubectl is now configured to use “minikube”
```
Go to your virtual box and verify the newly created minikube virtual machine (Figure 1).
进入你的虚拟箱,并验证刚安装的 minikube 虚拟机功能正常(图 1
![Figure 1: Minikube virtual machine in virtual box][1]
Now verify the existing status of minikube using the *minikube* status command.
使用 *minikube status* 命令,查看状态是否与下面的输出一致
```
C:\>minikube status
@ -68,7 +68,7 @@ apiserver: Running
kubeconfig: Configured
```
Next, use the *kubectl cluster-info* command to get details about kubeDNS.
然后,使用 *kubectl cluster-info* 命令查看 kubeDNS 详情。
```
kubectl cluster-info
@ -76,13 +76,13 @@ Kubernetes master is running at https://192.168.99.103:8443
KubeDNS is running at https://192.168.99.103:8443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
```
To get more details on debugging and to diagnose cluster problems, use the *kubectl cluster-info* dump command.
你可以使用 *kubectl cluster-info dump* 命令来调试和诊断集群问题。
Once minikube is ready, install kubectl *[(https://kubernetes.io/docs/tasks/tools/)][2]*. It is a command line cluster that is used to run commands against Kubernetes clusters and minikube as well.
当 minikube 安装完成后,安装 kubectl *[(https://kubernetes.io/docs/tasks/tools/)][2]*。它是一个命令行集群,用于对 Kubernetes 集群和 minikube 执行命令。
![Figure 2: Lens][3]
Execute the *kubectl get* *nodes* command to get details on all nodes and, in this case, minikube.
执行 *kubectl get nodes* 命令获取所有 <ruby>节点<rt>node</rt></ruby> 的详情,在本例中是获取 minikube 的详情。
```
C:\>kubectl get nodes
@ -90,7 +90,7 @@ NAME STATUS ROLES AGE VERSION
minikube Ready master 7m57s v1.18.3
```
Use the *kubectl get all* command to get all details for the default name space.
使用 *kubectl get all* 命令获取默认命名空间下的所有详情。
```
C:\>kubectl get all
@ -98,29 +98,29 @@ NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 7m58s
```
We now have a minikube cluster ready with kubectl. The next step is to install and configure Lens and verify the sample applications.
我们现在已经有一个 minikube 集群,并准备好了 kubectl。下一步是安装和配置 Lens并用示例应用程序来验证。
### Lens installation and configuration
### Lens 安装和配置
Go to *https://k8slens.dev/* and download an installable package based on the operating system you have.
打开 *https://k8slens.dev/*,下载与你的操作系统匹配的安装包。
Next, install Lens as per the instruction displayed on the screen. Open Lens after successful installation. You will find a minikube in the catalogue (Figure 3).
然后,参照屏幕上的教程来安装 Lens安装完成后打开 Lens。你会发现在目录中有一个 minikube图 3
![Figure 3: Lens catalogue][4]
Click on *minikube* and you will enter the world of minikube clusters, which you will love forever.
点击 *minikube* 后,你就进入了 minikube 的世界,你会爱上它的。
Click on *Nodes* and get the node details that you got after executing the kubectl get nodes commands.
点击 *<ruby>节点<rt>node</rt></ruby>* 获取有关 `kubectl get nodes` 命令输出的 <ruby>节点<rt>node</rt></ruby> 详情。
Now, Lens is ready to use.
现在,你可以使用 Lens 了。
![Figure 4: Lens cluster][5]
Lets deploy [https://github.com/GoogleCloudPlatform/microservices-demo][6], which is a cloud-native microservices demo application. It has 11-tier microservices applications, and is a Web based e-commerce app.
我们现在部署 [https://github.com/GoogleCloudPlatform/microservices-demo][6],这是一个云原生微服务 demo 应用程序。它有 11 层的微服务应用,是一个基于网络的电子商务应用。
Download the application and extract it locally in the system where you have downloaded and configured minikube.
下载这个应用程序,把它解压到与 minikube 相同的目录。
Go to the *release* directory and execute the following command.
进入 *release* 目录,执行以下命令。
```
kubectl apply -f kubernetes-manifests.yaml
@ -151,7 +151,7 @@ deployment.apps/adservice created
service/adservice created
```
The installation of the app will start now, but it will take some time to reflect that we have used kubectl commands.
安装过程现在应该已经开始了,不过它需要一些时间来反映出我们使用了 kubectl 命令。
![Figure 5: Lens nodes][7]
@ -172,7 +172,7 @@ redis-cart-57bd646894-v7kfr 0/1 Pending 0 8h
shippingservice-8685dd9855-pmgjm 1/1 Running 0 8h
```
Table 1 lists a few commands that you can use to get information from kubectl.
表 1 列出了你可以通过 kubectl 来获取信息的几个命令。
![Figure 6: Lens pods][8]
@ -196,23 +196,23 @@ Table 1 lists a few commands that you can use to get information from kubectl.
| Print the logs for a pod | kubectl logs <pod_name> |
| Print the logs for a specific container in a pod | kubectl logs -c <container_name> <pod_name> |
Lens can help you get all the information listed in Table 1 and more for a specific cluster. We can also perform edit and delete actions on Kubernetes resources using Lens.
Lens 不仅可以帮你获取表 1 中列出的所有信息,它还可以获取指定集群的信息。我们还能用 Lens 来对 Kubernetes 资源进行编辑和删除操作。
![Figure 7: Lens deployments][9]
Lets see how this works. Select *Pods* in the Workloads section (Figure 6). We can edit, delete, access logs, access terminals of pod from Lens itself. Cool, right?
我们来看下是如何操作的。在 *<ruby>工作负载<rt>Workloads</rt></ruby>* 部分选择 *<ruby>容器荚<rt>Pods</rt></ruby>*(图 6我们能通过 Lens 来编辑、删除、查看日志、访问 <ruby>容器荚<rt>Pod</rt></ruby> 的终端,这是不是很酷?
![Figure 8: Lens Replicasets][10]
You can verify all *deployments* in the *Workloads* section (Figure 7), verify all *Replicasets* in the *Workloads* section (Figure 8), all *Secrets* in the *Config* section (Figure 9) and all *Services* in the *Network* section (Figure 10).
你可以验证 *<ruby>工作负载<rt>Workloads</rt></ruby>* 部分的所有 *<ruby>部署<rt>deployments</rt></ruby>*(图 7*<ruby>工作负载<rt>Workloads</rt></ruby>* 部分的所有 *<ruby>副本<rt>Replicasets</rt></ruby>* (图 8*<ruby>配置<rt>Config</rt></ruby>* 部分的所有 *<ruby>密钥<rt>Secrets</rt></ruby>* (图 9以及 *<ruby>网络<rt>Network</rt></ruby>* 部分的所有 *<ruby>服务<rt>Services</rt></ruby>* 是否都正常(图 10
![Figure 9: Lens Secrets][11]
You can see how easy it is to navigate to all resources, and effectively find all Kubernetes resources from a single place quickly. We can edit YAML files in Lens and apply it at runtime to see the change.
你可以看到,跳转到所有的资源以及在一个地方高效地查看所有资源就是如此轻松。我们可以用 Lens 修改 YAML 文件,在运行时应用它来查看变更。
![Figure 10: Lens Services][12]
We can also configure multiple clusters deployed by multiple cloud service providers and use Lens for visibility and troubleshooting.
对于配置在不同的云服务商部署的多个集群,我们仍可以用 Lens 来进行观察和故障处理。
--------------------------------------------------------------------------------
@ -220,8 +220,8 @@ via: https://www.opensourceforu.com/2022/09/monitoring-and-debugging-kubernetes-
作者:[Mitesh Soni][a]
选题:[lkxed][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
译者:[lxbwolf](https://github.com/译者ID)
校对:[校对者ID](https://github.com/lxbwolf)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出