KpuCko

Calico Network Policy - ingress to app two ways

Sep 20th, 2025
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 1.47 KB | None | 0 0
  1. apiVersion: projectcalico.org/v3
  2. kind: NetworkPolicy
  3. metadata:
  4.   name: allow-nginx-ingress-to-glance
  5.   namespace: ma3x-glance
  6. spec:
  7.   selector: app == "glance"
  8.   types:
  9.    - Ingress
  10.     - Egress
  11.   ingress:
  12.     - action: Allow
  13.       protocol: TCP
  14.       source:
  15.         namespaceSelector: projectcalico.org/name == "ingress-nginx"
  16.         selector: app.kubernetes.io/component == "controller" && app.kubernetes.io/name == "ingress-nginx"
  17.       destination:
  18.         ports:
  19.          - 8080
  20.   egress:
  21.     - action: Allow
  22.       protocol: TCP
  23.       destination:
  24.         namespaceSelector: projectcalico.org/name == "ingress-nginx"
  25.         selector: app.kubernetes.io/component == "controller" && app.kubernetes.io/name == "ingress-nginx"
  26.         ports:
  27.          - 1024:65535
  28. ---
  29. apiVersion: projectcalico.org/v3
  30. kind: NetworkPolicy
  31. metadata:
  32.   name: allow-glance-to-nginx-ingress
  33.   namespace: ingress-nginx
  34. spec:
  35.   selector: app.kubernetes.io/component == "controller" && app.kubernetes.io/name == "ingress-nginx"
  36.   types:
  37.    - Ingress
  38.     - Egress
  39.   ingress:
  40.     - action: Allow
  41.       protocol: TCP
  42.       source:
  43.         namespaceSelector: projectcalico.org/name == "ma3x-glance"
  44.         selector: app == "glance"
  45.         ports:
  46.          - 1024:65535
  47.   egress:
  48.     - action: Allow
  49.       protocol: TCP
  50.       destination:
  51.         namespaceSelector: projectcalico.org/name == "ma3x-glance"
  52.         selector: app == "glance"
  53.         ports:
  54.          - 8080
  55.  
Tags: calico
Advertisement
Add Comment
Please, Sign In to add comment