Discovery - Hashicorp Consul

Objective

This document provides instructions on how to discover service endpoints using Hashicorp Consul. Service discovery enables you to find the endpoints where a given service is available. To know more information about service discovery, see Volterra Service Discovery.

Using the instructions provided in this guide, you can create a discovery object and endpoint for a service using the service name and the location where the service is available.

Note: The service name is obtained from Consul.


Prerequisites

Note: If you do not have an account, see Create a VES Account.

  • Consul with a service or application reachable from a Volterra Site

Note: Install the Volterra Node or Cluster Image in your cloud or edge location.


Configuration

Volterra enables you to discover existing service endpoints using multiple methods, including the Hashicorp Consul. This document covers service discovery on sites, virtual sites, or virtual networks using the Consul information.

The following figure shows the configuration workflow for service discovery with consul:

image10
Figure: Setting up Service Discovery with Consul

Configuration Sequence

Discovering services using the Consul service information requires performing the following sequence of actions:

Phase Description
Create Discovery Object with Consul Create a discovery object with Consul as the method and configure access credentials.
Create Endpoint with Consul Service Information Configure endpoint with Consul as the discovery type and associate sites with it.

Create Discovery Object with Consul

Step 1: Open the Consul GUI and confirm that the services are discovered.

The following image shows a sample of Consul nodes view:

image7
Figure: Service Discovery Consul Node

The following image shows a sample of Consul services view:

image5
Figure: Service Discovery Consul Service

Step 2: Start creating discovery object in VoltConsole.

Log on to VoltConsole and create a discovery configuration object in the ‘System’ namespace. Select system from the ‘namespace’ menu. Select Manage from configuration menu and Discovery from the options pane. Click Add discovery. The discovery object form gets loaded.

image8
Figure: Service Discovery Creation

Step 3: Enter the basic configuration.

Enter name, labels, and description in the Name, Labels, and Description fields respectively.

image14
Figure: Service Discovery Config Options

Step 4: Configure access information and configuration type.

Enter the configuration as per the following guidelines:

  • Select Consul for the Access info field.
  • Enter an API server address in the API server field.
  • Enter Consul server name in the Server name field.

image1
Figure: Service Discovery Consul Config Options

Step 5: Enter the security configuration.

The security configuration consists of certificate, key, and credentials.

image9
Figure: Service Discovery Consul Config Options

Step 6: Set discovery type, subdomain, and DNS mode.

Select CONSUL as the discovery type in the Type field, enter subdomain in the Subdomain field, and select CORE_DNS as the DNS mode. Click Apply.

image13
Figure: Service Discovery Network Type Config Options

Step 7: Complete creating discovery object.

Click Add discovery button to create the discovery object.

With the above configuration, Volterra reads all the discovered services seamlessly from the Consul server.


Create Endpoint with Consul Service Information

Step 1: Select the desired namespace or create a namespace where endpoint needs to be created.

image12
Figure: Navigate to Namespace

Step 2: Start creating endpoint.

Select Manage from the configuration menu and Endpoints from the options pane. Click Add endpoint.

image11
Figure: Endpoint Creation

Step 3:Enter basic configuration for endpoint.

Enter name, labels, and description in the Name, Labels, and Description fields respectively.

image15
Figure: Endpoint Config Options

Step 4: Configure service or application information.

Set configuration as per the following guidelines.

  • Select Service info for the Endpoint Address field.
  • Select Service name for the Service info field.
  • Enter your service name in the Service name field.
  • Select CONSUL for the Discovery type field.

image6
Figure: Endpoint Discovery Type Consul Config

Note: You can use Consul UI or Consul CLI to retrieve the service information. In this case, you can directly use the ‘Service Name’ as discovered in the Consul and omit any namespace information.

Step 5: Specify where the endpoint is discoverd.

Configure where the endpoint should be discovered. Select an appropriate option in the RefOrSelector field. Click Select ref.

image4
Figure: Endpoint Address Reference Selector

Any reference object (site, virtual site, or virtual network) needs to be created and listed before configuring this field. All the available object list gets displayed on a cascading menu where you can select one or more objects.

image2
Figure: Endpoint Site Reference Selection

Step 6: Enter port and protocol values and complete endpoint creation.

Select values for the fields Port and Protocol respectively. Click Add endpoint to complete creating endpoint.

image3
Figure: Endpoint Port and Protocol

With the above steps, you can discover a service endpoint from existing Consul server using ‘Service Info’ on a location specified using the selector. Once the service is discovered, the object can be used with other configuration objects of Volterra platform.


Concepts


API References