TranslateProject/sources/tech/20200708 A visual guide to Lens- A new way to see Kubernetes.md
DarkSun 87737c99d2 选题[tech]: 20200708 A visual guide to Lens: A new way to see Kubernetes
sources/tech/20200708 A visual guide to Lens- A new way to see Kubernetes.md
2020-07-09 05:02:32 +08:00

12 KiB

A visual guide to Lens: A new way to see Kubernetes

Navigate advanced Kubernetes administration without the command line with Lens, the "Kubernetes IDE." Cat wearing glasses

There are many Kubernetes administration tools to choose from, whether you prefer a command-line utility or a graphical user interface. I recently covered k9s, a text-based interface that many day-to-day Kubernetes administrators enjoy, but you have to navigate through many Kubernetes-specific terms to use it. A lot of people who use Kubernetes less often would rather have a colorful, clean visual guide. This is where Lens, an open source integrated development environment (IDE) tool for administering Kubernetes clusters, comes in.

Install Lens

You can download Lens for Linux, macOS, or Windows from either its GitHub page or its website. Linux installs are offered through AppImage, and this tutorial walks you through the installation process. After installation, Lens appeared in my applications list (the blue box with the L in the center).

Lens app icon

(Jess Cherry, CC BY-SA 4.0)

Add a cluster

Managing Kubernetes means keeping an eye on one or more clusters. To add a cluster to Lens, click the large + sign, choose your cluster from the drop-down list, and click Add Cluster. Environments are automatically picked up from your ~/.kube/config file.

Adding a cluster in Lens

(Jess Cherry, CC BY-SA 4.0)

Explore Lens' menus

Lens gives you all the information you need about a cluster it manages. To help you get started, I'll explore the Lens menu sections with screenshots to show you what information and options they offer.

If you need a refresher on Kubernetes terminology, A beginner's guide to Kubernetes container orchestration is a good place to read about it.

Nodes menu

First, look at the Nodes. A node can be a virtual machine or physical (bare metal) machine depending on the cluster. Each node contains the services necessary to run Pods, managed by the control plane. We can start by checking if our nodes are up and running in a Ready state. If there were an issue, this page would provide details as to what is wrong with the node.

Lens Nodes menu

(Jess Cherry, CC BY-SA 4.0)

Workloads menu

The Workloads section provides a lot of information about your cluster. You can access its subsections with either the menu on the left or at the top of the pane—both work the same way.

Overview

Click Overview to see the events happening in the cluster, as well as how many Pods, Deployments, StatefulSets, DaemonSets, Jobs, and CronJobs are running in it. You can select each Overview item to see details about it.

Lens Workloads Overview menu

(Jess Cherry, CC BY-SA 4.0)

Pods

Click Pods to see a list of the pods in the cluster.

Lens Workloads Pods menu

(Jess Cherry, CC BY-SA 4.0)

Click on a pod name in the Pods section of Workloads, and it will bring up a details pane on the right with a ton of things you can do really quickly.

Lens Workloads Pod details

(Jess Cherry, CC BY-SA 4.0)

Open the pod's logs by clicking on the multi-line button (the second icon from the left) on the top-right of the pod detail window.

Lens Workloads Pod logs

(Jess Cherry, CC BY-SA 4.0)

If you need to shell into a pod, Lens has a terminal built into it. Access it by clicking the terminal button (the left-most icon) above the pod detail.

Shelling into a pod in Lens

(Jess Cherry, CC BY-SA 4.0)

A terminal will open.

Shelling into a pod in Lens

(Jess Cherry, CC BY-SA 4.0)

Deployments

Deployments shows what Deployments are in the cluster.

Lens Workloads Deployments menu

(Jess Cherry, CC BY-SA 4.0)

Configuration menu

Configuration shows ConfigMaps, Secrets, Resource Quotas, and Horizontal Pod Autoscalers (HPA).

Lens ConfigMaps menu

(Jess Cherry, CC BY-SA 4.0)

Network menu

Network includes options for managing your network services, endpoints, ingresses, and network policies.

Network Services

Lens Network Services menu

(Jess Cherry, CC BY-SA 4.0)

If you see a pencil icon (like the one in the top-right corner above), clicking it will open a terminal window where you can edit the configurations.

Editing configurations in Lens

(Jess Cherry, CC BY-SA 4.0)

Storage menu

Storage options, including PersistentVolumes and StorageClasses, are also navigable.

Lens StorageClasses menu

(Jess Cherry, CC BY-SA 4.0)

Namespaces menu

Namespaces shows a list of your namespaces.

Lens Namespaces menu

(Jess Cherry, CC BY-SA 4.0)

Apps menu

Lens' crown jewel is its one-click (OK, more like three-click) process for installing apps with Helm charts. I would suggest using this only on your local cluster, but it's still a nice add-on in Lens.

To install a chart, click Apps in the left navigation and click Charts. A list of all the charts available through Helm (and its stable repository) appears.

Helm charts in Lens' Apps menu

(Jess Cherry, CC BY-SA 4.0)

You can also find a chart using Search. Click on the chart you want, and a window will open on the right with a large Install button.

Searching for Helm charts in Lens' Apps menu

(Jess Cherry, CC BY-SA 4.0)

Click Install and a terminal will open at the bottom with another Install button in the lower-right. Click it.

Installing a Helm chart in Lens

(Jess Cherry, CC BY-SA 4.0)

It installs the Helm chart and tells you when it's finished.

Installing a Helm chart in Lens

(Jess Cherry, CC BY-SA 4.0)

You can double-check that the Helm chart is installed in your cluster by looking in the Pods section under Workloads.

Confirming Helm chart in Lens

(Jess Cherry, CC BY-SA 4.0)

The Helm install takes under a minute and, because Lens has an edit function in each detail window, you can manually configure the apps you install. In my opinion, this is the only downfall of this function—I prefer to use my own values because it's hard to track manual changes. Why do I consider this a problem? If you're working with a repo with versioned helm charts and need to run a manual change without checking in the changed values, you quickly run into code drift.

Access Control menu

The Access Control section includes Service Accounts, Roles, Role Bindings, and Pod Security Policies, so you can visualize and edit the security you have in place (as you can see in the following screenshots). Service Accounts are the equivalent of Linux user accounts, but they are intended for processes running in a cluster. Running applications are attached to Roles, which have Role Bindings to the cluster to allow pods to access certain administrative permissions. Pod Security Policies are a more glandular level of security for the pods to have access to resources like certain volume types or to set seccomp profiles used by containers. 

Service Accounts

Lens Access Control Service Accounts menu

(Jess Cherry, CC BY-SA 4.0)

Role Bindings

Lens Access Control RoleBindings menu

(Jess Cherry, CC BY-SA 4.0)

Roles

Lens Access Control Roles menu

(Jess Cherry, CC BY-SA 4.0)

Final notes

Lens is a beautiful and powerful alternative to managing Kubernetes from the command line. There are some times when you'll want to use the command line, mostly due to the drawbacks of manually editing charts before launching them or for tracking environmental changes. If you have good log-keeping practices in your cluster, this may not be a problem. If you are a visual person, Lens is a great way to explore your Kubernetes cluster and handle 95% of your administrative tasks.


via: https://opensource.com/article/20/7/kubernetes-lens

作者:Jessica Cherry 选题:lujun9972 译者:译者ID 校对:校对者ID

本文由 LCTT 原创编译,Linux中国 荣誉推出