Skip to content

Commit

Permalink
Add SR-IOV Device Plugin CDI support
Browse files Browse the repository at this point in the history
  • Loading branch information
e0ne committed Oct 3, 2023
1 parent 37ddcd4 commit 16c0c80
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 6 deletions.
2 changes: 2 additions & 0 deletions api/v1/sriovoperatorconfig_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ type SriovOperatorConfigSpec struct {
// Default mode: daemon
// +kubebuilder:validation:Enum=daemon;systemd
ConfigurationMode ConfigurationModeType `json:"configurationMode,omitempty"`
// Flag to enable Container Device Interface mode for SR-IOV Network Device Plugin
UseCDI bool `json:"useCDI,omitempty"`
}

// SriovOperatorConfigStatus defines the observed state of SriovOperatorConfig
Expand Down
19 changes: 19 additions & 0 deletions bindata/manifests/plugins/sriov-device-plugin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ spec:
- --log-level=10
- --resource-prefix={{.ResourcePrefix}}
- --config-file=/etc/pcidp/$(NODE_NAME)
{{- if .UseCDI }}
- --use-cdi
{{- end }}
env:
- name: NODE_NAME
valueFrom:
Expand All @@ -65,6 +68,12 @@ spec:
readOnly: true
- name: device-info
mountPath: /var/run/k8s.cni.cncf.io/devinfo/dp
{{- if .UseCDI }}
- name: dynamic-cdi
mountPath: /var/run/cdi
- name: host-config-volume
mountPath: /host/etc/pcidp/
{{- end }}
volumes:
- name: devicesock
hostPath:
Expand All @@ -76,3 +85,13 @@ spec:
hostPath:
path: /var/run/k8s.cni.cncf.io/devinfo/dp
type: DirectoryOrCreate
{{ - if .UseCDI }}
- name: dynamic-cdi
hostPath:
path: /var/run/cdi
type: DirectoryOrCreate
- name: host-config-volume
hostPath:
path: /etc/pcidp
type: DirectoryOrCreate
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ spec:
description: NodeSelector selects the nodes to be configured
type: object
configurationMode:
description: Flag to enable the sriov-network-config-daemon to use
a systemd mode instead of the regular method
description: 'Flag to enable the sriov-network-config-daemon to use
a systemd service to configure SR-IOV devices on boot Default mode:
daemon'
enum:
- daemon
- systemd
Expand Down Expand Up @@ -71,6 +72,10 @@ spec:
maximum: 2
minimum: 0
type: integer
useCDI:
description: Flag to enable Container Device Interface mode for SR-IOV
Network Device Plugin
type: boolean
type: object
status:
description: SriovOperatorConfigStatus defines the observed state of SriovOperatorConfig
Expand Down
5 changes: 3 additions & 2 deletions controllers/sriovnetworknodepolicy_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func (r *SriovNetworkNodePolicyReconciler) Reconcile(ctx context.Context, req ct
return reconcile.Result{}, err
}
// Render and sync Daemon objects
if err = r.syncPluginDaemonObjs(ctx, defaultPolicy, policyList); err != nil {
if err = r.syncPluginDaemonObjs(ctx, defaultOpConf, defaultPolicy, policyList); err != nil {
return reconcile.Result{}, err
}
// Sync SriovNetworkNodeState objects
Expand Down Expand Up @@ -324,7 +324,7 @@ func (r *SriovNetworkNodePolicyReconciler) syncSriovNetworkNodeState(ctx context
return nil
}

func (r *SriovNetworkNodePolicyReconciler) syncPluginDaemonObjs(ctx context.Context, dp *sriovnetworkv1.SriovNetworkNodePolicy, pl *sriovnetworkv1.SriovNetworkNodePolicyList) error {
func (r *SriovNetworkNodePolicyReconciler) syncPluginDaemonObjs(ctx context.Context, operatorConfig *sriovnetworkv1.SriovOperatorConfig, dp *sriovnetworkv1.SriovNetworkNodePolicy, pl *sriovnetworkv1.SriovNetworkNodePolicyList) error {
logger := log.Log.WithName("syncPluginDaemonObjs")
logger.Info("Start to sync sriov daemons objects")

Expand All @@ -335,6 +335,7 @@ func (r *SriovNetworkNodePolicyReconciler) syncPluginDaemonObjs(ctx context.Cont
data.Data["ReleaseVersion"] = os.Getenv("RELEASEVERSION")
data.Data["ResourcePrefix"] = os.Getenv("RESOURCE_PREFIX")
data.Data["ImagePullSecrets"] = GetImagePullSecrets()
data.Data["UseCDI"] = operatorConfig.Spec.UseCDI

objs, err := renderDsForCR(constants.PluginPath, &data)
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ spec:
description: NodeSelector selects the nodes to be configured
type: object
configurationMode:
description: Flag to enable the sriov-network-config-daemon to use
a systemd mode instead of the regular method
description: 'Flag to enable the sriov-network-config-daemon to use
a systemd service to configure SR-IOV devices on boot Default mode:
daemon'
enum:
- daemon
- systemd
Expand Down Expand Up @@ -71,6 +72,10 @@ spec:
maximum: 2
minimum: 0
type: integer
useCDI:
description: Flag to enable Container Device Interface mode for SR-IOV
Network Device Plugin
type: boolean
type: object
status:
description: SriovOperatorConfigStatus defines the observed state of SriovOperatorConfig
Expand Down

0 comments on commit 16c0c80

Please sign in to comment.