Kubernetes Device Plugin
The Kubernetes manages hardware devices through the Device-plugin.
The Kubernetes manages hardware devices through the Device-plugin. Figure 5-3 shows the logical view of the Kubernetes.
The Device-plugin mechanism implements the gRPC registration service in kubelet and opens standard RPC interfaces, allowing vendors to implement their own Device-plugins. Device-plugin allocates devices and reports information.
Atlas provides users with Kubernetes device plugins and implements corresponding interfaces.
- ListAndWatch: When kubelet is started, this interface is called through RPC. This interface returns basic device information on the node, including the device quantity, model, and basic specifications. The kubelet reports information to Kubernetes Master for resource scheduling.
- Allocate: When the kubelet starts the container service, it calls the Device-plugin interface through RPC. This interface returns the list of available physical device IDs of the current node in the form of the ASCEND_VISBLE_DEVICES environment variable.
Vendors only need to implement a Docker image and a YAML configuration file based on the DaemonSet service to integrate devices into the Kubernetes system. Figure 5-4 shows the design architecture of device plug-ins.
Kubernetes Device Plugin Deployment Mode
The Device-plugin is deployed on the Kubernetes node and runs as an independent daemon process.
To ensure the high availability of the Device-Plugin, the device plugin needs to be automatically started when the node is restarted, the plugin exits unexpectedly, or the plugin process exits due to other reasons.
Kubernetes provides the DaemonSet service, which is suitable for long-term running of Device-plugin on nodes. If a fault occurs, the process can be automatically started.
To enable the Device-plugin to run in DaemonSet mode, you need to deploy the following components:
- Device plugin image: Package the executable binary files of the device plugin into a Docker image and use the binary files as the startup commands of the container.
- Kubernetes YAML configuration file
After the DaemonSet is deployed, a container is started on each Atlas server node in the Kubernetes cluster. The binary file of the device plugin running in the container functions as the Daemon process. When the daemon process exits unexpectedly, the Kubernetes automatically starts the container so that the daemon process can be automatically started.