apiVersion: networking.k8s.io/v1 kind: NetworkPolicy metadata: name: {{ luanti_wasm_name | to_json }} namespace: {{ luanti_wasm_namespace | to_json }} spec: podSelector: matchLabels: app: {{ luanti_wasm_name | to_json }} policyTypes: [Ingress, Egress] ingress: - ports: - port: 8080 protocol: TCP {% if luanti_wasm_ingress_peers | length > 0 %} from: {{ luanti_wasm_ingress_peers | to_json }} {% endif %} egress: - to: - namespaceSelector: matchLabels: kubernetes.io/metadata.name: kube-system podSelector: matchLabels: k8s-app: kube-dns ports: - port: 53 protocol: UDP - port: 53 protocol: TCP - to: {% for cidr in luanti_wasm_game_cidrs %} - ipBlock: cidr: {{ cidr | to_json }} {% endfor %} ports: - port: {{ luanti_wasm_game_port }} protocol: UDP {% if luanti_wasm_https_cidrs | length > 0 %} - to: {% for cidr in luanti_wasm_https_cidrs %} - ipBlock: cidr: {{ cidr | to_json }} {% endfor %} ports: - port: 443 protocol: TCP {% endif %}