apiVersion: networking.k8s.io/v1 kind: NetworkPolicy metadata: name: allow-logstash-and-grafana-to-elasticsearch namespace: monitoring spec: podSelector: matchLabels: app.kubernetes.io/name: elasticsearch policyTypes: - Ingress ingress: - from: - podSelector: matchLabels: app.kubernetes.io/name: logstash ports: - protocol: TCP port: 9200 - from: - podSelector: matchLabels: app.kubernetes.io/name: grafana ports: - protocol: TCP port: 9200