-
Notifications
You must be signed in to change notification settings - Fork 12
Description
Hey @the-smooth-operator and @ziegeer,
apiVersion: projectcalico.org/v3
kind: NetworkPolicy
metadata:
name: deny-most
namespace: prod
spec:
selector: role != 'proxy'
types:
- Ingress
- Egress
ingress:
- action: Allow
source:
namespaceSelector: name == 'prod'
- action: Deny
source:
namespaceSelector: name != 'prod'
egress:
- action: Allow
This policy should provide namespace network isolation. Sorry that got lost in the transition. Maybe it'll save you a little time. The policy can only be applied with calicoctl
I believe. In order to do that, I had to run calicoctl as a pod in the cluster itself which is documented here:
https://docs.projectcalico.org/v3.5/usage/calicoctl/install#installing-calicoctl-as-a-kubernetes-pod
I think that the current cluster has Calico available in policy only mode but I'm not sure I fully understood the state of Calico in the cluster.
Cheers!
Daniel
Update: I forgot. You'll want to read the docs on Calico policies. You can do some pretty neat stuff including using the namespaceSelector
and selector
for this. I can't remember exactly what I was doing here but you'll just need to make sure that the namespace and pod labels match whatever you have in the policy here. May take a bit of experimenting but it shouldn't be too bad to get it all working.