k3s-cluster/kubernetes/main/apps/game-servers/network_policy.yaml

36 lines
845 B
YAML
Raw Permalink Normal View History

2023-04-19 23:37:53 +00:00
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: deny-most-allow-some
namespace: game-servers
spec:
# Apply to all pods in this namespace
podSelector: {}
ingress:
- from:
# Allow all pods in this namespace
- namespaceSelector:
matchLabels:
name: "game-servers"
# Allow traefik pods
- namespaceSelector:
matchLabels:
name: "traefik"
# Allow all pods with this label
- podSelector:
matchLabels:
2024-01-27 04:49:45 +00:00
needsGameServers: "yes"
egress:
- to:
- ipBlock:
2024-01-27 05:59:25 +00:00
# allow all IPs
cidr: 0.0.0.0/0
except:
# except the private IP ranges: https://en.wikipedia.org/wiki/Private_network
- 10.0.0.0/8
- 192.168.0.0/16
- 172.16.0.0/20
- ipBlock:
cidr: 192.168.87.250/24 # server