networkpolicy.yaml
Download networkpolicy.yaml as it is.
# Who may reach the gateway pods and the setup Job, and what they may reach.# Needs a network plugin that enforces NetworkPolicy (Calico, Cilium, most# managed clusters with it turned on); without one these change nothing.## Gateway pods:# in: the device ports (8080) from anywhere: the clocks, through the# load balancer;# the admin port (9090) from the other gateway pods (live views),# the setup Job, and Prometheus (edit the namespace below);# out: DNS, Postgres (5432), the Valkey (6379), the other gateway pods (9090), and sinks and# MQTT brokers (443, 8883, 1883). A webhook or broker on another# port, or a database on another port, needs its port added here.# The setup Job: DNS and the gateways' admin port only.## A listener on a new device port needs that port in the first ingress# rule too, as in devices-service.yaml. Kubelet probes come from the node# and are allowed by the common network plugins without a rule.apiVersion: networking.k8s.io/v1kind: NetworkPolicymetadata: name: houradvantage-gateway labels: app.kubernetes.io/component: gatewayspec: podSelector: matchLabels: app.kubernetes.io/name: houradvantage app.kubernetes.io/component: gateway policyTypes: [Ingress, Egress] ingress: # Devices. One entry per device port. - ports: - { protocol: TCP, port: 8080 } # Admin API: the other gateways, the setup Job, Prometheus. - from: - podSelector: matchLabels: app.kubernetes.io/name: houradvantage - namespaceSelector: matchLabels: kubernetes.io/metadata.name: monitoring ports: - { protocol: TCP, port: 9090 } egress: - ports: - { protocol: UDP, port: 53 } - { protocol: TCP, port: 53 } # Postgres. Narrow it with an ipBlock (the database's address) if you can. - ports: - { protocol: TCP, port: 5432 } # The Valkey the pods share. - to: - podSelector: matchLabels: app.kubernetes.io/name: houradvantage app.kubernetes.io/component: valkey ports: - { protocol: TCP, port: 6379 } # The other gateway pods' admin API (live views across pods). - to: - podSelector: matchLabels: app.kubernetes.io/name: houradvantage app.kubernetes.io/component: gateway ports: - { protocol: TCP, port: 9090 } # Webhook sinks (HTTPS) and MQTT brokers (TLS and plain). - ports: - { protocol: TCP, port: 443 } - { protocol: TCP, port: 8883 } - { protocol: TCP, port: 1883 }---apiVersion: networking.k8s.io/v1kind: NetworkPolicymetadata: name: houradvantage-setup labels: app.kubernetes.io/component: setupspec: podSelector: matchLabels: app.kubernetes.io/name: houradvantage app.kubernetes.io/component: setup policyTypes: [Ingress, Egress] # Nothing comes in. ingress: [] egress: - ports: - { protocol: UDP, port: 53 } - { protocol: TCP, port: 53 } - to: - podSelector: matchLabels: app.kubernetes.io/name: houradvantage app.kubernetes.io/component: gateway ports: - { protocol: TCP, port: 9090 }