-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[backport 2.10] Enable internal traffic for workloads exposed by v2al…
…pha1 APIRule (#1686) * Enable internal traffic for workloads exposed by v2alpha1 APIRule (#1666) * Enable internal traffic for workloads exposed by v2alpha1 APIRule * Remove with labels * Add RN * Update desired_test.go * Revert changes of get service selector * Switch logic to allow instead of disallow * Update docs/release-notes/2.12.0.md Co-authored-by: Natalia Sitko <[email protected]> * Pass down podSelector from top to bottom --------- Co-authored-by: Natalia Sitko <[email protected]> * Add RN for 2.10.4 --------- Co-authored-by: Natalia Sitko <[email protected]>
- Loading branch information
1 parent
0acd1c4
commit ba18ce5
Showing
12 changed files
with
228 additions
and
55 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
## Bugfixes | ||
|
||
We've fixed the [issue](https://github.com/kyma-project/api-gateway/issues/1632) where a workload exposed via a `v2alpha1` APIRule was not accessible from within the cluster. |
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,3 @@ | ||
## Bugfixes | ||
|
||
We've fixed the [issue](https://github.com/kyma-project/api-gateway/issues/1632) where a workload exposed via a `v2alpha1` APIRule was not accessible from within the cluster. |
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
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
95 changes: 95 additions & 0 deletions
95
internal/processing/processors/v2alpha1/authorizationpolicy/internal_access_test.go
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,95 @@ | ||
package authorizationpolicy_test | ||
|
||
import ( | ||
"context" | ||
"github.com/kyma-project/api-gateway/internal/processing/processors/v2alpha1/authorizationpolicy" | ||
|
||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
securityv1beta1 "istio.io/client-go/pkg/apis/security/v1beta1" | ||
) | ||
|
||
var _ = Describe("Internal access from cluster APs", func() { | ||
It("should create an AP for internal access, one if only one service is used", func() { | ||
// given | ||
ruleJwt := newNoAuthRuleBuilderWithDummyData(). | ||
withPath("/abc"). | ||
build() | ||
|
||
noAuthRule := newNoAuthRuleBuilderWithDummyData(). | ||
withPath("/def"). | ||
build() | ||
|
||
apiRule := newAPIRuleBuilderWithDummyData(). | ||
withRules(ruleJwt, noAuthRule). | ||
build() | ||
svc := newServiceBuilderWithDummyData().build() | ||
client := getFakeClient(svc) | ||
processor := authorizationpolicy.NewProcessor(&testLogger, apiRule) | ||
|
||
// when | ||
result, err := processor.EvaluateReconciliation(context.Background(), client) | ||
|
||
Expect(err).To(BeNil()) | ||
Expect(result).To(HaveLen(3)) | ||
|
||
goodAps := 0 | ||
for i := 0; i < 3; i++ { | ||
ap := result[i].Obj.(*securityv1beta1.AuthorizationPolicy) | ||
if len(ap.Spec.Rules[0].To) == 0 { | ||
Expect(len(ap.Spec.Rules[0].From)).To(Equal(1)) | ||
Expect(ap.Spec.Rules[0].From[0].Source.NotPrincipals).To(ConsistOf("cluster.local/ns/istio-system/sa/istio-ingressgateway-service-account")) | ||
goodAps++ | ||
} else if len(ap.Spec.Rules[0].To) == 1 { | ||
if ap.Spec.Rules[0].To[0].Operation.Paths[0] == "/abc" { | ||
goodAps++ | ||
} else if ap.Spec.Rules[0].To[0].Operation.Paths[0] == "/def" { | ||
goodAps++ | ||
} | ||
} | ||
} | ||
Expect(goodAps).To(Equal(3)) | ||
}) | ||
|
||
It("should create an AP for internal access, two if two services are used", func() { | ||
// given | ||
ruleJwt := newNoAuthRuleBuilderWithDummyData(). | ||
withPath("/abc"). | ||
build() | ||
|
||
noAuthRule := newNoAuthRuleBuilderWithDummyData(). | ||
withPath("/def"). | ||
withServiceName("different-service"). | ||
build() | ||
|
||
apiRule := newAPIRuleBuilderWithDummyData(). | ||
withRules(ruleJwt, noAuthRule). | ||
build() | ||
svc := newServiceBuilderWithDummyData().build() | ||
differentSvc := newServiceBuilderWithDummyData().withName("different-service").addSelector("a", "b").build() | ||
client := getFakeClient(svc, differentSvc) | ||
processor := authorizationpolicy.NewProcessor(&testLogger, apiRule) | ||
|
||
// when | ||
result, err := processor.EvaluateReconciliation(context.Background(), client) | ||
|
||
Expect(err).To(BeNil()) | ||
Expect(result).To(HaveLen(4)) | ||
|
||
for _, apResult := range result { | ||
ap := apResult.Obj.(*securityv1beta1.AuthorizationPolicy) | ||
|
||
if len(ap.Spec.Rules[0].To) > 0 { | ||
Expect(len(ap.Spec.Rules[0].To[0].Operation.Paths)).To(Equal(1)) | ||
if ap.Spec.Rules[0].To[0].Operation.Paths[0] == "/abc" { | ||
Expect(ap.Spec.Rules[0].To[0].Operation.Paths).To(ContainElement("/abc")) | ||
} else if ap.Spec.Rules[0].To[0].Operation.Paths[0] == "/def" { | ||
Expect(ap.Spec.Rules[0].To[0].Operation.Paths).To(ContainElement("/def")) | ||
} | ||
} else { | ||
Expect(len(ap.Spec.Rules[0].From)).To(Equal(1)) | ||
Expect(ap.Spec.Rules[0].From[0].Source.NotPrincipals).To(ConsistOf("cluster.local/ns/istio-system/sa/istio-ingressgateway-service-account")) | ||
} | ||
} | ||
}) | ||
}) |
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.