Discover Services Using Kubernetes

Objective

This document provides instructions on how to discover service endpoints using Kubernetes (K8s) service information. 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 for a Kubernetes cluster and an endpoint for a service using the service name.


Prerequisites

The following prerequisites apply:

  • An existing Kubernetes cluster with a service or application reachable from a Volterra site

Configuration

Volterra enables users to discover existing service endpoints either natively or using external methods. This guide covers service discovery on sites, virtual sites, or virtual networks using Kubernetes service information.

The following figure shows the workflow for creating service discovery with Kubernetes service information:

FlowChart
Figure: Setting up Service Discovery with k8s Service Info

Configuration Sequence

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

Phase Description
Create Discovery for External Kubernetes Cluster Create a service discovery object of type Kubernetes.
Create Endpoint with K8s Service Information Configure endpoint with K8s as the discovery type and associate sites with it.

Create Discovery for External Kubernetes Cluster

Step: 1 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.

SDCCreat
Figure: Service Discovery Creation

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

SDCCnfOpt
Figure: Service Discovery Config Options

Step 3: Select Kubernetes for the Type field. Select Virtual Network or Site or Virtual Site for the Virtual site or site or network field and accordingly, select an appropriate object from the Select ref field. Select Site Local Network for the Network Type field.

Figure: Service Discovery Config Options

Note: The Network Type field is not applicable for the Virtual Network setting.

Step 4: Click Discovery Service Access Information field to open the service access information form. Select k8s for the Discovery Service Access Information field and Kubeconfig for the oneoff field.

Figure: Service Discovery Access Information Options

Step 5: Click Kubeconfig to open the kubeconfig information form. Select Clear Secret for the Secret Info field and enter the URL for the secret. Select EncodingNone for the Secret Encoding field. Click the Apply buttons to return the add discovery form.

Figure: Kubeconfig Options

Note: This example uses Clear Secret for the Secret Info. However, you can use other supported type of secrets available in the drop down menu for the Secret Info field.

Step 6: Click the VIP Publish to load the VIP publish form and select the VIP publish enable checkbox. Configure the values as per the following guidelines:

  • Select DNS delegation for the VIP publish method field.
  • Enter a subdomain in the Subdomain field.
  • Select CORE DNS or KUBE DNS for the DNS mode field depending on your external k8s cluster DNS provider.
Figure: VIP Publish Configuration

Step 7: Click the Apply button to return to the add discovery form and click Add discovery button to create the discovery object.


Create Endpoint with K8s Service Information

Step 1: Select desired namespace or create a namespace.

Figure: Navigate to Namespace

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

Figure: Endpoint Creation

The Add endpoint form gets loaded.

Figure: Endpoint Config Options

Step 3: Using your Kubeconfig file, obtain the Kubernetes service or application information from your cluster.

Step 4: Configure endpoint address information 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.

    Note: Obtain service name from Step 3.

  • Select K8s for the Discovery type field.
Figure: Endpoint Address Service Info Config Options

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

Figure: Endpoint Address Reference Selector

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

Figure: Endpoint Site Reference Selection

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

Figure: Endpoint Port and Protocol

With the steps above, you can discover a service endpoint from external Kubernetes providers 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