Jaejung Lee
Jaejung Lee

Reputation: 1

how can restrict traffic between nodes in kubernetes?

I want to block traffic between nodes in kubernetes.

This is because i don't want to have any effect on the traffic coming from the specfic pod.

how can do this?

Upvotes: 0

Views: 207

Answers (1)

SAIJAL
SAIJAL

Reputation: 172

You can use network policies for this. The following example of a network policy blocks all in-cluster traffic to a set of web server pods, except the pods allowed by the policy configuration.

To achieve this setup, create a NetworkPolicy with the following manifest:

kind: NetworkPolicy
apiVersion: networking.k8s.io/v1
metadata:
  name: access-nginx
spec:
  podSelector:
    matchLabels:
      app: nginx
  ingress:
  - from:
    - podSelector:
        matchLabels:
          app: foo

Once you apply this configuration, only pods with label

app: foo

can talk to the pods with the label

app: nginx.

Upvotes: 1

Related Questions