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 Volterra 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:

seq
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 for Consul Cluster Create a service discovery object of type Consul.
Verify Discovered Services Verify that the service discovery object is created and successfully discovered services.
Use Discovered Services Configure endpoint with K8s as the discovery type and associate sites with it.

Note: The site of discovery object and the endpoint must be the same.


Create Discovery for Consul Cluster

Step 1: Start discovery object creation.

Create a discovery configuration object in the System namespace. Select the system from the namespace menu. Select Manage from the configuration menu and Discovery from the options pane. Click Add discovery. The discovery object form gets loaded.

image1

Step 2: Enter metadata.

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

Step 3: Set discovery location.

Select Virtual Network or Site or Virtual Site for the Virtual-site or site or network field in the Where section. Accordingly, select an appropriate object from the Select ref field. Select Site Local Network or Site Local Inside Network for the Network Type field.

image2

Step 4: Configure consul settings for discovery.

Select Hashicorp Consul Service Discovery for the Select How Endpoints are Discovered field in the Endpoint Services Discovery section. Configure API Server and Port configuration for your consul server

image3

Note: If authentication is HTTP based, skip Step 5 and proceed to Step 6.

Step 5: Configure TLS parameters.
  • If authentication method for consul is TLS-based, click Configure TLS Parameters. The TLS parameter forms get loaded. In the Server Parameters section, enter SNI name and enter Server CA certificate in ASCII or base64 format

image4

  • Enter client certificate under Client Parameters section in ASCII or base64 format.

image5

  • Next click on configure client private key. Then user can choose Blindfold secret or clear secret under Secret Info. Then provide the key in Text, Blindfold or base64 format. If you have given ASCII and have to blindfold, click on Blindfold button. Next click on apply to confirm the configuration

image6

  • Now Click on apply to confirm the tls params configuration
Step 6 Configure HTTP authentication.
  • If authentication is http parameters based for consul server then configure HTTP Authentication Parameters username and password. Enter username for consul server and then click on Configure password.

image7

  • Enter the password in text field and click on blindfold to encrypt it locally. Then click on blindfold to encrypt the password locally and then click on apply to save the configuration

image8

Step 7: Set VIP publishing.

Select the VIP publish enable checkbox in the Advertise VIP Publising section. Configure the values as per the following guidelines:

  • Select DNS Delegation for the VIP Publish Method field.
  • Enter a subdomain in the Subdomain field.

Verify Discovered Services

Verify that the service discovery object is created and discovered services.

Step 1: Navigate to service discovery in VoltConsole.

Navigate to Manage -> App Management -> Service Discovery. Verify that the service discovery object is created and the Services field displays the number of services discovered.

image9

Step 2: Verify the discovered services.

Click on the value displayed on the Services field. This displays the list of discovered services.

image10

Note: Note down the Service Name field for a service to use it in configuration such as origin pools or endpoints.


Use Discovered Services

After the service discovery object is created and the services are discovered, you can use it in the configurations such as the following:

  • Origin Pools: The origin pools are a way to declare the origin servers for your service in the load balancer configuration. You can create origin pools as part of HTTP load balancer creation or individually create and apply it to a HTTP load balancer later.
  • Endpoints: The endpoint objects are for advanced configuration for using in the virtual host configuration.

Configure Origin Pool with Consul Service Information

This chapter shows the origin pool creation with Consul service name for the origin server specification.

Step 1: Start creating origin pool.

Log into VoltConsole and change to your application namespace. Select Manage -> Origin Pools. Click Add Origin Pool.

Step 2: Set consul as the type of origin.

Set a name in the metadata section and select Consul Service Name of Origin Server on given Sites option for the Select Type of Origin Server field.

Step 3: Set the service name.

Enter service name in the Service Name field. Obtain the service name using the instructions in the Verify Discovered Services chapter.

Step 4: Specify the location for origin pool.

Select Site or Virtual Site for the Select Site or Virtual Site field and select a site or virtual site accordingly. Select a network for the Select Network on the site option.

Step 5:Set port.

Enter a port in the Port field. Scroll down and click Save and Exit.

image11

This enables the service to be reachable on the selected network on the selected site or virtual site.


Create Endpoint with K8s Service Information

Step 1: Navigate to your application namespace in VoltConsole.

Select desired namespace from the namespace selector or create a namespace using the General -> Personal Management -> My Namespaces -> Add namespace option.

Step 2: Start creating endpoint.
  • Select Manage -> Virtual Host from the configuration menu and Endpoints from the options pane. Click Add endpoint.
  • The Add endpoint form gets loaded. Add a name, optionally set labels, and optionally add a description.
Step 3: Obtain consul service information.

Obtain the Consul service information using the instructions in the Verify Discovered Services chapter.

Step 4: Specify the location for endpoint.

Configure where the endpoint should be discovered. Select an appropriate option in the Where field. Click Select ref. This site or virtual site or virtual network must be same as that of the discovery object created.

image12

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

Step 5: Configure endpoint address.

Configure the information as per the following guidelines:

  • Select Service Selector info for the Endpoint Specifier field.
  • Select Hashicorp Consul for the Discovery field.
  • Select Service name for the Service field.
  • Enter your service name in the Service name field. Use the <servicename> format.

Note: Obtain service name from Step 3.

Step 6: Set port and protocol.

Enter port and protocol values for the fields Port and Protocol respectively.

image13

Note: The port must be the service port of the Consul service and not the node port.

With the steps above, you can discover a service endpoint from Consul 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. For example, you can advertise it across sites in cloud or edge.


Concepts


API References