|
| 1 | +# NetworkPolicies: default-deny then allow only the kagent controller |
| 2 | +# to reach agent pods. Agents cannot call each other directly — all A2A |
| 3 | +# traffic routes through the gateway (controller service on port 8083). |
| 4 | + |
| 5 | +# --- team-beta: deny all ingress, allow only from kagent controller --- |
| 6 | +apiVersion: networking.k8s.io/v1 |
| 7 | +kind: NetworkPolicy |
| 8 | +metadata: |
| 9 | + name: default-deny-ingress |
| 10 | + namespace: team-beta |
| 11 | +spec: |
| 12 | + podSelector: {} |
| 13 | + policyTypes: |
| 14 | + - Ingress |
| 15 | +--- |
| 16 | +apiVersion: networking.k8s.io/v1 |
| 17 | +kind: NetworkPolicy |
| 18 | +metadata: |
| 19 | + name: allow-kagent-controller |
| 20 | + namespace: team-beta |
| 21 | +spec: |
| 22 | + podSelector: |
| 23 | + matchLabels: |
| 24 | + app.kubernetes.io/name: specialist-agent |
| 25 | + policyTypes: |
| 26 | + - Ingress |
| 27 | + ingress: |
| 28 | + # Only the kagent controller pod may initiate connections to the specialist. |
| 29 | + # The controller lives in the kagent namespace and carries this label. |
| 30 | + - from: |
| 31 | + - namespaceSelector: |
| 32 | + matchLabels: |
| 33 | + kubernetes.io/metadata.name: kagent |
| 34 | + podSelector: |
| 35 | + matchLabels: |
| 36 | + app.kubernetes.io/name: kagent |
| 37 | + ports: |
| 38 | + - protocol: TCP |
| 39 | + port: 8080 # agent HTTP port (A2A endpoint) |
| 40 | + |
| 41 | +# --- team-alpha: deny all ingress, allow only from kagent controller --- |
| 42 | +apiVersion: networking.k8s.io/v1 |
| 43 | +kind: NetworkPolicy |
| 44 | +metadata: |
| 45 | + name: default-deny-ingress |
| 46 | + namespace: team-alpha |
| 47 | +spec: |
| 48 | + podSelector: {} |
| 49 | + policyTypes: |
| 50 | + - Ingress |
| 51 | +--- |
| 52 | +apiVersion: networking.k8s.io/v1 |
| 53 | +kind: NetworkPolicy |
| 54 | +metadata: |
| 55 | + name: allow-kagent-controller |
| 56 | + namespace: team-alpha |
| 57 | +spec: |
| 58 | + podSelector: |
| 59 | + matchLabels: |
| 60 | + app.kubernetes.io/name: orchestrator-agent |
| 61 | + policyTypes: |
| 62 | + - Ingress |
| 63 | + ingress: |
| 64 | + - from: |
| 65 | + - namespaceSelector: |
| 66 | + matchLabels: |
| 67 | + kubernetes.io/metadata.name: kagent |
| 68 | + podSelector: |
| 69 | + matchLabels: |
| 70 | + app.kubernetes.io/name: kagent |
| 71 | + ports: |
| 72 | + - protocol: TCP |
| 73 | + port: 8080 |
| 74 | + |
| 75 | +# --- Both namespaces: allow egress only to kagent controller + kube-dns --- |
| 76 | +apiVersion: networking.k8s.io/v1 |
| 77 | +kind: NetworkPolicy |
| 78 | +metadata: |
| 79 | + name: allow-egress-to-kagent |
| 80 | + namespace: team-alpha |
| 81 | +spec: |
| 82 | + podSelector: {} |
| 83 | + policyTypes: |
| 84 | + - Egress |
| 85 | + egress: |
| 86 | + - to: |
| 87 | + - namespaceSelector: |
| 88 | + matchLabels: |
| 89 | + kubernetes.io/metadata.name: kagent |
| 90 | + ports: |
| 91 | + - protocol: TCP |
| 92 | + port: 8083 # kagent A2A gateway port |
| 93 | + - to: |
| 94 | + - namespaceSelector: |
| 95 | + matchLabels: |
| 96 | + kubernetes.io/metadata.name: kube-system |
| 97 | + ports: |
| 98 | + - protocol: UDP |
| 99 | + port: 53 # kube-dns |
| 100 | + - protocol: TCP |
| 101 | + port: 53 |
| 102 | +--- |
| 103 | +apiVersion: networking.k8s.io/v1 |
| 104 | +kind: NetworkPolicy |
| 105 | +metadata: |
| 106 | + name: allow-egress-to-kagent |
| 107 | + namespace: team-beta |
| 108 | +spec: |
| 109 | + podSelector: {} |
| 110 | + policyTypes: |
| 111 | + - Egress |
| 112 | + egress: |
| 113 | + - to: |
| 114 | + - namespaceSelector: |
| 115 | + matchLabels: |
| 116 | + kubernetes.io/metadata.name: kagent |
| 117 | + ports: |
| 118 | + - protocol: TCP |
| 119 | + port: 8083 |
| 120 | + - to: |
| 121 | + - namespaceSelector: |
| 122 | + matchLabels: |
| 123 | + kubernetes.io/metadata.name: kube-system |
| 124 | + ports: |
| 125 | + - protocol: UDP |
| 126 | + port: 53 |
| 127 | + - protocol: TCP |
| 128 | + port: 53 |
0 commit comments