nokia / danm

TelCo grade network management in a Kubernetes cluster
BSD 3-Clause "New" or "Revised" License
373 stars 81 forks source link

Default Networks don't have default routes #237

Closed electrocucaracha closed 4 years ago

electrocucaracha commented 4 years ago

Is this a BUG REPORT or FEATURE REQUEST?:

Uncomment only one, leave it on its own line:

bug feature

What happened: The default route is not adding the default network into the routing table

$ kubectl exec -ti test -- ip route
10.244.0.0/16 via 10.244.1.1 dev eth0 
10.244.1.0/24 dev eth0 scope link  src 10.244.1.5

What you expected to happen:

$ kubectl exec -ti test -- ip route
default via 10.244.1.1 dev eth0
10.244.0.0/16 via 10.244.1.1 dev eth0 
10.244.1.0/24 dev eth0 scope link  src 10.244.1.5

How to reproduce it: I've defined a Default Cluster Network using Flannel as CNI

cat <<EOF | kubectl apply -f -
apiVersion: danm.k8s.io/v1
kind: ClusterNetwork
metadata:
  name: default
spec:
  NetworkID: flannel
  NetworkType: flannel
EOF

Once DANM setup is completed, I've created a single Pod with no explicit connection.

cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: Pod 
metadata:
  name: test
spec:
  containers:
    - name: test
      image: alpine:3.11
      command: ["sleep"]
      args: ["infinity"]
EOF

Anything else we need to know?: This issue affects pods that are trying to connect to services outside of the Pod subnet(10.244.0.0/16), e. g. Kubernetes Services(10.96.0.0/12).

Environment:

Levovar commented 4 years ago

default route not being added is usually the sign of your Flannel config being wrong. please share

also please read https://github.com/nokia/danm/issues/135

electrocucaracha commented 4 years ago

This was the flannel configuration file:

{
  "name": "cbr0",
  "cniVersion": "0.3.1",
  "plugins": [
    {   
      "type": "flannel",
      "delegate": {
        "hairpinMode": true,
        "isDefaultGateway": true
      }   
    },  
    {   
      "type": "portmap",
      "capabilities": {
        "portMappings": true
      }   
    }   
  ]
}

So I changed to this one

{
  "name": "cbr0",
  "type": "flannel",
  "cniVersion": "0.3.1",
  "delegate": {
    "hairpinMode": true,
    "isDefaultGateway": true
  }
}

And the default routes are added

kubectl exec -ti test -- ip route
default via 10.244.1.1 dev eth0 
10.244.0.0/16 via 10.244.1.1 dev eth0 
10.244.1.0/24 dev eth0 scope link  src 10.244.1.9 

Thanks for the quick response on this.