Skip to content

Commit

Permalink
udn, cni: Report UDN iface info on network-status
Browse files Browse the repository at this point in the history
Before this commit, this was the network status we reported for a UDN
pod:
```
kubectl get pods pod
-ojsonpath="{@.metadata.annotations.k8s\.v1\.cni\.cncf\.io\/network-status}"
| jq
[
  {
    "name": "ovn-kubernetes",
    "interface": "eth0",
    "ips": [
      "10.244.1.9",
      "fd00:10:244:2::9"
    ],
    "mac": "0a:58:0a:f4:01:09",
    "default": true,
    "dns": {}
  }
]
```

With it, we now report:
```
[
 {
    "name": "ovn-kubernetes",
    "interface": "ovn-udn1",
    "ips": [
      "10.128.0.3"
    ],
    "mac": "0a:58:0a:80:00:03",
    "default": true,
    "dns": {}
  },
  {
    "name": "ovn-kubernetes",
    "interface": "eth0",
    "ips": [
      "10.244.1.6",
      "fd00:10:244:2::6"
    ],
    "mac": "0a:58:0a:f4:01:06",
    "default": false,
    "dns": {}
  }
 ]
```

This way, applications complying to the k8snetworkplumbingwg de-facto
standard can be aware of the UDN interface information.

We report the primary UDN first so the
network-attachment-definition-client can identify which of the 2
interfaces to report as primary [0].

[0]
k8snetworkplumbingwg/network-attachment-definition-client#71

Signed-off-by: Miguel Duarte Barroso <[email protected]>
Co-authored-by: Ram Lavi <[email protected]>
  • Loading branch information
2 people authored and zeeke committed Oct 22, 2024
1 parent df727a3 commit bab6b31
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion go-controller/pkg/cni/cni.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,23 @@ func (pr *PodRequest) cmdAddWithGetCNIResultFunc(kubeAuth *KubeAPIAuth, clientse
if err != nil {
return nil, err
}
if _, err := getCNIResultFn(primaryUDNPodRequest, clientset, primaryUDNPodInfo); err != nil {
primaryUDNResult, err := getCNIResultFn(primaryUDNPodRequest, clientset, primaryUDNPodInfo)
if err != nil {
return nil, err
}

response.Result.Routes = append(primaryUDNResult.Routes, response.Result.Routes...)
response.Result.Interfaces = append(primaryUDNResult.Interfaces, response.Result.Interfaces...)
response.Result.IPs = append(primaryUDNResult.IPs, response.Result.IPs...)

// Offset the index of the default network IPs to correctly point to the default network interfaces
numOfPrimaryIfaces := len(primaryUDNResult.Interfaces)
for i := len(primaryUDNResult.IPs); i < len(response.Result.IPs); i++ {
ifaceIPConfig := response.Result.IPs[i].Copy()
if response.Result.IPs[i].Interface != nil {
response.Result.IPs[i].Interface = current.Int(*ifaceIPConfig.Interface + numOfPrimaryIfaces)
}
}
}
} else {
response.PodIFInfo = podInterfaceInfo
Expand Down

0 comments on commit bab6b31

Please sign in to comment.