0

I need to create a network policy which accept the traffic (ingress + egress) between all pods inside the same namespace on a specific port ONLY (for example on port 9200).

I labeled my namespace called calico using kubectl label ns calico type=clico

I tried the below policy but after creating it, I created a pod to test telnet on port 9200 and it is not allowed.

apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: test-network-policy
  namespace: calico
spec:
  podSelector: {}
  policyTypes:
  - Ingress
  - Egress
  ingress:
  - from:
    - namespaceSelector:
        matchLabels:
          type: calico
    - podSelector: {}
    ports:
    - protocol: TCP
      port: 9200
  egress:
  - to:
    - namespaceSelector:
        matchLabels:
          type: calico
    - podSelector: {}
    ports:
    - protocol: TCP
      port: 9200
Y.jab
  • 9
  • 2

1 Answers1

0

Looks like a typo in namespace label: type=clico and policy definition: matchLabels: type: calico