|
| 1 | +// To regenerate api.pb.go run hack/update-device-plugin.sh |
| 2 | +syntax = 'proto3'; |
| 3 | + |
| 4 | +package deviceplugin; |
| 5 | + |
| 6 | +import "github.com/gogo/protobuf/gogoproto/gogo.proto"; |
| 7 | + |
| 8 | +option (gogoproto.goproto_stringer_all) = false; |
| 9 | +option (gogoproto.stringer_all) = true; |
| 10 | +option (gogoproto.goproto_getters_all) = true; |
| 11 | +option (gogoproto.marshaler_all) = true; |
| 12 | +option (gogoproto.sizer_all) = true; |
| 13 | +option (gogoproto.unmarshaler_all) = true; |
| 14 | +option (gogoproto.goproto_unrecognized_all) = false; |
| 15 | + |
| 16 | + |
| 17 | +// Registration is the service advertised by the Kubelet |
| 18 | +// Only when Kubelet answers with a success code to a Register Request |
| 19 | +// may Device Plugins start their service |
| 20 | +// Registration may fail when device plugin version is not supported by |
| 21 | +// Kubelet or the registered resourceName is already taken by another |
| 22 | +// active device plugin. Device plugin is expected to terminate upon registration failure |
| 23 | +service Registration { |
| 24 | + rpc Register(RegisterRequest) returns (Empty) {} |
| 25 | +} |
| 26 | + |
| 27 | +message RegisterRequest { |
| 28 | + // Version of the API the Device Plugin was built against |
| 29 | + string version = 1; |
| 30 | + // Name of the unix socket the device plugin is listening on |
| 31 | + // PATH = path.Join(DevicePluginPath, endpoint) |
| 32 | + string endpoint = 2; |
| 33 | + // Schedulable resource name. As of now it's expected to be a DNS Label |
| 34 | + string resource_name = 3; |
| 35 | +} |
| 36 | + |
| 37 | +message Empty { |
| 38 | +} |
| 39 | + |
| 40 | +// DevicePlugin is the service advertised by Device Plugins |
| 41 | +service DevicePlugin { |
| 42 | + // ListAndWatch returns a stream of List of Devices |
| 43 | + // Whenever a Device state change or a Device disapears, ListAndWatch |
| 44 | + // returns the new list |
| 45 | + rpc ListAndWatch(Empty) returns (stream ListAndWatchResponse) {} |
| 46 | + |
| 47 | + // Allocate is called during container creation so that the Device |
| 48 | + // Plugin can run device specific operations and instruct Kubelet |
| 49 | + // of the steps to make the Device available in the container |
| 50 | + rpc Allocate(AllocateRequest) returns (AllocateResponse) {} |
| 51 | +} |
| 52 | + |
| 53 | +// ListAndWatch returns a stream of List of Devices |
| 54 | +// Whenever a Device state change or a Device disapears, ListAndWatch |
| 55 | +// returns the new list |
| 56 | +message ListAndWatchResponse { |
| 57 | + repeated Device devices = 1; |
| 58 | +} |
| 59 | + |
| 60 | +/* E.g: |
| 61 | +* struct Device { |
| 62 | +* ID: "GPU-fef8089b-4820-abfc-e83e-94318197576e", |
| 63 | +* State: "Healthy", |
| 64 | +*} */ |
| 65 | +message Device { |
| 66 | + // A unique ID assigned by the device plugin used |
| 67 | + // to identify devices during the communication |
| 68 | + // Max length of this field is 63 characters |
| 69 | + string ID = 1; |
| 70 | + // Health of the device, can be healthy or unhealthy, see constants.go |
| 71 | + string health = 2; |
| 72 | +} |
| 73 | + |
| 74 | +// - Allocate is expected to be called during pod creation since allocation |
| 75 | +// failures for any container would result in pod startup failure. |
| 76 | +// - Allocate allows kubelet to exposes additional artifacts in a pod's |
| 77 | +// environment as directed by the plugin. |
| 78 | +// - Allocate allows Device Plugin to run device specific operations on |
| 79 | +// the Devices requested |
| 80 | +message AllocateRequest { |
| 81 | + repeated string devicesIDs = 1; |
| 82 | +} |
| 83 | + |
| 84 | +// Failure Handling: |
| 85 | +// if Kubelet sends an allocation request for dev1 and dev2. |
| 86 | +// Allocation on dev1 succeeds but allocation on dev2 fails. |
| 87 | +// The Device plugin should send a ListAndWatch update and fail the |
| 88 | +// Allocation request |
| 89 | +message AllocateResponse { |
| 90 | + repeated DeviceRuntimeSpec spec = 1; |
| 91 | +} |
| 92 | + |
| 93 | +// The list to be added to the CRI spec |
| 94 | +message DeviceRuntimeSpec { |
| 95 | + // ID of the Device |
| 96 | + string ID = 1; |
| 97 | + // List of environment variable to set in the container. |
| 98 | + map<string, string> envs = 2; |
| 99 | + // Mounts for the container. |
| 100 | + repeated Mount mounts = 3; |
| 101 | + // Devices for the container |
| 102 | + repeated DeviceSpec devices = 4; |
| 103 | +} |
| 104 | + |
| 105 | +// Mount specifies a host volume to mount into a container. |
| 106 | +// where device library or tools are installed on host and container |
| 107 | +message Mount { |
| 108 | + // Path of the mount within the container. |
| 109 | + string container_path = 1; |
| 110 | + // Path of the mount on the host. |
| 111 | + string host_path = 2; |
| 112 | + // If set, the mount is read-only. |
| 113 | + bool read_only = 3; |
| 114 | +} |
| 115 | + |
| 116 | +// DeviceSpec specifies a host device to mount into a container. |
| 117 | +message DeviceSpec { |
| 118 | + // Path of the device within the container. |
| 119 | + string container_path = 1; |
| 120 | + // Path of the device on the host. |
| 121 | + string host_path = 2; |
| 122 | + // Cgroups permissions of the device, candidates are one or more of |
| 123 | + // * r - allows container to read from the specified device. |
| 124 | + // * w - allows container to write to the specified device. |
| 125 | + // * m - allows container to create device files that do not yet exist. |
| 126 | + string permissions = 3; |
| 127 | +} |
0 commit comments