Skip to content

Commit

Permalink
Add support for CDI
Browse files Browse the repository at this point in the history
https://github.com/container-orchestrated-devices/container-device-interface

Add copyrights to all edited files
Switch to kustomize for deployment artifacts
Update Readme

Signed-off-by: amaslennikov <amaslennikov@nvidia.com>
  • Loading branch information
almaslennikov committed Sep 19, 2023
1 parent dd9e918 commit c19a164
Show file tree
Hide file tree
Showing 18 changed files with 703 additions and 98 deletions.
21 changes: 11 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,29 @@ available at mellanox/k8s-rdma-shared-dev-plugin.
Make sure to configure ib0 or appropriate IPoIB netdevice as the parent netdevice for creating overlay/virtual
netdevices.

**2.** Create ConfigMap
**2.** Create ConfigMap and deploy Device Plugin

Create config map to describe mode as "hca" mode. This is per node configuration.
Deploy device plugin and create config map to describe mode as "hca" mode. This is per node configuration.

```
kubectl create -f images/k8s-rdma-shared-dev-plugin-config-map.yaml
cd deployment/k8s/base
kubectl apply -k .
```

**3.** Deploy device plugin

```
kubectl create -f images/k8s-rdma-shared-dev-plugin-ds.yaml
```

**4.** Create Test pod
**3.** Create Test pod

Create test pod which requests 1 vhca resource.

```
kubectl create -f example/test-hca-pod.yaml
```

### Deploy the device plugin with CDI support
To use the device plugin with [CDI](https://github.com/cncf-tags/container-device-interface) support, do the following:
```
cd deployment/k8s/base/overlay
kubectl apply -k .
```
# How to use device plugin for RDMA

The device plugin can be used with macvlan for RDMA, to do the following steps:
Expand Down
27 changes: 26 additions & 1 deletion cmd/k8s-rdma-shared-dp/main.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
/*----------------------------------------------------
2023 NVIDIA CORPORATION & AFFILIATES
Licensed under the Apache License, Version 2.0 (the License);
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an AS IS BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
----------------------------------------------------*/

package main

import (
Expand Down Expand Up @@ -31,15 +49,22 @@ func main() {
flag.BoolVar(&versionOpt, "v", false, "Show application version")
flag.StringVar(
&configFilePath, "config-file", resources.DefaultConfigFilePath, "path to device plugin config file")
useCdi := false
flag.BoolVar(&useCdi, "use-cdi", false,
"Use Container Device Interface to expose devices in containers")
flag.Parse()
if versionOpt {
fmt.Printf("%s\n", printVersionString())
return
}

if useCdi {
log.Println("CDI enabled")
}

log.Println("Starting K8s RDMA Shared Device Plugin version=", version)

rm := resources.NewResourceManager(configFilePath)
rm := resources.NewResourceManager(configFilePath, useCdi)

log.Println("resource manager reading configs")
if err := rm.ReadConfig(); err != nil {
Expand Down
File renamed without changes.
File renamed without changes.
6 changes: 6 additions & 0 deletions deployment/k8s/base/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
- configmap.yaml
- daemonset.yaml
24 changes: 24 additions & 0 deletions deployment/k8s/overlay/cdi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: rdma-shared-dp-ds
namespace: kube-system
spec:
template:
spec:
containers:
- name: k8s-rdma-shared-dp-ds
volumeMounts:
- name: default-cdi
mountPath: /etc/cdi/
- name: dynamic-cdi
mountPath: /var/run/cdi
volumes:
- name: default-cdi
hostPath:
path: /etc/cdi
type: DirectoryOrCreate
- name: dynamic-cdi
hostPath:
path: /var/run/cdi
type: DirectoryOrCreate
8 changes: 8 additions & 0 deletions deployment/k8s/overlay/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
- ../base

patchesStrategicMerge:
- cdi.yaml
10 changes: 10 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ go 1.20

require (
github.com/Mellanox/rdmamap v1.1.0
github.com/container-orchestrated-devices/container-device-interface v0.5.4
github.com/jaypipes/ghw v0.6.1
github.com/jaypipes/pcidb v1.0.0
github.com/onsi/ginkgo v1.11.0
Expand All @@ -19,16 +20,24 @@ require (
require (
github.com/StackExchange/wmi v1.2.1 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/fsnotify/fsnotify v1.5.1 // indirect
github.com/ghodss/yaml v1.0.0 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/hpcloud/tail v1.0.0 // indirect
github.com/kr/pretty v0.2.1 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/opencontainers/runc v1.1.2 // indirect
github.com/opencontainers/runtime-spec v1.1.0 // indirect
github.com/opencontainers/runtime-tools v0.9.1-0.20221107090550-2e043c6bd626 // indirect
github.com/opencontainers/selinux v1.10.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/stretchr/objx v0.5.0 // indirect
github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635 // indirect
github.com/vishvananda/netns v0.0.4 // indirect
golang.org/x/mod v0.8.0 // indirect
golang.org/x/sys v0.10.0 // indirect
golang.org/x/text v0.11.0 // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
Expand All @@ -39,6 +48,7 @@ require (
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
howett.net/plist v1.0.0 // indirect
sigs.k8s.io/yaml v1.3.0 // indirect
)

replace (
Expand Down
Loading

0 comments on commit c19a164

Please sign in to comment.