Skip to content

Commit

Permalink
add egress rules for sentinel np
Browse files Browse the repository at this point in the history
  • Loading branch information
rurkss committed Feb 7, 2024
1 parent 7a0d2dd commit 31cb162
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
13 changes: 13 additions & 0 deletions operator/redisfailover/service/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,19 @@ func generateSentinelNetworkPolicy(rf *redisfailoverv1.RedisFailover, labels map
Ports: ports,
},
},
Egress: []np.NetworkPolicyEgressRule{
np.NetworkPolicyEgressRule{
To: []np.NetworkPolicyPeer{
np.NetworkPolicyPeer{
NamespaceSelector: &metav1.LabelSelector{
MatchLabels: map[string]string{
"app.kubernetes.io/instance": namespace,
},
},
},
},
},
},
},
}
}
Expand Down
39 changes: 39 additions & 0 deletions operator/redisfailover/service/generator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1478,6 +1478,19 @@ func TestSentinelNetworkPolicy(t *testing.T) {
},
},
},
Egress: []networkingv1.NetworkPolicyEgressRule{
networkingv1.NetworkPolicyEgressRule{
To: []networkingv1.NetworkPolicyPeer{
networkingv1.NetworkPolicyPeer{
NamespaceSelector: &metav1.LabelSelector{
MatchLabels: map[string]string{
"app.kubernetes.io/instance": namespace,
},
},
},
},
},
},
},
},
},
Expand Down Expand Up @@ -1534,6 +1547,19 @@ func TestSentinelNetworkPolicy(t *testing.T) {
},
},
},
Egress: []networkingv1.NetworkPolicyEgressRule{
networkingv1.NetworkPolicyEgressRule{
To: []networkingv1.NetworkPolicyPeer{
networkingv1.NetworkPolicyPeer{
NamespaceSelector: &metav1.LabelSelector{
MatchLabels: map[string]string{
"app.kubernetes.io/instance": namespace,
},
},
},
},
},
},
},
},
},
Expand Down Expand Up @@ -1600,6 +1626,19 @@ func TestSentinelNetworkPolicy(t *testing.T) {
},
},
},
Egress: []networkingv1.NetworkPolicyEgressRule{
networkingv1.NetworkPolicyEgressRule{
To: []networkingv1.NetworkPolicyPeer{
networkingv1.NetworkPolicyPeer{
NamespaceSelector: &metav1.LabelSelector{
MatchLabels: map[string]string{
"app.kubernetes.io/instance": namespace,
},
},
},
},
},
},
},
},
},
Expand Down

0 comments on commit 31cb162

Please sign in to comment.