forked from github/multus-cni
Fix sr-iov support
Fix thick plugin daemonset to add volume mapping required for sr-iov and fix code to update network status. In addition, fix checkpoint structures to support K8s without kubelet pod resources API. fix #665 and #778
This commit is contained in:
@@ -168,6 +168,10 @@ spec:
|
|||||||
mountPath: /host/run
|
mountPath: /host/run
|
||||||
- name: host-var-lib-cni-multus
|
- name: host-var-lib-cni-multus
|
||||||
mountPath: /var/lib/cni/multus
|
mountPath: /var/lib/cni/multus
|
||||||
|
- name: host-var-lib-kubelet
|
||||||
|
mountPath: /var/lib/kubelet
|
||||||
|
- name: host-run-k8s-cni-cncf-io
|
||||||
|
mountPath: /run/k8s.cni.cncf.io
|
||||||
- name: host-run-netns
|
- name: host-run-netns
|
||||||
mountPath: /run/netns
|
mountPath: /run/netns
|
||||||
mountPropagation: HostToContainer
|
mountPropagation: HostToContainer
|
||||||
@@ -217,6 +221,12 @@ spec:
|
|||||||
- name: host-var-lib-cni-multus
|
- name: host-var-lib-cni-multus
|
||||||
hostPath:
|
hostPath:
|
||||||
path: /var/lib/cni/multus
|
path: /var/lib/cni/multus
|
||||||
|
- name: host-var-lib-kubelet
|
||||||
|
hostPath:
|
||||||
|
path: /var/lib/kubelet
|
||||||
|
- name: host-run-k8s-cni-cncf-io
|
||||||
|
hostPath:
|
||||||
|
path: /run/k8s.cni.cncf.io
|
||||||
- name: host-run-netns
|
- name: host-run-netns
|
||||||
hostPath:
|
hostPath:
|
||||||
path: /run/netns/
|
path: /run/netns/
|
||||||
|
@@ -33,7 +33,7 @@ type PodDevicesEntry struct {
|
|||||||
PodUID string
|
PodUID string
|
||||||
ContainerName string
|
ContainerName string
|
||||||
ResourceName string
|
ResourceName string
|
||||||
DeviceIDs []string
|
DeviceIDs map[int64][]string
|
||||||
AllocResp []byte
|
AllocResp []byte
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -97,12 +97,14 @@ func (cp *checkpoint) GetPodResourceMap(pod *v1.Pod) (map[string]*types.Resource
|
|||||||
for _, pod := range cp.podEntires {
|
for _, pod := range cp.podEntires {
|
||||||
if pod.PodUID == podID {
|
if pod.PodUID == podID {
|
||||||
entry, ok := resourceMap[pod.ResourceName]
|
entry, ok := resourceMap[pod.ResourceName]
|
||||||
if ok {
|
if !ok {
|
||||||
// already exists; append to it
|
|
||||||
entry.DeviceIDs = append(entry.DeviceIDs, pod.DeviceIDs...)
|
|
||||||
} else {
|
|
||||||
// new entry
|
// new entry
|
||||||
resourceMap[pod.ResourceName] = &types.ResourceInfo{DeviceIDs: pod.DeviceIDs}
|
entry = &types.ResourceInfo{}
|
||||||
|
resourceMap[pod.ResourceName] = entry
|
||||||
|
}
|
||||||
|
for _, v := range pod.DeviceIDs {
|
||||||
|
// already exists; append to it
|
||||||
|
entry.DeviceIDs = append(entry.DeviceIDs, v...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -45,10 +45,11 @@ var _ = BeforeSuite(func() {
|
|||||||
"PodUID": "970a395d-bb3b-11e8-89df-408d5c537d23",
|
"PodUID": "970a395d-bb3b-11e8-89df-408d5c537d23",
|
||||||
"ContainerName": "appcntr1",
|
"ContainerName": "appcntr1",
|
||||||
"ResourceName": "intel.com/sriov_net_A",
|
"ResourceName": "intel.com/sriov_net_A",
|
||||||
"DeviceIDs": [
|
"DeviceIDs": {"-1": [
|
||||||
"0000:03:02.3",
|
"0000:03:02.3",
|
||||||
"0000:03:02.0"
|
"0000:03:02.0"
|
||||||
],
|
]
|
||||||
|
},
|
||||||
"AllocResp": "CikKC3NyaW92X25ldF9BEhogMDAwMDowMzowMi4zIDAwMDA6MDM6MDIuMA=="
|
"AllocResp": "CikKC3NyaW92X25ldF9BEhogMDAwMDowMzowMi4zIDAwMDA6MDM6MDIuMA=="
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@@ -143,10 +144,10 @@ var _ = Describe("Kubelet checkpoint data read operations", func() {
|
|||||||
"PodUID": "970a395d-bb3b-11e8-89df-408d5c537d23",
|
"PodUID": "970a395d-bb3b-11e8-89df-408d5c537d23",
|
||||||
"ContainerName": "appcntr1",
|
"ContainerName": "appcntr1",
|
||||||
"ResourceName": "intel.com/sriov_net_A",
|
"ResourceName": "intel.com/sriov_net_A",
|
||||||
"DeviceIDs": [
|
"DeviceIDs": { "-1": [
|
||||||
"0000:03:02.3",
|
"0000:03:02.3",
|
||||||
"0000:03:02.0"
|
"0000:03:02.0"
|
||||||
],
|
] },
|
||||||
"AllocResp": "CikKC3NyaW92X25ldF9BEhogMDAwMDowMzowMi4zIDAwMDA6MDM6MDIuMA=="
|
"AllocResp": "CikKC3NyaW92X25ldF9BEhogMDAwMDowMzowMi4zIDAwMDA6MDM6MDIuMA=="
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
@@ -708,7 +708,7 @@ func CmdAdd(args *skel.CmdArgs, exec invoke.Exec, kubeClient *k8s.ClientInfo) (c
|
|||||||
}
|
}
|
||||||
|
|
||||||
// create the network status, only in case Multus as kubeconfig
|
// create the network status, only in case Multus as kubeconfig
|
||||||
if n.Kubeconfig != "" && kc != nil {
|
if kubeClient != nil && kc != nil {
|
||||||
if !types.CheckSystemNamespaces(string(k8sArgs.K8S_POD_NAME), n.SystemNamespaces) {
|
if !types.CheckSystemNamespaces(string(k8sArgs.K8S_POD_NAME), n.SystemNamespaces) {
|
||||||
delegateNetStatus, err := nadutils.CreateNetworkStatus(tmpResult, delegate.Name, delegate.MasterPlugin, devinfo)
|
delegateNetStatus, err := nadutils.CreateNetworkStatus(tmpResult, delegate.Name, delegate.MasterPlugin, devinfo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -724,7 +724,7 @@ func CmdAdd(args *skel.CmdArgs, exec invoke.Exec, kubeClient *k8s.ClientInfo) (c
|
|||||||
}
|
}
|
||||||
|
|
||||||
// set the network status annotation in apiserver, only in case Multus as kubeconfig
|
// set the network status annotation in apiserver, only in case Multus as kubeconfig
|
||||||
if n.Kubeconfig != "" && kc != nil {
|
if kubeClient != nil && kc != nil {
|
||||||
if !types.CheckSystemNamespaces(string(k8sArgs.K8S_POD_NAME), n.SystemNamespaces) {
|
if !types.CheckSystemNamespaces(string(k8sArgs.K8S_POD_NAME), n.SystemNamespaces) {
|
||||||
err = k8s.SetNetworkStatus(kubeClient, k8sArgs, netStatus, n)
|
err = k8s.SetNetworkStatus(kubeClient, k8sArgs, netStatus, n)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -876,7 +876,7 @@ func CmdDel(args *skel.CmdArgs, exec invoke.Exec, kubeClient *k8s.ClientInfo) er
|
|||||||
}
|
}
|
||||||
|
|
||||||
// unset the network status annotation in apiserver, only in case Multus as kubeconfig
|
// unset the network status annotation in apiserver, only in case Multus as kubeconfig
|
||||||
if in.Kubeconfig != "" {
|
if kubeClient != nil {
|
||||||
if netnsfound {
|
if netnsfound {
|
||||||
if !types.CheckSystemNamespaces(string(k8sArgs.K8S_POD_NAMESPACE), in.SystemNamespaces) {
|
if !types.CheckSystemNamespaces(string(k8sArgs.K8S_POD_NAMESPACE), in.SystemNamespaces) {
|
||||||
err := k8s.SetNetworkStatus(kubeClient, k8sArgs, nil, in)
|
err := k8s.SetNetworkStatus(kubeClient, k8sArgs, nil, in)
|
||||||
|
Reference in New Issue
Block a user