-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
create a network policy restricting access to backend, specify cors o…
…rigin for backend
- Loading branch information
1 parent
396771c
commit 833e0b0
Showing
2 changed files
with
59 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
apiVersion: networking.k8s.io/v1 | ||
kind: NetworkPolicy | ||
metadata: | ||
name: backend-network-policy | ||
spec: | ||
podSelector: | ||
matchLabels: | ||
app: backend | ||
policyTypes: | ||
- Ingress | ||
- Egress | ||
ingress: | ||
- from: | ||
# Allow traffic from the Ingress controller namespace | ||
- namespaceSelector: | ||
matchLabels: | ||
kubernetes.io/metadata.name: ingress-nginx | ||
# # Also allow traffic from frontend pods (if needed) | ||
# - podSelector: | ||
# matchLabels: | ||
# app: frontend | ||
- ports: | ||
- protocol: TCP | ||
port: 8000 | ||
egress: | ||
- to: | ||
# Allow access to DNS service | ||
- namespaceSelector: | ||
matchLabels: | ||
kubernetes.io/metadata.name: kube-system | ||
ports: | ||
- protocol: UDP | ||
port: 53 | ||
- protocol: TCP | ||
port: 53 | ||
- to: | ||
# Allow specific egress to PostgreSQL database (consider specifying a specific CIDR if possible) | ||
- ipBlock: | ||
cidr: 0.0.0.0/0 # Update this if a more specific CIDR block can be used | ||
ports: | ||
- protocol: TCP | ||
port: 80 # For outbound web traffic | ||
- protocol: TCP | ||
port: 25060 # For PostgreSQL database |