feat: Add NetworkPolicy for Ollama security (Task 3)
All checks were successful
sync-to-forgejo / sync (push) Successful in 22s

Restricts ingress to Ollama service from users, payments, and nxtgauge-ai-assistant only
This commit is contained in:
sync-test 2026-07-06 01:48:23 +05:30
parent f0906d2c67
commit c73b8740b4
2 changed files with 55 additions and 1 deletions

View file

@ -5,3 +5,4 @@ resources:
- pvc.yaml
- deployment.yaml
- service.yaml
- networkpolicy.yaml

View file

@ -0,0 +1,53 @@
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: ollama-ingress-restriction
namespace: nxtgauge-ai
labels:
app: ollama
spec:
podSelector:
matchLabels:
app: ollama
policyTypes:
- Ingress
ingress:
# Allow traffic from users service (port 11434)
- from:
- namespaceSelector:
matchLabels:
name: default
podSelector:
matchLabels:
app: users
ports:
- protocol: TCP
port: 11434
# Allow traffic from payments service
- from:
- namespaceSelector:
matchLabels:
name: default
podSelector:
matchLabels:
app: payments
ports:
- protocol: TCP
port: 11434
# Allow traffic from nxtgauge-ai-assistant service
- from:
- namespaceSelector:
matchLabels:
name: nxtgauge-ai
podSelector:
matchLabels:
app: nxtgauge-ai-assistant
ports:
- protocol: TCP
port: 11434
# Allow traffic from within the same namespace (for health checks, etc.)
- from:
- podSelector: {}
ports:
- protocol: TCP
port: 11434