Discovery

Functions used to render and return discovery responses to Envoy proxies.

The templates are configurable. todo See ref:Configuration#Templates

class sovereign.discovery.DiscoveryTypes

Bases: enum.Enum

An enumeration.

clusters = 'clusters'
endpoints = 'endpoints'
listeners = 'listeners'
routes = 'routes'
secrets = 'secrets'
sovereign.discovery.make_context(request: sovereign.schemas.DiscoveryRequest, template: sovereign.schemas.XdsTemplate)

Creates context variables to be passed into either a jinja template, or as kwargs to a python template.

sovereign.discovery.remove_unwanted_resources(conf, requested)

If Envoy specifically requested a resource, this removes everything that does not match the name of the resource. If Envoy did not specifically request anything, every resource is retained.

sovereign.discovery.resource_name(resource)
async sovereign.discovery.response(request: sovereign.schemas.DiscoveryRequest, xds_type: sovereign.discovery.DiscoveryTypes)

A Discovery Request typically looks something like:

{
    "version_info": "0",
    "node": {
        "cluster": "T1",
        "build_version": "<revision hash>/<version>/Clean/RELEASE",
        "metadata": {
            "auth": "..."
        }
    }
}

When we receive this, we give the client the latest configuration via a Discovery Response that looks something like this:

{
    "version_info": "abcdef1234567890",
    "resources": []
}

The version_info is derived from sovereign.discovery.version_hash()

Parameters
  • request – An envoy Discovery Request

  • xds_type – what type of XDS template to use when rendering

Returns

An envoy Discovery Response

sovereign.discovery.version_hash(*args) → str

Creates a ‘version hash’ to be used in envoy Discovery Responses.