-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Remove shutdown_rx from downstream loop * Improve missing gameserver warning * Add name as property in warning * Implement Agent service * use random port in test * Add backtrace and nocapture to test * * Upgrade to 50ms delay. (#752) --------- Co-authored-by: Mark Mandel <[email protected]>
- Loading branch information
1 parent
8c2bc21
commit 57244b4
Showing
11 changed files
with
467 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# Control Plane Relay | ||
|
||
| services | ports | Protocol | | ||
|----------|-------|-----------| | ||
| QCMP | 7600 | UDP(IPv4 && IPv6) | | ||
|
||
> **Note:** This service is currently in active experimentation and development | ||
so there may be bugs which cause it to be unusable for production, as always | ||
all bug reports are welcome and appreciated. | ||
|
||
For multi-cluster integration, Quilkin provides a `agent` service, that can be | ||
deployed to a cluster to act as a beacon for QCMP pings and forward cluster | ||
configuration information to a `relay` service | ||
|
||
To view all options for the `agent` subcommand, run: | ||
|
||
```shell | ||
$ quilkin agent --help | ||
{{#include ../../../target/quilkin.agent.commands}} | ||
``` | ||
|
||
## Quickstart | ||
The simplest version of the `agent` service is just running `quilkin agent`, | ||
this will setup just the QCMP service allowing the agent to be pinged for | ||
measuring round-time-trips (RTT). | ||
|
||
``` | ||
quilkin agent | ||
``` | ||
|
||
To run an agent with the relay (see [`relay` quickstart](./relay.md#quickstart) | ||
for more information), you just need to specify the relay endpoint with the | ||
`--relay` flag **and** provide a configuration discovery provider such as a | ||
configuration file or Agones. | ||
|
||
``` | ||
quilkin --admin-adress http://localhost:8001 agent --relay http://localhost:7900 file quilkin.yaml | ||
``` | ||
|
||
Now if we run cURL on both the relay and the control plane we should see that | ||
they both contain the same set of endpoints. | ||
|
||
```bash | ||
# Check Agent | ||
curl localhost:8001/config | ||
# Check Relay | ||
curl localhost:8000/config | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
/* | ||
* Copyright 2023 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
use std::sync::Arc; | ||
|
||
use crate::config::Config; | ||
|
||
define_port!(7600); | ||
|
||
/// Runs Quilkin as a relay service that runs a Manager Discovery Service | ||
/// (mDS) for accepting cluster and configuration information from xDS | ||
/// management services, and exposing it as a single merged xDS service for | ||
/// proxy services. | ||
#[derive(clap::Args, Clone, Debug)] | ||
pub struct Agent { | ||
/// Port for QCMP service. | ||
#[clap(short, long, env = "QCMP_PORT", default_value_t = PORT)] | ||
pub qcmp_port: u16, | ||
/// One or more `quilkin relay` endpoints to push configuration changes to. | ||
#[clap(short, long, env = "QUILKIN_MANAGEMENT_SERVER")] | ||
pub relay: Vec<tonic::transport::Endpoint>, | ||
/// The `region` to set in the cluster map for any provider | ||
/// endpoints discovered. | ||
#[clap(long, env = "QUILKIN_REGION")] | ||
pub region: Option<String>, | ||
/// The `zone` in the `region` to set in the cluster map for any provider | ||
/// endpoints discovered. | ||
#[clap(long, env = "QUILKIN_ZONE")] | ||
pub zone: Option<String>, | ||
/// The `sub_zone` in the `zone` in the `region` to set in the cluster map | ||
/// for any provider endpoints discovered. | ||
#[clap(long, env = "QUILKIN_SUB_ZONE")] | ||
pub sub_zone: Option<String>, | ||
/// The configuration source for a management server. | ||
#[clap(subcommand)] | ||
pub provider: Option<crate::config::Providers>, | ||
} | ||
|
||
impl Default for Agent { | ||
fn default() -> Self { | ||
Self { | ||
qcmp_port: PORT, | ||
relay: <_>::default(), | ||
region: <_>::default(), | ||
zone: <_>::default(), | ||
sub_zone: <_>::default(), | ||
provider: <_>::default(), | ||
} | ||
} | ||
} | ||
|
||
impl Agent { | ||
pub async fn run( | ||
&self, | ||
config: Arc<Config>, | ||
mut shutdown_rx: tokio::sync::watch::Receiver<()>, | ||
) -> crate::Result<()> { | ||
let locality = (self.region.is_some() || self.zone.is_some() || self.sub_zone.is_some()) | ||
.then(|| crate::endpoint::Locality { | ||
region: self.region.clone().unwrap_or_default(), | ||
zone: self.zone.clone().unwrap_or_default(), | ||
sub_zone: self.sub_zone.clone().unwrap_or_default(), | ||
}); | ||
|
||
let _mds_task = if !self.relay.is_empty() { | ||
let _provider_task = match self.provider.as_ref() { | ||
Some(provider) => Some(provider.spawn(config.clone(), locality.clone())), | ||
None => return Err(eyre::eyre!("no configuration provider given")), | ||
}; | ||
|
||
let task = crate::xds::client::MdsClient::connect( | ||
String::clone(&config.id.load()), | ||
self.relay.clone(), | ||
); | ||
|
||
tokio::select! { | ||
result = task => Some(result?.mds_client_stream(config.clone())), | ||
_ = shutdown_rx.changed() => return Ok(()), | ||
} | ||
} else { | ||
tracing::info!("no relay servers given"); | ||
None | ||
}; | ||
|
||
crate::protocol::spawn(self.qcmp_port).await?; | ||
shutdown_rx.changed().await.map_err(From::from) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.