Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: auto-add istio ingress gateway namespace to AuthorizationPolicy #344

Merged
merged 3 commits into from
Oct 30, 2024

Conversation

schahal
Copy link
Contributor

@schahal schahal commented Oct 30, 2024

Ref: #342

Motivation

We have an AuthorizationPolicy where users can set allowedNamespaces. However, it's easy to miss the namespace of the ingress gateway that users may want their VirtualService tied to.

What This Does

This parses the namespace of the istio gateways that users provide and creates a new list by appending it to the allowedNamespaces-provided list adds a separate rule for it

This is a safe assumption due to our checks of its format:

{{ fail ".Values.virtualService.gateways entries must be in the form of: namespace/gateway-name" }}

Test

Updated set network.allowAll and virtualService.enabled in values.local.yaml to `true...

Resulting relevant diff of make template:

First Commit

--- /tmp/simple-app-orig.yaml	2024-10-29 19:55:03
+++ /tmp/simple-app-new.yaml	2024-10-29 19:57:33
...
@@ -424,7 +424,7 @@
 metadata:
   name: simple-app
   labels:
-    helm.sh/chart: simple-app-1.12.1
+    helm.sh/chart: simple-app-1.12.2
     app.kubernetes.io/version: "latest"
     app.kubernetes.io/managed-by: Helm
     tags.datadoghq.com/service: "simple-app"
@@ -466,6 +466,7 @@
         namespaces:
         - foo
         - bar
+        - istio-gateways
     to:
     - operation:
         ports:
...

Updated Commit

...
@@ -471,6 +471,15 @@
         ports:
         - "80"
         - "8443"
+  - from:
+    - source:
+        namespaces:
+        - "istio-gateways"
+    to:
+    - operation:
+        ports:
+        - "80"
+        - "8443"
 ---
...

@schahal schahal requested a review from a team as a code owner October 30, 2024 03:09
@schahal schahal requested a review from diranged October 30, 2024 04:09
@schahal schahal force-pushed the chore/auth-pol-add-ing-gateway-ns branch from 55b5e6e to 5f2eeae Compare October 30, 2024 04:32
@schahal schahal merged commit 0f2cfbe into main Oct 30, 2024
2 checks passed
@schahal schahal deleted the chore/auth-pol-add-ing-gateway-ns branch October 30, 2024 19:39
schahal added a commit that referenced this pull request Nov 2, 2024
#346)

## Why

There may be apps that pull in and sub-chart `nd-common` , but they
don't have the `virtualService: *` key set in their values.

In those cases, helm install may fail when we added
#344.

Slightly tweaking nd-common AuthPolicy template to render cleanly in
those scenarios
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants