apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: ib-gateway
  namespace: foxhunt
spec:
  podSelector:
    matchLabels:
      app: ib-gateway
  policyTypes:
    - Ingress
    - Egress
  ingress:
    - from:
        - podSelector:
            matchLabels:
              app.kubernetes.io/name: trading-service
        - podSelector:
            matchLabels:
              app.kubernetes.io/name: broker-gateway
        - podSelector:
            matchLabels:
              app: multistrat-rebalancer
      ports:
        - protocol: TCP
          port: 4002
        - protocol: TCP
          port: 4004
  egress:
    # IBKR external servers
    - to:
        - ipBlock:
            cidr: 0.0.0.0/0
            except:
              - 10.0.0.0/8
              - 172.16.0.0/12
              - 192.168.0.0/16
      ports:
        - protocol: TCP
          port: 443
        - protocol: TCP
          port: 4000
        - protocol: TCP
          port: 4001
