Skip to content

Commit e21977d

Browse files
committed
sgx: add new special resources for TDX QGS and SGX platform registration
Signed-off-by: Mikko Ylinen <[email protected]>
1 parent d4d9b65 commit e21977d

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

cmd/sgx_plugin/sgx_plugin.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
dpapi "github.com/intel/intel-device-plugins-for-kubernetes/pkg/deviceplugin"
2626
"k8s.io/klog/v2"
2727
pluginapi "k8s.io/kubelet/pkg/apis/deviceplugin/v1beta1"
28+
cdispec "tags.cncf.io/container-device-interface/specs-go"
2829
)
2930

3031
const (
@@ -67,6 +68,24 @@ func (dp *devicePlugin) Scan(notifier dpapi.Notifier) error {
6768
return nil
6869
}
6970

71+
func createEFIMountsCDIDevice(name string) *cdispec.Spec {
72+
73+
return &cdispec.Spec{
74+
Version: dpapi.CDIVersion,
75+
Kind: dpapi.CDIVendor + "/sgx",
76+
Devices: []cdispec.Device{
77+
{
78+
Name: name,
79+
ContainerEdits: cdispec.ContainerEdits{
80+
Mounts: []*cdispec.Mount{
81+
{HostPath: "efivarfs", ContainerPath: "/sys/firmware/efi/efivars", Type: "efivarfs", Options: []string{"rw", "nosuid", "nodev", "noexec", "relatime"}},
82+
},
83+
},
84+
},
85+
},
86+
}
87+
}
88+
7089
func (dp *devicePlugin) scan() (dpapi.DeviceTree, error) {
7190
devTree := dpapi.NewDeviceTree()
7291

@@ -96,6 +115,19 @@ func (dp *devicePlugin) scan() (dpapi.DeviceTree, error) {
96115
devTree.AddDevice(deviceTypeProvision, devID, dpapi.NewDeviceInfoWithTopologyHints(pluginapi.Healthy, nodes, nil, nil, nil, nil, nil))
97116
}
98117

118+
tdQeNodes := []pluginapi.DeviceSpec{
119+
{HostPath: sgxEnclavePath, ContainerPath: sgxEnclavePath, Permissions: "rw"},
120+
{HostPath: sgxProvisionPath, ContainerPath: sgxProvisionPath, Permissions: "rw"},
121+
}
122+
123+
devTree.AddDevice("tdqe", "tdqe-1", dpapi.NewDeviceInfoWithTopologyHints(pluginapi.Healthy, tdQeNodes, nil, nil, nil, nil, nil))
124+
125+
regNodes := []pluginapi.DeviceSpec{
126+
{HostPath: sgxEnclavePath, ContainerPath: sgxEnclavePath, Permissions: "rw"},
127+
}
128+
129+
devTree.AddDevice("registration", "registration-1", dpapi.NewDeviceInfoWithTopologyHints(pluginapi.Healthy, regNodes, nil, nil, nil, nil, createEFIMountsCDIDevice("registration")))
130+
99131
return devTree, nil
100132
}
101133

deployments/sgx_plugin/base/intel-sgx-plugin.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ spec:
4949
- name: sgx-provision
5050
mountPath: /dev/sgx_provision
5151
readOnly: true
52+
- name: cdipath
53+
mountPath: /var/run/cdi
5254
volumes:
5355
- name: kubeletsockets
5456
hostPath:
@@ -61,5 +63,9 @@ spec:
6163
hostPath:
6264
path: /dev/sgx_provision
6365
type: CharDevice
66+
- name: cdipath
67+
hostPath:
68+
path: /var/run/cdi
69+
type: DirectoryOrCreate
6470
nodeSelector:
6571
kubernetes.io/arch: amd64

0 commit comments

Comments
 (0)