EnvoyControlPlane / internal /
..
README.md Add database persistence and consistency check between in-memory cache and DB. 15 days ago
converter.go Add database persistence and consistency check between in-memory cache and DB. 15 days ago
log.go add deployment code and modify 18 days ago
rest_api.go Add database persistence and consistency check between in-memory cache and DB. 15 days ago
run_server.go inital commit 18 days ago
snapshot.go Add database persistence and consistency check between in-memory cache and DB. 15 days ago
storage.go Add database persistence and consistency check between in-memory cache and DB. 15 days ago
README.md

This is a great request! Based on the provided Go code, which defines a REST API for managing an Envoy xDS Configuration Snapshot, here is a comprehensive README.md.


Envoy xDS Snapshot Management API

This package provides a REST API built in Go for managing the configuration snapshot (Cluster, Listener, Route) used by an Envoy xDS control plane. It allows for dynamic addition, removal, querying, and persistence of Envoy configuration resources.

🚀 Features

  • Dynamic Configuration: Add and remove Clusters, Listeners, and Routes on the fly.
  • Querying: Retrieve the current list or details of configured resources.
  • Persistence: Save the current configuration snapshot to a Database or a File and load it back.
  • Envoy xDS Types: Utilizes official Envoy Go types (github.com/envoyproxy/go-control-plane) for resource definitions.

💻 API Endpoints

All endpoints expect a JSON request body (for POST) or use query parameters (for GET).

Configuration Management (POST)

These endpoints allow you to add or remove Envoy xDS resources from the current snapshot.

Endpoint Method Description Request Body Example
/add-cluster POST Adds a new Envoy Cluster. {"name": "my-cluster", "cluster": {...}}
/remove-cluster POST Removes a Cluster by name. {"name": "my-cluster"}
/add-listener POST Adds a new Envoy Listener. {"name": "my-listener", "listener": {...}}
/remove-listener POST Removes a Listener by name. {"name": "my-listener"}
/add-route POST Adds a new Envoy Route configuration. {"name": "my-route", "route": {...}}
/remove-route POST Removes a Route by name. {"name": "my-route"}

Note: The cluster, listener, and route fields in the requests must contain the full, JSON-marshaled protobuf structure for clusterv3.Cluster, listenerv3.Listener, and routerv3.Router respectively.


Query and Listing (GET)

Use these endpoints to inspect the current state of the in-memory snapshot.

Endpoint Method Description Query Parameters Response Structure
/list-clusters GET Lists all enabled and disabled Clusters. None {"enabled": [...], "disabled": [...]}
/get-cluster GET Retrieves the details of a specific Cluster. ?name=my-cluster Full Cluster Protobuf JSON
/list-listeners GET Lists all enabled and disabled Listeners. None {"enabled": [...], "disabled": [...]}
/get-listener GET Retrieves the details of a specific Listener. ?name=my-listener Full Listener Protobuf JSON
/list-routes GET Lists all enabled and disabled Routes. None {"enabled": [...], "disabled": [...]}
/get-route GET Retrieves the details of a specific Route. ?name=my-route Full Route Protobuf JSON

Persistence (POST)

These handlers manage loading and saving the configuration snapshot from/to persistent storage (Database or local File).

Database Handlers

Endpoint Method Description Query Parameters
/load-from-db POST Loads the complete configuration from the persistent database into the snapshot cache. None
/flush-to-db POST Saves the current snapshot from the cache (source of truth) to the persistent database. ?deleteMissing=true/1 (Optional)

/flush-to-db Logic:

  • By default, it performs a logical flush (updates existing, adds new, but does not physically delete resources from the DB).
  • If the query parameter deleteMissing=true or deleteMissing=1 is provided, it performs an actual flush, physically deleting any resources from the database that are no longer present in the in-memory cache.

File Handlers

Endpoint Method Description Request Body Example
/load-from-file POST Loads a snapshot from a local file at the specified path and applies it to the cache. {"path": "/tmp/snapshot.json"}
/save-to-file POST Saves the current cache snapshot to a local file at the specified path. {"path": "/tmp/snapshot.json"}