Skip to content

Commit

Permalink
Initial DNS proxy implementation
Browse files Browse the repository at this point in the history
This copies much of the logic from Istio, however it also supports a multi-tenant proxy.

## New crate

The new `istio-dns` crate extends the Trust-DNS API to specifically support the DNS proxy use case. The existing Trust-DNS `Catalog` does not allow an `Authority` to conditionally indicate its answers as authoritative, which is something that a proxy needs to do. The code here was written with the intent of eventually upstreaming to Trust-DNS.

## Host aliases

Within ztunnel, a new `dns` package implements the `istio-dns` `Resolver`, and serves DNS directly from the `WorkloadStore`.

The logic for handling host aliases has been somewhat inverted from Istio. Istio pre-generated aliases for each client and added entries for all possible hosts to the lookup table.

However, in shared proxy mode we have to handle the problem that some host aliases are client-specific (e.g. just service-name without namespace). To account for this, we dynamically run the alias logic in reverse, trying to figure out the FQDN from the requested hostname. This means that no additional entries for aliases were necessary in the `WorkloadStore`.

## Forwarding

Ztunnel dns uses one of two types of DNS forwarders, depending on if shared or dedicated mode. When in shared mode, it needs to use the configuration for the client pod in order to forward to the appropriate upstream resolver.

Fixes #487
  • Loading branch information
nmittler committed Jun 7, 2023
1 parent 0b91907 commit de51a9e
Show file tree
Hide file tree
Showing 18 changed files with 2,962 additions and 251 deletions.
282 changes: 280 additions & 2 deletions Cargo.lock

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,13 @@ tower-hyper-http-body-compat = { version = "0", features = ["server", "http2"] }
futures-util = "0.3.26"
chrono = "0.4.23"

# DNS
istio-dns = { version = "0.0.0", path = "crates/dns" }
trust-dns-client = "0.22.0"
trust-dns-proto = "0.22.0"
trust-dns-server = "0.22.0"
trust-dns-resolver = "0.22.0"

[target.'cfg(target_os = "linux")'.dependencies]
netns-rs = "0.1.0"

Expand All @@ -102,6 +109,7 @@ incremental = true
[dev-dependencies]
criterion = { version = "0.4.0", features = ["async_tokio", "html_reports"] }
diff = "0.1.13"
istio-dns = { version = "0.0.0", path = "crates/dns", features = [ "testing" ] }
matches = "0.1.9"
test-case = "3.0.0"
#debug = true
Loading

0 comments on commit de51a9e

Please sign in to comment.