Consul 简明教程

Consul - Using UI

在本章中,我们将了解如何使用 Consul UI(用户界面)并了解其重要组成部分。

In this chapter, we will learn how to use the Consul UI (User Interface) and understand its important components.

Consul UISetup

Consul 为我们提供了一个实用的界面,使用它我们可以轻松管理事务。您可以在任何所需的端口上轻松启动控制台用户界面。Consul UI 可划分为三个重要部分,它们是:

Consul provides us with a useful interface using that we can manage things at ease. You can easily bring up the consul user interface on any port you desire. The Consul UI can be divided into three important parts, which are −

  1. ACL − Set of Rules to easily lock your clusters easily

  2. Datacenter − Enables you to easily manage datacenters and work out with your cluster.

  3. Nodes − Quick update on the nodes that Consul cluster is using

Using Consul UI

为了使用 Consul UI,我们必须安装 HashiCorp 团队在 Consul 项目网站上提供的 UI 包。因此,让我们尝试从源下载它并开始使用它。如果显示 Permission Denied error ,请在每个命令前使用 sudo

In order to use the Consul UI, we have to install the UI package provided by the Hashicorp team on Consul’s project site. So, let us try to download it from the source and start using it. Please use sudo ahead of every command in case the Permission Denied error is shown.

$ mkdir /opt/consul-ui
$ cd /opt/consul-ui
$ wget https://releases.hashicorp.com/consul/0.7.2/consul_0.7.2_web_ui.zip
$ unzip consul_0.7.2_web_ui.zip
$ rm consul_0.7.2_web_ui.zip

您可以使用以下命令通过任何代理查看 Consul UI 的输出。

You can view the output of Consul UI using the following command over any agent.

$ consul agent -dev -ui -data-dir /tmp/consul

输出将如以下屏幕截图所示。

The output would be as shown in the following screenshot.

agent

默认情况下,您将在 http://localhost:8500/ui 处观察 UI。/ui 部分与控制台的 HTTP API 相同。

By default, you will observe the UI at http://localhost:8500/ui. The /ui part is same as the consul’s HTTP API.

要在 Docker 上使用 Consul UI,请为 Docker 镜像(progrium/consul)运行以下命令:

For using the Consul UI over a Docker, please run the following command for the Docker image (progrium/consul) −

$ docker run -p 8400:8400 -p 8500:8500 -p 8600:53/udp -h node1 progrium/consul
-server -bootstrap -ui-dir /ui

输出将如以下屏幕截图所示。

The output would be as shown in the following screenshot.

progrium consul

Features of Consul UI

您可以通过查看 Consul UI 的一些功能(如)来开始浏览 Consul UI:

You can start browsing Consul UI by looking at some of its features, such as −

  1. Nodes

  2. ACL

  3. Key/Value

  4. Settings

  5. Datacenter

  6. Services

Let us understand each of these in detail.

Nodes

可以在以下屏幕截图中观察到仪表板上的节点的基本用法。

The basic usage of Nodes on the UI Dashboard can be observed as shown in the following screenshot.

ui dashboard

当您像我们一样单击特定节点(例如 node1)时,我们看到可以轻松地看到节点上的信息:

When you click on the particular node like node1 in our case, we can see that the information on the node can be easily seen as −

node1

您可以随时从 Consul 注销节点。这使得从高级控制台群集的角度轻松管理节点。

You can anytime deregister the node from Consul. It makes it easy to manage nodes from a high consul cluster point of view.

ACL (Access Control Lists)

Consul 的最佳功能之一是访问控制列表。您可以为跨越多个数据中心的不同集群编写不同的权限。开启 ACL 最简单的方法之一是在 Consul 的数据目录中添加一个新的 json 文件。要启用并更新 ACL,您可以在设置中的字段中添加主 ACL 令牌,并使用 ACL 选项卡刷新它

One of the best features of Consul is the Access Control Lists. You can write your different permissions for different clusters across various datacenters. One of the easiest way to turn on the ACL’s is to add a new json file in Consul’s data directory. To enable and update the ACL, you can add the master ACL token in the field in settings, and refresh it using the ACL tab

有关详细信息,请查看 here

For more information, please check here

acl tab

Key/Value

Consul 的键值选项默认情况下存在于 Consul UI 中。您可以使用 Consul UI 创建自己的密钥。它还提供了一个创建文件夹以存储密钥的选项。

The Key Value option for Consul is by default present in the Consul UI. You can create your own key by using the Consul UI. It also provides an option to create a folder to store your key.

key value

Settings

您可以在屏幕的右上角查看 Consul UI 的设置选项。单击该选项后,您可以轻松地看到 Consul 为您提供了一个选项,使用该选项可以配置其本地存储设置和用于验证的令牌系统。

You can check the settings option of the Consul UI on the top right hand side of the screen. Upon clicking that option, you can easily see that Consul provides you an option using which you can configure its local storage settings and token system for verification.

settings

Datacenter

数据中心选项可以轻松地进行更改和切换。Consul UI 自动更新 Consul 正在处理的数据中心的数量检测。

The datacenter option can be easily changed and switched over by choice. The Consul UI automatically updates the detection of the number of data centers Consul is working on.

Services

Consul 用户界面还为您提供了一个服务选项卡,以配置和查看当前使用 Consul 部署的服务。它为我们提供了根据节点配置服务的选项。

The Consul UI also provides you a Services tab to configure and view services that are currently deployed using Consul. It provides us an option to configure services depending on the nodes.