{{- if .Values.networkPolicy.enabled -}} apiVersion: networking.k8s.io/v1 kind: NetworkPolicy metadata: name: {{ include "agent-monitor.fullname" . }} labels: {{- include "agent-monitor.labels" . | nindent 4 }} spec: podSelector: matchLabels: {{- include "agent-monitor.selectorLabels" . | nindent 6 }} policyTypes: - Ingress - Egress ingress: # Allow HTTP traffic to the application port from any pod (ingress controllers, etc.) - ports: - port: {{ .Values.service.targetPort }} protocol: TCP {{- if .Values.mcp.enabled }} # Allow MCP traffic when sidecar is enabled - ports: - port: {{ .Values.mcp.port }} protocol: TCP {{- end }} {{- with .Values.networkPolicy.additionalIngressRules }} {{- toYaml . | nindent 4 }} {{- end }} egress: # Allow DNS resolution - ports: - port: 53 protocol: UDP - port: 53 protocol: TCP # Allow outbound HTTPS (for external API calls) - ports: - port: 443 protocol: TCP # Allow internal communication within the cluster - to: - podSelector: {} {{- with .Values.networkPolicy.additionalEgressRules }} {{- toYaml . | nindent 4 }} {{- end }} {{- end }}