# Recommended Network Policies for Linkerd

**URL:** <https://linkerd.buoyant.io/t/recommended-network-policies-for-linkerd/186>\
**Category:** Linkerd General Discussion\
**Created:** [July 19, 2023, 11:17pm UTC](https://linkerd.buoyant.io/t/recommended-network-policies-for-linkerd/186 "2023-07-19T23:17:19Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![kzap](https://avatars.discourse-cdn.com/v4/letter/k/91b2a8/32.png) [@kzap](https://linkerd.buoyant.io/u/kzap)\
**Post date:** [July 19, 2023, 11:17pm UTC](https://linkerd.buoyant.io/t/recommended-network-policies-for-linkerd/186/1 "2023-07-19T23:17:19Z")

</div>

Trying to find some guide on what network policies one should set to make sure meshed pods can talk to each other when we have network policies in our namespace

Our network policies is setup similar to this article: [Linkerd 2.x With Network Policy. In this post, we’re going to experiment… | by Ivan Sim | Medium](https://ihcsim.medium.com/linkerd-2-x-with-network-policy-2657103333ca)

We have policies such as this:

```yaml
spec:
  podSelector:
    matchExpressions:
      - key: linkerd.io/proxy-deployment
        operator: Exists
  policyTypes:
  - Egress
  egress:
  - to:
    - namespaceSelector: {}
      podSelector:
        matchExpressions:
        - key: linkerd.io/proxy-deployment
          operator: Exists

```

That allow communication from linkerd pods to other pods with linkerd

We do notice that some pods that do not use Deployments like Argo Rollouts have this label instead: `linkerd.io/proxy-replicaset`

Is there a recommended way to allow linkerd communication in a namespace that has locked down network policies?

---

<div class="post-metadata">

**Author:** ![Alex](https://yyz1.discourse-cdn.com/flex029/user_avatar/linkerd.buoyant.io/alex/32/63_2.png) [@Alex](https://linkerd.buoyant.io/u/Alex)\
**Post date:** [July 24, 2023, 11:27pm UTC](https://linkerd.buoyant.io/t/recommended-network-policies-for-linkerd/186/2 "2023-07-24T23:27:00Z")

</div>

Hi @kzap!

A more reliable label to look for would be the `linkerd.io/control-plane-ns` label since this should be present on all meshed pods, no matter what the kind of workload they belong to.

---

<div class="post-metadata">

**Author:** ![kzap](https://avatars.discourse-cdn.com/v4/letter/k/91b2a8/32.png) [@kzap](https://linkerd.buoyant.io/u/kzap)\
**Post date:** [July 25, 2023, 11:39am UTC](https://linkerd.buoyant.io/t/recommended-network-policies-for-linkerd/186/3 "2023-07-25T11:39:04Z")

</div>

Thanks, I did use that for now. Wondering more about if there’s a guide or article about which traffic we need to allow?

---

<div class="post-metadata">

**Author:** ![Alex](https://yyz1.discourse-cdn.com/flex029/user_avatar/linkerd.buoyant.io/alex/32/63_2.png) [@Alex](https://linkerd.buoyant.io/u/Alex)\
**Post date:** [July 26, 2023, 11:29pm UTC](https://linkerd.buoyant.io/t/recommended-network-policies-for-linkerd/186/4 "2023-07-26T23:29:29Z")

</div>

If I’m understanding your question correctly, the answer will depend on your application and environment. Linkerd proxies run as sidecar containers and they only communicate between each other when those pod communicate between each other. Therefore, you shouldn’t need to add any additional network policies specifically to facilitate Linkerd.

The exception to this is that all Linkerd proxies need to talk to the Linkerd control plane, which runs in the `linkerd` namespace.

---

<div class="post-metadata">

**Author:** ![kzap](https://avatars.discourse-cdn.com/v4/letter/k/91b2a8/32.png) [@kzap](https://linkerd.buoyant.io/u/kzap)\
**Post date:** [July 27, 2023, 1:07am UTC](https://linkerd.buoyant.io/t/recommended-network-policies-for-linkerd/186/5 "2023-07-27T01:07:25Z")

</div>

Thanks, so ideally I should need 1 network policy only for egress

```yaml
---
# This allows any Pod w/ Linkerd Proxy to communicate with pods in the Linkerd namespace
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: allow-linkerd-proxy-egress
spec:
  podSelector:
    matchLabels:
      linkerd.io/control-plane-ns: linkerd
  egress:
  - to:
    - namespaceSelector:
        matchLabels:
          kubernetes.io/metadata.name: linkerd

```

I dont need any ingress network policies to accept incoming traffic from pods in the Linkerd namespace?

---

<div class="post-metadata">

**Author:** ![Alex](https://yyz1.discourse-cdn.com/flex029/user_avatar/linkerd.buoyant.io/alex/32/63_2.png) [@Alex](https://linkerd.buoyant.io/u/Alex)\
**Post date:** [July 27, 2023, 5:45pm UTC](https://linkerd.buoyant.io/t/recommended-network-policies-for-linkerd/186/6 "2023-07-27T17:45:05Z")

</div>

Not as far as I’m aware.
