2023-03-28 18:39:22 +00:00
|
|
|
// Copyright (c) HashiCorp, Inc.
|
|
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
|
2022-05-27 11:38:52 +00:00
|
|
|
// Package proxycfg contains components for sourcing the data required to
|
|
|
|
// configure Connect proxies. The Manager provides an API with which proxy
|
|
|
|
// services can be registered, and coordinates the fetching (and refreshing)
|
|
|
|
// of intentions, upstreams, discovery chain, certificates etc. Consumers
|
|
|
|
// such as the xDS server can then subscribe to receive snapshots of this
|
|
|
|
// data whenever it changes.
|
2018-10-03 12:36:38 +00:00
|
|
|
//
|
2022-05-27 11:38:52 +00:00
|
|
|
// Consul client agents support the configuration of proxies locally
|
|
|
|
// registered to them, whereas Consul servers support both this and proxies
|
|
|
|
// in the catalog.
|
2018-10-03 12:36:38 +00:00
|
|
|
//
|
2022-05-27 11:38:52 +00:00
|
|
|
// The following diagram depicts the component relationships on a server, as
|
|
|
|
// this is the more complex mode of operation:
|
2018-10-03 12:36:38 +00:00
|
|
|
//
|
2022-10-21 19:58:06 +00:00
|
|
|
// +-------+ 1. +------------+
|
|
|
|
// | Local | ◀------------▶ | Local |
|
|
|
|
// | State | | State Sync |
|
|
|
|
// +-------+ +-----+------+
|
|
|
|
// ▲ |
|
2023-04-04 13:42:42 +00:00
|
|
|
// +-------+ | +---------------+ | 2.
|
|
|
|
// | envoy | 4. | 4a. | Local | |
|
|
|
|
// +-------+ | +-▶ | Config Source +-+ |
|
|
|
|
// | stream | | +---------------+ | |
|
|
|
|
// ▼ | | ▼ ▼
|
2022-10-21 19:58:06 +00:00
|
|
|
// +--------+ 3. +-+-+-----------+ 6. +----------+ 2a. +----------+
|
|
|
|
// | xDS +---▶ | Catalog +-----▶ | proxycfg +----▶ | proxycfg |
|
|
|
|
// | Server | ◀---+ Config Source +-----▶ | Manager +--+ | State |
|
|
|
|
// +--------+ 8. +----+----------+ 7. +----------+ | +----------+
|
|
|
|
// 5. | |
|
|
|
|
// ▼ 7a. | +----------+
|
|
|
|
// +-------+ +-▶ | proxycfg |
|
|
|
|
// | State | | State |
|
|
|
|
// | Store | +----------+
|
|
|
|
// +-------+
|
2022-10-14 09:26:42 +00:00
|
|
|
//
|
2022-10-21 19:58:06 +00:00
|
|
|
// 1. local.Sync watches the agent's local state for changes.
|
|
|
|
// 2. If any sidecar proxy or gateway services are registered to the local agent
|
|
|
|
// they are sync'd to the proxycfg.Manager.
|
|
|
|
// 2a. proxycfg.Manager creates a state object for the service and begins
|
|
|
|
// pre-fetching data (go to 8).
|
2023-04-04 13:42:42 +00:00
|
|
|
// 3. Client (i.e., envoy) begins a stream and the xDS server calls Watch on its
|
|
|
|
// ConfigSource - on a client agent this would be a local config source, on a
|
|
|
|
// server it would be a catalog config source.
|
|
|
|
// 4. On server, the catalog config source will check if service is registered locally.
|
2023-07-31 17:56:09 +00:00
|
|
|
// 4a. If the service *is* registered locally it hands off the local config
|
2022-10-21 19:58:06 +00:00
|
|
|
// source, which calls Watch on the proxycfg manager (and serves the pre-
|
|
|
|
// fetched data).
|
|
|
|
// 5. Otherwise, it fetches the service from the state store.
|
|
|
|
// 6. It calls Watch on the proxycfg manager.
|
|
|
|
// 7. It registers the service with the proxycfg manager.
|
|
|
|
// 7a. See: 2a.
|
|
|
|
// 8. xDS server receives snapshots of configuration data whenever it changes.
|
2018-10-03 12:36:38 +00:00
|
|
|
package proxycfg
|