Skip to content
This repository has been archived by the owner on Jul 11, 2023. It is now read-only.

Commit

Permalink
Introducing per-service filtering (#1725)
Browse files Browse the repository at this point in the history
Introducing per-service filtering

Introduces per-destination filter-chain matching on outbound.
This change will allow setting specific L4 or L7 filtering, precursor
for TCP routing.

- Since we are filtering all permitted traffic, we can generalize the
remaining traffic and simplify Egress, which will not require a CIDR
anymore. (TODO: cleanup CIDR flags/code)
- Since we can match all destination traffic, Permissive mode can potentially 
use TCP proxy if we want (instead of wildcarded RDS) to allow also L4 protocols
between services.
- Additional work that might benefit from it: per-service route table
on RDS, TCP routing, ....

Additionally:
- Fixing the listener tests required adding the long-awaited catalog mock.
Will add more tests in subsequent commits.
  • Loading branch information
eduser25 authored Sep 25, 2020
1 parent 0d05587 commit dac3552
Show file tree
Hide file tree
Showing 10 changed files with 499 additions and 162 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ jobs:
env:
CERT_MANAGER: "tresor"
BOOKSTORE_SVC: "bookstore"
BOOKTHIEF_EXPECTED_RESPONSE_CODE: "404"
BOOKTHIEF_EXPECTED_RESPONSE_CODE: "0"
ENABLE_EGRESS: "false"
DEPLOY_TRAFFIC_SPLIT: "true"
CTR_TAG: ${{ github.sha }}
Expand Down Expand Up @@ -217,7 +217,7 @@ jobs:
env:
CERT_MANAGER: "cert-manager" # enables jetstack/cert-manager integration
BOOKSTORE_SVC: "bookstore-v1"
BOOKTHIEF_EXPECTED_RESPONSE_CODE: "404"
BOOKTHIEF_EXPECTED_RESPONSE_CODE: "0"
ENABLE_EGRESS: "false"
DEPLOY_TRAFFIC_SPLIT: "false"
DEPLOY_WITH_SAME_SA: "true"
Expand Down
2 changes: 1 addition & 1 deletion demo/cmd/bookthief/bookthief.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func main() {
// the HTTP response status code will differ for in-mesh requests.
//
// Expected response code when bookthief tries to buy books from the bookstore:
// 1. With SMI policies: 404
// 1. With SMI policies: 0
// 2. With permissive traffic policy: 200
//
// When it tries to make an egress request, we expect a 200 response with egress enabled and a 404 response with egress disabled.
Expand Down
2 changes: 1 addition & 1 deletion demo/deploy-bookthief.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ set -aueo pipefail
source .env

BOOKSTORE_SVC="${BOOKSTORE_SVC:-bookstore}"
BOOKTHIEF_EXPECTED_RESPONSE_CODE="${BOOKTHIEF_EXPECTED_RESPONSE_CODE:-404}"
BOOKTHIEF_EXPECTED_RESPONSE_CODE="${BOOKTHIEF_EXPECTED_RESPONSE_CODE:-0}"
CI_MAX_ITERATIONS_THRESHOLD="${CI_MAX_ITERATIONS_THRESHOLD:-0}"
CI_CLIENT_CONCURRENT_CONNECTIONS="${CI_CLIENT_CONCURRENT_CONNECTIONS:-1}"
ENABLE_EGRESS="${ENABLE_EGRESS:-false}"
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ require (
golang.org/x/lint v0.0.0-20200302205851-738671d3881b // indirect
golang.org/x/tools v0.0.0-20200911183043-b43031a33b24 // indirect
google.golang.org/grpc v1.27.0
google.golang.org/protobuf v1.23.0
gopkg.in/yaml.v2 v2.3.0
helm.sh/helm/v3 v3.2.0
k8s.io/api v0.18.5
Expand Down
289 changes: 289 additions & 0 deletions pkg/catalog/mock_catalog.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pkg/envoy/ads/response_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ var _ = Describe("Test ADS response functions", func() {
mockConfigurator.EXPECT().IsEgressEnabled().Return(false).AnyTimes()
mockConfigurator.EXPECT().IsPrometheusScrapingEnabled().Return(false).AnyTimes()
mockConfigurator.EXPECT().IsTracingEnabled().Return(false).AnyTimes()
mockConfigurator.EXPECT().IsPermissiveTrafficPolicyMode().Return(false).AnyTimes()

It("returns Aggregated Discovery Service response", func() {
s := NewADSServer(mc, true, tests.Namespace, mockConfigurator)
Expand Down
2 changes: 1 addition & 1 deletion pkg/envoy/lds/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ package lds
import "github.com/pkg/errors"

var (
errInvalidCIDRRange = errors.New("invalid CIDR range")
errNoValidTargetEndpoints = errors.New("No valid resolvable addresses")
)
Loading

0 comments on commit dac3552

Please sign in to comment.