Skip to content

Commit

Permalink
[Course Task] doc-device-crd (#286)
Browse files Browse the repository at this point in the history
Signed-off-by: xian-jie.shen [email protected]
Co-authored-by: Kevin Wang <[email protected]>
  • Loading branch information
jxs1211 and kevin-wangzefeng authored Jan 3, 2023
1 parent 75c2497 commit 8f12dae
Showing 1 changed file with 20 additions and 23 deletions.
43 changes: 20 additions & 23 deletions content/en/docs/developer/device_crd.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,13 @@ We currently manage devices from the cloud and synchronize the device updates be

## Notice
Device Management features are updated from v1alpha1 to v1alpha2 in release v1.4.
It is **not** compatible for v1alpha1 and v1alpha2.
It is **not** compatible with v1alpha1 and v1alpha2.
Details can be found [device-management-enhance](https://github.com/kubeedge/kubeedge/tree/master/docs/proposals/device-management-enhance.md)

## Device Model

A `device model` describes the device properties such as 'temperature' or 'pressure'. A device model is like a reusable template using which many devices can be created and managed.

Details on device model definition can be found [here](https://github.com/kubeedge/kubeedge/tree/master/docs/proposals/device-management-enhance.md#modifications-on-device-model-types).
Details on the device model definition can be found [here](https://github.com/kubeedge/kubeedge/tree/master/docs/proposals/device-management-enhance.md#modifications-on-device-model-types).

### Device Model Sample
A sample device model like below,
Expand Down Expand Up @@ -51,9 +50,8 @@ spec:
## Device Instance
A `device` instance represents an actual device object. It is like an instantiation of the `device model` and references properties defined in the model which exposed by property visitors to access. The device spec is static while the device status contains dynamically changing data like the desired state of a device property and the state reported by the device.

Details on device instance definition can be found [here](https://github.com/kubeedge/kubeedge/tree/master/docs/proposals/device-management-enhance.md#modifications-on-device-instance-types).
A `device` instance represents an actual device object. It is like an instantiation of the `device model` and references properties defined in the model which are exposed by property visitors to access. The device spec is static while the device status contains dynamically changing data like the desired state of a device property and the state reported by the device.
Details on the device instance definition can be found [here](https://github.com/kubeedge/kubeedge/tree/master/docs/proposals/device-management-enhance.md#modifications-on-device-instance-types).

### Device Instance Sample
A sample device instance like below,
Expand Down Expand Up @@ -148,8 +146,8 @@ From KubeEdge v1.4, we can support customized protocols and customized settings,
```

### Data Topic
From KubeEdge v1.4, we add data section defined in device spec.
Data section describe a list of time-series properties which will be reported by mappers to edge MQTT broker and should be processed in edge.
From KubeEdge v1.4, we add a data section defined in the device spec.
The data section describes a list of time-series properties that will be reported by mappers to the edge MQTT broker and should be processed in the edge.

```yaml
apiVersion: devices.kubeedge.io/v1alpha1
Expand Down Expand Up @@ -178,16 +176,15 @@ spec:

## Device Mapper

Mapper is an application that is used to connect and control devices. Following are the responsibilities of mapper:
Mapper is an application that is used to connect and control devices. The following are the responsibilities of the mapper:
1) Scan and connect to the device.
2) Report the actual state of twin-attributes of device.
3) Map the expected state of device-twin to actual state of device-twin.
4) Collect telemetry data from device.
5) Convert readings from device to format accepted by KubeEdge.
3) Map the expected state of device-twin to the actual state of device-twin.
4) Collect telemetry data from the device.
5) Convert readings from the device to a format accepted by KubeEdge.
6) Schedule actions on the device.
7) Check health of the device.

Mapper can be specific to a protocol where standards are defined i.e Bluetooth, Zigbee, etc or specific to a device if it a custom protocol.
Check the health of the device.
The mapper can be specific to a protocol where standards are defined i.e Bluetooth, Zigbee, etc or specific to a device if it is a custom protocol.

Mapper design details can be found [here](https://github.com/kubeedge/kubeedge/tree/master/docs/proposals/mapper-design.md#mapper-design)

Expand All @@ -205,22 +202,22 @@ The following are the steps to
```

2. Create a device instance in the cloud node.

```shell
kubectl apply -f <path to device instance yaml>
```

Note: The creation of a device instance will also lead to the creation of a config map which will contain information about the devices which are required by the mapper applications
The name of the config map will be as follows: device-profile-config-< edge node name >. The updates of the config map are handled internally by the device controller.

Note: Creation of device instance will also lead to the creation of a config map which will contain information about the devices which are required by the mapper applications
The name of the config map will be as follows: device-profile-config-< edge node name >. The updates of the config map is handled internally by the device controller.

3. Run the mapper application corresponding to your protocol.
1. Run the mapper application corresponding to your protocol.

4. Edit the status section of the device instance yaml created in step 2 and apply the yaml to change the state of device twin. This change will be reflected at the edge, through the device controller
2. Edit the status section of the device instance yaml created in step 2 and apply the yaml to change the state of device twin. This change will be reflected at the edge, through the device controller
and device twin modules. Based on the updated value of device twin at the edge the mapper will be able to perform its operation on the device.

5. The reported values of the device twin are updated by the mapper application at the edge and this data is synced back to the cloud by the device controller. User can view the update at the cloud by checking his device instance object.
1. The reported values of the device twin are updated by the mapper application at the edge and this data is synced back to the cloud by the device controller. Users can view the update on the cloud by checking their device instance object.

Note: Sample device model and device instance for a few protocols can be found at
Note: Sample device models and device instances for a few protocols can be found at
```shell
$GOPATH/src/github.com/kubeedge/kubeedge/build/crd-samples/devices
```

0 comments on commit 8f12dae

Please sign in to comment.