Skip to content

Commit

Permalink
Upgrade whereabouts CNI to v0.5.4 and align secondary network IPAM wi…
Browse files Browse the repository at this point in the history
…th additional pluginArgs.

 - Modify base Dockerfile to pull whereabouts-v0.5.4.
 - Update whereabouts clusterrole with additional API group resources.
 - Update whereabouts cmdArgs to provide PodName and PodNameSpace information.

Signed-off-by: root <arunkumar.velayutham@intel.com>
  • Loading branch information
arunvelayutham committed Jul 28, 2022
1 parent 2f9134b commit 7f4476e
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 8 deletions.
10 changes: 10 additions & 0 deletions build/charts/antrea/templates/whereabouts/clusterrole.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ rules:
- whereabouts.cni.cncf.io
resources:
- ippools
- overlappingrangeipreservations
verbs:
- get
- put
Expand All @@ -19,4 +20,13 @@ rules:
- patch
- create
- delete
- apiGroups:
- coordination.k8s.io
resources:
- leases
verbs:
- create
- get
- list
- update
{{- end }}
2 changes: 1 addition & 1 deletion build/images/base/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ ARG OVS_VERSION
FROM ubuntu:20.04 as cni-binaries

ARG CNI_BINARIES_VERSION
ARG WHEREABOUTS_VERSION=v0.5.1
ARG WHEREABOUTS_VERSION=v0.5.4

RUN apt-get update && \
apt-get install -y --no-install-recommends wget ca-certificates
Expand Down
2 changes: 1 addition & 1 deletion pkg/agent/cniserver/ipam/antrea_ipam.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (
)

const (
AntreaIPAMType = "antrea"
AntreaIPAMType = "antrea"
)

// Antrea IPAM driver would allocate IP addresses according to object IPAM annotation,
Expand Down
20 changes: 14 additions & 6 deletions pkg/agent/secondarynetwork/podwatch/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,11 @@ func removePodAllSecondaryNetwork(podCNIInfo *cnipodcache.CNIConfigInfo) error {
// Clean-up IPAM at whereabouts db (etcd or kubernetes API server) for all the secondary networks of the Pod which is getting removed.
// NOTE: SR-IOV VF interface clean-up, upon Pod delete will be handled by SR-IOV device plugin. Not handled here.
cmdArgs = &invoke.Args{Command: string("DEL"), ContainerID: podCNIInfo.ContainerID,
NetNS: podCNIInfo.ContainerNetNS, Path: cniPath}
NetNS: podCNIInfo.ContainerNetNS, Path: cniPath, PluginArgs: [][2]string{
{"K8S_POD_NAME", podCNIInfo.PodName},
{"K8S_POD_NAMESPACE", podCNIInfo.PodNameSpace},
{"K8S_POD_INFRA_CONTAINER_ID", podCNIInfo.ContainerID},
}}
// example: podCNIInfo.NetworkConfig = {"eth1": net1-cniconfig, "eth2": net2-cniconfig}
for secNetInstIface, secNetInstConfig := range podCNIInfo.NetworkConfig {
cmdArgs.IfName = secNetInstIface
Expand Down Expand Up @@ -190,7 +194,7 @@ func (pc *PodController) handleAddUpdatePod(obj interface{}) error {
// Avoid processing Pod annotation, if we already have at least one secondary network successfully configured on this Pod.
// We do not support/handle Annotation updates yet.
if len(podCNIInfo.NetworkConfig) > 0 {
klog.InfoS("Secondary network already configured on this Pod. Annotation update not supported.", klog.KObj(pod))
klog.InfoS("Secondary network already configured on this Pod. Annotation update not supported.", "Pod", klog.KObj(pod))
return nil
}
// Parse Pod annotation and proceed with the secondary network configuration.
Expand Down Expand Up @@ -295,7 +299,11 @@ func (pc *PodController) configureSecondaryInterface(pod *corev1.Pod, netinfo *S
if netinfo.InterfaceType == sriovInterfaceType {
cmdArgs = &invoke.Args{Command: string("ADD"), ContainerID: podCNIInfo.ContainerID,
NetNS: podCNIInfo.ContainerNetNS, IfName: netinfo.InterfaceName,
Path: cniPath}
Path: cniPath, PluginArgs: [][2]string{
{"K8S_POD_NAME", podCNIInfo.PodName},
{"K8S_POD_NAMESPACE", podCNIInfo.PodNameSpace},
{"K8S_POD_INFRA_CONTAINER_ID", podCNIInfo.ContainerID},
}}
ipamResult, err = ipam.GetIPAMSubnetAddress(cniconfig, cmdArgs)
if err != nil {
return errors.New("secondary network IPAM failed")
Expand Down Expand Up @@ -329,7 +337,7 @@ func (pc *PodController) configureSecondaryInterface(pod *corev1.Pod, netinfo *S
func (pc *PodController) configureSecondaryNetwork(pod *corev1.Pod, networklist []*SecondaryNetworkObject, podCNIInfo *cnipodcache.CNIConfigInfo) error {

for _, netinfo := range networklist {
klog.InfoS("Secondary Network Information:", netinfo)
klog.InfoS("Secondary Network Information:", "netInfo", netinfo)
if len(netinfo.NetworkName) > 0 {
netDefCRD, err := pc.netAttachDefClient.NetworkAttachmentDefinitions(pod.Namespace).Get(context.TODO(), netinfo.NetworkName, metav1.GetOptions{})
if err != nil {
Expand All @@ -353,10 +361,10 @@ func (pc *PodController) configureSecondaryNetwork(pod *corev1.Pod, networklist

func (pc *PodController) Run(stopCh <-chan struct{}) {
defer func() {
klog.InfoS("Shutting down", controllerName)
klog.InfoS("Shutting down", "controller", controllerName)
pc.queue.ShutDown()
}()
klog.InfoS("Starting ", controllerName)
klog.InfoS("Starting ", "controller", controllerName)
go pc.podInformer.Run(stopCh)
if !cache.WaitForNamedCacheSync(controllerName, stopCh, pc.podInformer.HasSynced) {
return
Expand Down

0 comments on commit 7f4476e

Please sign in to comment.