-
Notifications
You must be signed in to change notification settings - Fork 146
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
Enable mounting connectivity information for multiple devices/instances in a Pod #492
Comments
I'm interested in taking a crack at this! |
i'm not sure i have strong feelings. if there are no limits on envvar lengths, we might just add a normalized instance_name? might be easier to debug if there are issues (which env var traces to which instance, etc). |
@michaelzhang114 any updates or questions on this? Would be great to prioritize this for the next release. |
any opinions on naming the mounted env vars? I know @kate-goldenring suggested Without changing the flow, I'm thinking if it is easier to just name them as OPCUA: The broker can still do the equivalent of |
One option would be to create some assumption that all device specific environment variables that are prefixed with I realized that we don't need the suffix to be globally unique (like a hashed instance id); rather it just needs to be unique among the devices mounted into the broker. Because of this, we can have the discovery handlers suffix each of the If the Agent does the suffixing, rather than during allocate, it could also be done by the |
The annotation that Akri Agent set in ContainerAllocateResponse for each virtual device has the same problem. All virtual devices will set to the same annotation field "akri.agent.slot" |
Another proposal for device properties is to define some tags for DH to control whether to append a suffix and what the suffix is. We can append Suffix with the hash from usage slot id if no tag being specified and do differently if tag is specified. For example, device property DEBUG_ECHO_DESCRIPTION => DEBUG_ECHO_DESCRIPTION_ or DEBUG_ECHO_DESCRIPTION => DEBUG_ECHO_DESCRIPTION |
Is there any chance to have it as a part of incoming release? |
Background on how Akri adds connectivity information to brokers
The Akri Agent creates a device plugin for each device it discovers, creating a node level resource for that device. Then, a Pod can request that IoT device just as it would a compute resource (CPU and memory) in the
resourceRequests
section of the PodSpec. This is explained further in Akri's requesting Akri resources documentation. Akri's Controller does this on your behalf when abrokerSpec
is specified in aConfiguration
. It will deploy thatPod
orJob
, adding the discovered device as aresourceRequest
. Then, before the Pod is run on a node, the kubelet callsAllocate
on the device plugin in the Akri Agent to confirm that it can use that resource (device). In it's response, the device plugin can specify any environment variables or mounts that should be added to the container using that device. This is where Akri sets connectivity information (and adds devnode mounts forudev
). The environment variables are delineated in Akri's broker documentation.Problem
The issue is that there is one environment variable name for all of a protocol of devices. This has been fine in Akri's prevailing scenario of one device per broker; however, it causes missing connectivity information for the remaining N-1 devices requested.
For example, for ONVIF, the RTSP url for the camera is set under an environment variable named
ONVIF_DEVICE_SERVICE_URL
, so say a Pod has the followingresourceRequests
:When the broker Pod books up, only one (of the two camera's) RTSP URL is set in the environment variable
ONVIF_DEVICE_SERVICE_URL
. Instead, a list of urls should be specified or there should be N environment variables for N devices, each with an expected prefix, so the broker could do the equivalent ofprintenv | grep ONVIF_DEVICE_SERVICE_URL*
to know which devices it can connect to.Demo of the problem
The following demonstrates the problem using Akri's debugEcho Discovery Handler which "discovers" a set of devices declared in an Akri Configuration. The name of the discovered device is then mounted in the brokers. This walk through shows how only one device name is mounted when a Pod requests both discovered debugEcho resources.
kubectl get pods,akrii,akric
. Output would look similar to the following on a single node cluster:kubectl get akrii | tail -2 | awk '{print $1}'
. Substitute them into the following Pod'sresourceRequests
, prefixed byakri.sh/
:kubectl apply -f sample-broker.yaml
kubectl exec -it nginx-broker -- /bin/bash
DEBUG_ECHO_DESCRIPTION
environment variable that was added by the Agent device plugin and note that only one device namedevice1
is listed rather than both devices despite both being reserved by the Pod:root@nginx-broker:/# printenv | grep DEBUG_ECHO_DESCRIPTION DEBUG_ECHO_DESCRIPTION=device1
Potential solution
Instead of one environment varibale, there should be N environment variables for N devices, each with an expected prefix, so the broker could do the equivalent of
printenv | grep ONVIF_DEVICE_SERVICE_URL*
to know which devices it can connect to.This would be a breaking change, requiring sample brokers to be updated to do the new env var querying. It would require changes to the Discovery Handlers, where they would specify a unique label for each device here instead of the same one. I.E. the following:
could change to:
The text was updated successfully, but these errors were encountered: