Skip to content

WIP: sgx: add new special resources for TDX QGS and SGX platform registration #2103

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
32 changes: 32 additions & 0 deletions cmd/sgx_plugin/sgx_plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
dpapi "github.com/intel/intel-device-plugins-for-kubernetes/pkg/deviceplugin"
"k8s.io/klog/v2"
pluginapi "k8s.io/kubelet/pkg/apis/deviceplugin/v1beta1"
cdispec "tags.cncf.io/container-device-interface/specs-go"
)

const (
Expand Down Expand Up @@ -67,6 +68,24 @@
return nil
}

func createEFIMountsCDIDevice(name string) *cdispec.Spec {

Check failure on line 71 in cmd/sgx_plugin/sgx_plugin.go

View workflow job for this annotation

GitHub Actions / validate / lint

unnecessary leading newline (whitespace)

return &cdispec.Spec{
Version: dpapi.CDIVersion,
Kind: dpapi.CDIVendor + "/sgx",
Devices: []cdispec.Device{
{
Name: name,
ContainerEdits: cdispec.ContainerEdits{
Mounts: []*cdispec.Mount{
{HostPath: "efivarfs", ContainerPath: "/sys/firmware/efi/efivars", Type: "efivarfs", Options: []string{"rw", "nosuid", "nodev", "noexec", "relatime"}},
},
},
},
},
}
}

func (dp *devicePlugin) scan() (dpapi.DeviceTree, error) {
devTree := dpapi.NewDeviceTree()

Expand Down Expand Up @@ -96,6 +115,19 @@
devTree.AddDevice(deviceTypeProvision, devID, dpapi.NewDeviceInfoWithTopologyHints(pluginapi.Healthy, nodes, nil, nil, nil, nil, nil))
}

tdQeNodes := []pluginapi.DeviceSpec{
{HostPath: sgxEnclavePath, ContainerPath: sgxEnclavePath, Permissions: "rw"},
{HostPath: sgxProvisionPath, ContainerPath: sgxProvisionPath, Permissions: "rw"},
}

devTree.AddDevice("tdqe", "tdqe-1", dpapi.NewDeviceInfoWithTopologyHints(pluginapi.Healthy, tdQeNodes, nil, nil, nil, nil, nil))

regNodes := []pluginapi.DeviceSpec{
{HostPath: sgxEnclavePath, ContainerPath: sgxEnclavePath, Permissions: "rw"},
}

devTree.AddDevice("registration", "registration-1", dpapi.NewDeviceInfoWithTopologyHints(pluginapi.Healthy, regNodes, nil, nil, nil, nil, createEFIMountsCDIDevice("registration")))

return devTree, nil
}

Expand Down
6 changes: 6 additions & 0 deletions deployments/sgx_plugin/base/intel-sgx-plugin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ spec:
- name: sgx-provision
mountPath: /dev/sgx_provision
readOnly: true
- name: cdipath
mountPath: /var/run/cdi
volumes:
- name: kubeletsockets
hostPath:
Expand All @@ -61,5 +63,9 @@ spec:
hostPath:
path: /dev/sgx_provision
type: CharDevice
- name: cdipath
hostPath:
path: /var/run/cdi
type: DirectoryOrCreate
nodeSelector:
kubernetes.io/arch: amd64
Loading