Discovery

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

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

sovereign.discovery.response(request, xds, version, debug=False) → dict

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 – what type of XDS template to use when rendering
  • version – what template version to render for (i.e. envoy 1.7.0, 1.8.0)
  • debug – switch to control instance loading / exception raising
Returns:

An envoy Discovery Response

sovereign.discovery.version_hash(config: dict) → str

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

Parameters:config – Any dictionary
Returns:16 character hexadecimal string