Discovery - Hashicorp Consul
On This Page:
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.
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.
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:
Discovering services using the Consul service information requires performing the following sequence of actions:
|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.
Step 2: Enter metadata.
Enter name, labels, and description in the
Description fields respectively.
Step 3: Set discovery location.
Virtual Network 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.
Step 4: Configure consul settings for discovery.
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
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 Parameterssection, enter
SNI nameand enter
Server CA certificatein
- Enter client certificate under
Client Parameterssection in
- Next click on
configureclient private key. Then user can choose
clear secretunder Secret Info. Then provide the key in
base64format. If you have given ASCII and have to blindfold, click on Blindfold button. Next click on apply to confirm the configuration
- 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 Parametersusername and password. Enter
usernamefor consul server and then click on
- 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
Step 7: Set VIP publishing.
VIP publish enable checkbox in the
Advertise VIP Publising section. Configure the values as per the following guidelines:
DNS Delegationfor the
VIP Publish Methodfield.
- Enter a subdomain in the
Verify Discovered Services
Verify that the service discovery object is created and discovered services.
Step 1: Navigate to service discovery in VoltConsole.
App Management ->
Service Discovery. Verify that the service discovery object is created and the
Services field displays the number of services discovered.
Step 2: Verify the discovered services.
Click on the value displayed on the
Services field. This displays the list of discovered services.
Note: Note down the
Service Namefield 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
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.
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.
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
Personal Management ->
My Namespaces ->
Add namespace option.
Step 2: Start creating endpoint.
Virtual Hostfrom the configuration menu and
Endpointsfrom the options pane. Click
Add endpointform 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.
Note: Any reference object (site, virtual site, and virtual network) needs to be created and listed before configuring the
Selectreffield. 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:
Service Selector infofor the
Hashicorp Consulfor the
Service namefor the
- Enter your service name in the
Service namefield. Use the
Note: Obtain service name from Step 3.
Step 6: Set port and protocol.
Enter port and protocol values for the fields
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.