Skip to content

Commit ac283a0

Browse files
fix(operator): add extract selectors to gateway in netobserv mode to fix
fine-grained AuthZ
1 parent 145b063 commit ac283a0

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

operator/internal/manifests/gateway_tenants_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -944,6 +944,9 @@ func TestConfigureDeploymentForMode(t *testing.T) {
944944
Containers: []corev1.Container{
945945
{
946946
Name: gatewayContainerName,
947+
Args: []string{
948+
"--logs.auth.extract-selectors=SrcK8S_Namespace,DstK8S_Namespace",
949+
},
947950
},
948951
{
949952
Name: "opa",
@@ -1051,6 +1054,9 @@ func TestConfigureDeploymentForMode(t *testing.T) {
10511054
Containers: []corev1.Container{
10521055
{
10531056
Name: gatewayContainerName,
1057+
Args: []string{
1058+
"--logs.auth.extract-selectors=SrcK8S_Namespace,DstK8S_Namespace",
1059+
},
10541060
},
10551061
{
10561062
Name: "opa",

operator/internal/manifests/openshift/configure.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,23 @@ func ConfigureGatewayDeployment(
7373
return kverrors.Wrap(err, "failed to merge sidecar container spec ")
7474
}
7575

76-
if mode == lokiv1.OpenshiftLogging {
76+
if mode == lokiv1.OpenshiftLogging || mode == lokiv1.OpenshiftNetwork {
7777
// enable extraction of namespace selector
7878
for i, c := range d.Spec.Template.Spec.Containers {
7979
if c.Name != "gateway" {
8080
continue
8181
}
8282

83+
var authSelectors string
84+
switch mode {
85+
case lokiv1.OpenshiftLogging:
86+
authSelectors = opaDefaultLabelMatchers
87+
case lokiv1.OpenshiftNetwork:
88+
authSelectors = opaNetworkLabelMatchers
89+
}
90+
8391
d.Spec.Template.Spec.Containers[i].Args = append(d.Spec.Template.Spec.Containers[i].Args,
84-
fmt.Sprintf("--logs.auth.extract-selectors=%s", opaDefaultLabelMatchers),
92+
fmt.Sprintf("--logs.auth.extract-selectors=%s", authSelectors),
8593
)
8694
}
8795
}

0 commit comments

Comments
 (0)