Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SR-IOV Device Plugin CDI support #473

Merged
merged 1 commit into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
13 changes: 13 additions & 0 deletions bindata/manifests/plugins/sriov-device-plugin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,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 @@ -69,6 +72,10 @@ spec:
readOnly: true
- name: device-info
mountPath: /var/run/k8s.cni.cncf.io/devinfo/dp
{{- if .UseCDI }}
- name: dynamic-cdi
mountPath: /var/run/cdi
{{- end }}
volumes:
- name: devicesock
hostPath:
Expand All @@ -83,3 +90,9 @@ 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
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -72,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 @@ -151,7 +151,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
}

Expand Down Expand Up @@ -360,7 +360,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 @@ -372,6 +372,7 @@ func (r *SriovNetworkNodePolicyReconciler) syncPluginDaemonObjs(ctx context.Cont
data.Data["ResourcePrefix"] = os.Getenv("RESOURCE_PREFIX")
data.Data["ImagePullSecrets"] = GetImagePullSecrets()
data.Data["NodeSelectorField"] = GetDefaultNodeSelector()
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 @@ -72,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
Loading