Skip to content

Commit 71f740d

Browse files
feat: add network policies for otomi-api (#2490)
Co-authored-by: jeho <[email protected]>
1 parent 96f0d34 commit 71f740d

File tree

5 files changed

+63
-1
lines changed

5 files changed

+63
-1
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{{- if .Values.netpols.otomiApi }}
2+
---
3+
apiVersion: networking.k8s.io/v1
4+
kind: NetworkPolicy
5+
metadata:
6+
name: otomi-api-platform-policy
7+
namespace: otomi
8+
labels:
9+
{{- include "apl-network-policies.labels" . | nindent 4 }}
10+
app: otomi-api
11+
spec:
12+
podSelector:
13+
matchLabels:
14+
app.kubernetes.io/name: otomi-api
15+
policyTypes:
16+
- Ingress
17+
ingress:
18+
# Allow access from Istio public ingress gateway
19+
- from:
20+
- namespaceSelector:
21+
matchLabels:
22+
name: istio-system
23+
podSelector:
24+
matchLabels:
25+
app.kubernetes.io/instance: istio-ingressgateway-public
26+
# Allow access from gitea for webhook notifications
27+
- from:
28+
- namespaceSelector:
29+
matchLabels:
30+
name: gitea
31+
podSelector:
32+
matchLabels:
33+
app: gitea
34+
# Allow monitoring access for metrics scraping
35+
- from:
36+
- namespaceSelector:
37+
matchLabels:
38+
name: monitoring
39+
podSelector:
40+
matchLabels:
41+
app.kubernetes.io/instance: po-prometheus
42+
# Allow internal otomi namespace communication
43+
- from:
44+
- namespaceSelector:
45+
matchLabels:
46+
name: otomi
47+
{{- end }}

charts/apl-network-policies/values.yaml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
# Example configuration (all commented out):
88
# Simple on/off switch per application
99
# netpols:
10-
# gitea: true # Enable network policies for Gitea with sensible defaults
10+
# gitea: true # Enable network policies for Gitea with sensible defaults
11+
# otomiApi: true # Enable network policies for otomi-api with sensible defaults
1112

1213
# Network policy behavior when enabled:
1314
#
@@ -23,5 +24,13 @@
2324
# * CNPG system (for database management)
2425
# * Internal gitea namespace communication
2526
#
27+
# For otomi-api (netpols.otomiApi: true):
28+
# - Creates a NetworkPolicy in the otomi namespace
29+
# - Allows ingress from:
30+
# * Istio public ingress gateway (for web access)
31+
# * Gitea namespace (for webhook notifications)
32+
# * Monitoring namespace (for metrics scraping)
33+
# * Internal otomi namespace communication
34+
#
2635
# The complex network policy rules are baked into the chart templates,
2736
# so users only need to toggle network policies on/off per application.

helmfile.d/snippets/defaults.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -967,6 +967,8 @@ environments:
967967
otomi-api:
968968
editorInactivityTimeout: 1
969969
_rawValues: {}
970+
networkPolicies:
971+
enabled: true
970972
resources:
971973
api:
972974
limits:

values-schema.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2531,6 +2531,8 @@ properties:
25312531
$ref: '#/definitions/resources'
25322532
tools:
25332533
$ref: '#/definitions/resources'
2534+
networkPolicies:
2535+
$ref: '#/definitions/appNetworkPolicyConfig'
25342536
otomi-console:
25352537
additionalProperties: false
25362538
properties:
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
{{- $v := .Values }}
22
{{- $a := $v.apps }}
3+
{{- $oa := $v.apps | get "otomi-api" }}
34

45
# Simple per-app network policy configuration
56
netpols:
67
gitea: {{ $a.gitea.networkPolicies.enabled}}
8+
otomiApi: {{ $oa.networkPolicies.enabled}}

0 commit comments

Comments
 (0)