Skip to content

Instantly share code, notes, and snippets.

@daemonfire300
Created February 10, 2025 16:09
Show Gist options
  • Save daemonfire300/6c1204297f3c43903541cf6fb6fbbb78 to your computer and use it in GitHub Desktop.
Save daemonfire300/6c1204297f3c43903541cf6fb6fbbb78 to your computer and use it in GitHub Desktop.
same-ns-calico-pol.yaml
apiVersion: projectcalico.org/v3
kind: NetworkPolicy
metadata:
name: allow-same-namespace-communication
namespace: my-namespace
spec:
selector: app == 'myapp' # Applies to pods with the label `app=myapp`
types:
- Ingress
- Egress
ingress:
- action: Allow
source:
selector: app == 'myapp' # Allow traffic from pods with the label `app=myapp`
namespaceSelector: projectcalico.org/name == 'my-namespace' # Restrict to the same namespace
egress:
- action: Allow
destination:
selector: app == 'myapp' # Allow traffic to pods with the label `app=myapp`
namespaceSelector: projectcalico.org/name == 'my-namespace' # Restrict to the same namespace
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment