Skip to content

Commit 3dec105

Browse files
authored
outbound: Require ClientPolicy discovery (#2265)
To support Gateway API-style routes in the outbound proxy, we need to begin discovering this route configuration from the control plane (via the new `OutboundPolicies` API). This change updates the proxy as follows: 1. Policy controller configuration is now required for the proxy. Previously, the policy API was optionally configured for the inbound proxy. 2. The sidecar and ingress proxies are updated to use client policies. Service profile configurations continue to be used when they include HTTP routes and/or traffic split. Otherwise, a client policy is used to route traffic. Outbound policies are currently discovered for *all* outbound IP addresses. Over time, the policy controller will assume responsibility to make *all* routing decisions. It does not yet serve responses for all cases, however, so some fallback behavior exists to use endpoint metadata from profile discovery, if it exists. The multi-cluster gateway configuration does not yet use policies for outbound routing. Furthermore, the proxy reports an IP logical address for policy routes (instead of a named address, as is done with profiles). There are no new metrics or labels introduced in this PR. Metrics changes will be made in follow-up changes.
1 parent 3b915d0 commit 3dec105

File tree

30 files changed

+1797
-369
lines changed

30 files changed

+1797
-369
lines changed

Cargo.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -982,6 +982,7 @@ dependencies = [
982982
"linkerd-io",
983983
"linkerd-meshtls",
984984
"linkerd-meshtls-rustls",
985+
"linkerd-proxy-client-policy",
985986
"linkerd-proxy-server-policy",
986987
"linkerd-tonic-watch",
987988
"linkerd-tracing",
@@ -1051,12 +1052,16 @@ dependencies = [
10511052
"linkerd-meshtls-rustls",
10521053
"linkerd-proxy-client-policy",
10531054
"linkerd-retry",
1055+
"linkerd-tonic-watch",
10541056
"linkerd-tracing",
1057+
"linkerd2-proxy-api",
1058+
"once_cell",
10551059
"parking_lot",
10561060
"pin-project",
10571061
"thiserror",
10581062
"tokio",
10591063
"tokio-test",
1064+
"tonic",
10601065
"tower",
10611066
"tower-test",
10621067
"tracing",

linkerd/app/gateway/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ impl Gateway {
5454
T: svc::Param<tls::ClientId>,
5555
T: svc::Param<inbound::policy::AllowPolicy>,
5656
T: svc::Param<Option<SessionProtocol>>,
57-
T: svc::Param<profiles::LookupAddr>,
5857
T: Clone + Send + Sync + Unpin + 'static,
5958
// Server-side socket
6059
I: io::AsyncRead + io::AsyncWrite + io::PeerAddr,

linkerd/app/gateway/src/server.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ impl Gateway {
3838
T: svc::Param<tls::ClientId>,
3939
T: svc::Param<inbound::policy::AllowPolicy>,
4040
T: svc::Param<Option<SessionProtocol>>,
41-
T: svc::Param<profiles::LookupAddr>,
4241
T: Clone + Send + Sync + Unpin + 'static,
4342
// Server-side socket
4443
I: io::AsyncRead + io::AsyncWrite + io::PeerAddr,
@@ -80,10 +79,12 @@ impl Gateway {
8079

8180
// Apply the gateway's allowlist to the profile discovery service.
8281
let allowlist = self.config.allow_discovery.clone().into();
83-
let profiles = profiles::WithAllowlist::new(profiles, allowlist);
82+
let mut profiles = profiles::WithAllowlist::new(profiles, allowlist);
8483
self.outbound
8584
.with_stack(protocol)
86-
.push_discover(profiles.into_service())
85+
.push_discover(svc::mk(move |GatewayAddr(addr)| {
86+
profiles.get_profile(profiles::LookupAddr(addr.into()))
87+
}))
8788
.into_stack()
8889
};
8990

linkerd/app/inbound/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ linkerd-http-access-log = { path = "../../http-access-log" }
2727
linkerd-idle-cache = { path = "../../idle-cache" }
2828
linkerd-meshtls = { path = "../../meshtls", optional = true }
2929
linkerd-meshtls-rustls = { path = "../../meshtls/rustls", optional = true }
30+
linkerd-proxy-client-policy = { path = "../../proxy/client-policy" }
3031
linkerd-tonic-watch = { path = "../../tonic-watch" }
3132
linkerd2-proxy-api = { version = "0.8", features = ["inbound"] }
3233
once_cell = "1"

linkerd/app/inbound/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ struct Runtime {
7070
drain: drain::Watch,
7171
}
7272

73+
/// Indicates the name to be used to route gateway connections.
7374
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
7475
pub struct GatewayAddr(pub NameAddr);
7576

linkerd/app/integration/src/client.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ impl Client {
119119
}
120120
}
121121

122+
#[track_caller]
122123
pub async fn get(&self, path: &str) -> String {
123124
let req = self.request_builder(path);
124125
let res = self.request(req.method("GET")).await.expect("response");

linkerd/app/integration/src/controller.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,32 +181,39 @@ fn grpc_unexpected_request() -> grpc::Status {
181181
}
182182

183183
impl DstSender {
184+
#[track_caller]
184185
pub fn send(&self, up: impl Into<pb::Update>) {
185186
self.0.send(Ok(up.into())).expect("send dst update")
186187
}
187188

189+
#[track_caller]
188190
pub fn send_err(&self, e: grpc::Status) {
189191
self.0.send(Err(e)).expect("send dst err")
190192
}
191193

194+
#[track_caller]
192195
pub fn send_addr(&self, addr: SocketAddr) {
193196
self.send(destination_add(addr))
194197
}
195198

199+
#[track_caller]
196200
pub fn send_h2_hinted(&self, addr: SocketAddr) {
197201
self.send(destination_add(addr).hint(Hint::H2));
198202
}
199203

204+
#[track_caller]
200205
pub fn send_no_endpoints(&self) {
201206
self.send(destination_exists_with_no_endpoints())
202207
}
203208
}
204209

205210
impl ProfileSender {
211+
#[track_caller]
206212
pub fn send(&self, up: pb::DestinationProfile) {
207213
self.0.send(Ok(up)).expect("send profile update")
208214
}
209215

216+
#[track_caller]
210217
pub fn send_err(&self, err: grpc::Status) {
211218
self.0.send(Err(err)).expect("send profile update")
212219
}

0 commit comments

Comments
 (0)