I have been trying to experiment with the calico network rules and I'm finding it tough to get the ingress and the egress rules to work with order
in calico after denying all ingress and egress rules.
kubectl get pods --show-labels
NAME READY STATUS RESTARTS AGE LABELS
hello-web3 1/1 Running 0 45m app=foo
hello-web4 1/1 Running 0 45m app=bar
hello-web5 1/1 Running 0 15s app=foobar
hello-web6 1/1 Running 0 4s app=barbar
My network policy is as follows
---
apiVersion: projectcalico.org/v3
kind: NetworkPolicy
metadata:
name: ppdp-default
spec:
selector: all()
order: 2000
types:
- Ingress
- Egress
---
apiVersion: projectcalico.org/v3
kind: GlobalNetworkPolicy
metadata:
name: ppdp-egress-trusted
spec:
selector: app == 'foo'
order: 1000
types:
- Egress
egress:
- action: Allow
destination:
selector: app == 'bar'
---
apiVersion: projectcalico.org/v3
kind: GlobalNetworkPolicy
metadata:
name: ppdp-ingress-trusted
spec:
selector: app == 'foobar'
order: 100
types:
- Ingress
ingress:
- action: Allow
source:
selector: app == 'barbar'
Output for Ingress:
(base) ➜ ✗ kubectl exec --stdin --tty hello-web5 -- sh
/ # ^C
/ # wget -qO- --timeout=2 http://hello-web6:8080
^C
/ # wget -qO- --timeout=2 http://hello-web6:8080
wget: bad address 'hello-web6:8080'
/ # command terminated with exit code 1
---
(base) ➜ ✗ kubectl exec --stdin --tty hello-web6 -- sh
/ # wget -qO- --timeout=2 http://hello-web5:8080
wget: bad address 'hello-web5:8080'
/ # command terminated with exit code 1
Output for Egress
(base) ➜ ✗ kubectl exec --stdin --tty hello-web3 -- sh
/ # wget -qO- --timeout=2 http://hello-web4:8080
^C
/ # command terminated with exit code 130
Am I missing anything? Any help would be of great use.
Thanks in advance