-
Notifications
You must be signed in to change notification settings - Fork 208
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
connectivity: Introduce local redirect policy tests
Tests LRP connectivity scenarios with a configured skipRedirectFromBackend flag: - client pod to LRP frontend - LRP backend to LRP frontend Signed-off-by: Aditi Ghag <[email protected]> Signed-off-by: Aditi Ghag <[email protected]>
- Loading branch information
Showing
11 changed files
with
504 additions
and
13 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,53 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// Copyright Authors of Cilium | ||
|
||
package builder | ||
|
||
import ( | ||
_ "embed" | ||
|
||
"github.com/cilium/cilium-cli/connectivity/check" | ||
"github.com/cilium/cilium-cli/connectivity/tests" | ||
"github.com/cilium/cilium-cli/utils/features" | ||
) | ||
|
||
var ( | ||
//go:embed manifests/local-redirect-policy.yaml | ||
localRedirectPolicyYAML string | ||
) | ||
|
||
type localRedirectPolicy struct{} | ||
|
||
func (t localRedirectPolicy) build(ct *check.ConnectivityTest, _ map[string]string) { | ||
lrpFrontendIP := "169.254.169.254" | ||
lrpFrontendIPSkipRedirect := "169.254.169.255" | ||
newTest("lrp", ct). | ||
WithCiliumLocalRedirectPolicy(check.CiliumLocalRedirectPolicyParams{ | ||
Policy: localRedirectPolicyYAML, | ||
Name: "lrp-address-matcher", | ||
FrontendIP: lrpFrontendIP, | ||
SkipRedirectFromBackend: false, | ||
}). | ||
WithCiliumLocalRedirectPolicy(check.CiliumLocalRedirectPolicyParams{ | ||
Policy: localRedirectPolicyYAML, | ||
Name: "lrp-address-matcher-skip-redirect-from-backend", | ||
FrontendIP: lrpFrontendIPSkipRedirect, | ||
SkipRedirectFromBackend: true, | ||
}). | ||
WithFeatureRequirements(features.RequireEnabled(features.LocalRedirectPolicy)). | ||
WithFeatureRequirements(features.RequireEnabled(features.KPRSocketLB)). | ||
WithScenarios( | ||
tests.LRP(false), | ||
tests.LRP(true), | ||
). | ||
WithExpectations(func(a *check.Action) (egress, ingress check.Result) { | ||
if a.Scenario().Name() == "local-redirect-policy-skip-redirect-from-backend" { | ||
if a.Source().HasLabel("role", "lrp-backend") && | ||
a.Destination().Address(features.IPFamilyV4) == lrpFrontendIPSkipRedirect { | ||
return check.ResultCurlTimeout, check.ResultNone | ||
} | ||
return check.ResultOK, check.ResultNone | ||
} | ||
return check.ResultOK, check.ResultNone | ||
}) | ||
} |
21 changes: 21 additions & 0 deletions
21
connectivity/builder/manifests/local-redirect-policy-skip-redirect.yaml
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,21 @@ | ||
apiVersion: cilium.io/v2 | ||
kind: CiliumLocalRedirectPolicy | ||
metadata: | ||
name: # set by the check package in WithCiliumLocalRedirectPolicy() | ||
spec: | ||
redirectFrontend: | ||
addressMatcher: | ||
ip: # set by the check package in WithCiliumLocalRedirectPolicy() | ||
toPorts: | ||
- port: "80" | ||
name: "tcp" | ||
protocol: TCP | ||
redirectBackend: | ||
localEndpointSelector: | ||
matchLabels: | ||
role: lrp-backend | ||
toPorts: | ||
- port: "8080" | ||
name: "tcp-8080" | ||
protocol: TCP | ||
skipRedirectFromBackend: # set by the check package in WithCiliumLocalRedirectPolicy() |
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,20 @@ | ||
apiVersion: cilium.io/v2 | ||
kind: CiliumLocalRedirectPolicy | ||
metadata: | ||
name: lrp-addr-matcher | ||
spec: | ||
redirectFrontend: | ||
addressMatcher: | ||
ip: "169.254.169.254" | ||
toPorts: | ||
- port: "8080" | ||
name: "tcp" | ||
protocol: TCP | ||
redirectBackend: | ||
localEndpointSelector: | ||
matchLabels: | ||
role: lrp-backend | ||
toPorts: | ||
- port: "8080" | ||
name: "tcp-8080" | ||
protocol: TCP |
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
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.