I am trying to configure egress traffic using domains via Calico Cloud.
I am aware that DNS feature is possible with paid Calico Enterprise or Calico Cloud as mentioned here. I am using calico cloud trial. I am able to access Egress traffic using destination.nets, however when I am using destination.domains it block whole egress traffic.
My Env:
GKE cluster: 1.20.15-gke.3400
Calico version: Calico Cloud (Already connected cluster, Network Policy created via Calico Cloud UI)
Firewalls: Disabled
For tests I'm using default nginx pod with installed ping. I've tried to ping or curl. To make it easier, I've allowed any protocol.
Working config with nets:
apiVersion: projectcalico.org/v3
kind: GlobalNetworkPolicy
metadata:
name: default.allow-google
spec:
tier: default
order: 0
selector: app == "nginx"
namespaceSelector: ''
serviceAccountSelector: ''
egress:
- action: Allow
source: {}
destination:
nets:
- 142.250.185.132/32 ## ip of www.google.com
- 87.248.100.216/32 ## ip of www.yahoo.com
doNotTrack: false
applyOnForward: false
preDNAT: false
types:
- Egress
Issued policy using domains:
apiVersion: projectcalico.org/v3
kind: GlobalNetworkPolicy
metadata:
name: default.allow-google
spec:
tier: default
order: 0
selector: app == "nginx"
namespaceSelector: ''
serviceAccountSelector: ''
egress:
- action: Allow
source: {}
destination:
domains:
- '*.google.com'
- '*.yahoo.com'
- google.com
- yahoo.com
doNotTrack: false
applyOnForward: false
preDNAT: false
types:
- Egress
Questions:
- Am I missing some basic configuration? It's related with tiers (I was using default and security tier but result was the same)?
- Is there other option to allow egress policy based on DNS (open source/workarounds)?
Thanks in advance
I was lacking of
kube-dnsservice policy.When you connect your
GKEcluster toCalico Cloudyou don't have any policy. One you createnetsrule, it will work as it works only onIPs. However, when you want to useFQDN/DNSyou need to create policy to allow connectivity tokube-dnsservice. YAML would looks like below:More details can be found here.
For troubleshooting you can check if you see any output using
host($ host www.google.com) command fromdnsutils($ apt install dnsutils).After applying above YAML,
destination.domainspolicy working as expected.