Skip to content

Commit 66b2766

Browse files
p-rogPrzemyslaw Roguski
andauthored
Network policy for the qtodo (#126)
* Fixing db network policy bug, adding new qtodo egress network policies and default deny network policy * cleaning all changes * db network policy file change * feat: add qtodo egress NetworkPolicy (port-restricted, no default-deny) * fixing the namespace name * changing the ingress policy, to allow qtodo correct network communication * NP tweaks * removing egress qtodo network policies due to problems with OVN-K and later broken DNS * sync with PR#125 * Pushing correct, fully covered network polices, with correct DNS port and Keycloak port * openshift-ingress labels update, because policy-group.network.openshift.io/ingress: triggers OVN-K's special ACL handling for host-network traffic * changing the namespaceSelector: for Keycloak, because here Keycloak asnwers on both an internal hostname (for back-channel) and an external hostname (for browser redirects) * Adding default deny policy --------- Co-authored-by: Przemyslaw Roguski <proguski@proguski-thinkpadp1gen7.rmtpl.csb>
1 parent 6773186 commit 66b2766

6 files changed

Lines changed: 100 additions & 30 deletions

File tree

charts/qtodo/templates/db-network-policy.yaml

Lines changed: 0 additions & 14 deletions
This file was deleted.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
apiVersion: networking.k8s.io/v1
2+
kind: NetworkPolicy
3+
metadata:
4+
name: default-deny-in-namespace-qtodo
5+
namespace: {{ .Release.Namespace }}
6+
spec:
7+
podSelector: {}
8+
policyTypes:
9+
- Ingress
10+
- Egress

charts/qtodo/templates/network-policy.yaml

Lines changed: 0 additions & 15 deletions
This file was deleted.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
apiVersion: networking.k8s.io/v1
2+
kind: NetworkPolicy
3+
metadata:
4+
name: qtodo-db-network-policy
5+
namespace: {{ .Release.Namespace }}
6+
spec:
7+
podSelector:
8+
matchLabels:
9+
app: qtodo-db
10+
policyTypes:
11+
- Ingress
12+
- Egress
13+
ingress:
14+
# PostgreSQL — only from qtodo app pods in the same namespace
15+
- ports:
16+
- protocol: TCP
17+
port: 5432
18+
from:
19+
- podSelector:
20+
matchLabels:
21+
app: qtodo
22+
egress:
23+
# DNS resolution via CoreDNS — OCP uses port 5353 (not 53)
24+
- ports:
25+
- protocol: UDP
26+
port: 5353
27+
- protocol: TCP
28+
port: 5353
29+
to:
30+
- namespaceSelector:
31+
matchLabels:
32+
kubernetes.io/metadata.name: openshift-dns
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
apiVersion: networking.k8s.io/v1
2+
kind: NetworkPolicy
3+
metadata:
4+
name: qtodo-network-policy
5+
namespace: {{ .Release.Namespace }}
6+
spec:
7+
podSelector:
8+
matchLabels:
9+
app: qtodo
10+
policyTypes:
11+
- Ingress
12+
- Egress
13+
ingress:
14+
# Only allow inbound traffic from the OpenShift router.
15+
# Router pods use hostNetwork:true so traffic arrives from node IPs, not pod IPs.
16+
# OVN-K requires the policy-group.network.openshift.io/ingress label (empty value)
17+
# to generate the correct ACLs for host-network ingress traffic.
18+
- ports:
19+
- protocol: TCP
20+
port: 8080
21+
from:
22+
- namespaceSelector:
23+
matchLabels:
24+
policy-group.network.openshift.io/ingress: ""
25+
egress:
26+
# DNS resolution via CoreDNS — OCP uses port 5353 (not 53)
27+
- ports:
28+
- protocol: UDP
29+
port: 5353
30+
- protocol: TCP
31+
port: 5353
32+
to:
33+
- namespaceSelector:
34+
matchLabels:
35+
kubernetes.io/metadata.name: openshift-dns
36+
# PostgreSQL — qtodo-db pod in the same namespace
37+
- ports:
38+
- protocol: TCP
39+
port: 5432
40+
to:
41+
- podSelector:
42+
matchLabels:
43+
app: qtodo-db
44+
# Vault API — SPIFFE JWT auth for DB credentials retrieval
45+
- ports:
46+
- protocol: TCP
47+
port: 8200
48+
to:
49+
- namespaceSelector:
50+
matchLabels:
51+
kubernetes.io/metadata.name: vault
52+
# Keycloak OIDC back-channel — external Route resolves to the router's load-balancer IP,
53+
# which is not a pod IP in any namespace. namespaceSelector cannot match external IPs,
54+
# so a port-only rule is required for the code-to-token exchange POST to work.
55+
- ports:
56+
- protocol: TCP
57+
port: 443

charts/ztvp-certificates/values.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ configMapName: ztvp-trusted-ca
119119
# are auto-injected into all workloads via the cluster network operator.
120120
# Required for workloads that verify TLS of routes (e.g., ACS Central reaching Keycloak).
121121
proxyCA:
122-
enabled: false
122+
enabled: true
123123
configMapName: ztvp-proxy-ca
124124

125125
# Automatic rollout configuration

0 commit comments

Comments
 (0)