Introduction
A single edge node can be configured to run different sets of applications at different times, which is useful when applications must share exclusive access to a hardware peripheral (like a GPU) or when an edge node lacks the resources to run all desired applications simultaneously. This is achieved by grouping applications into profiles and using a Local Profile Server (LPS) application to switch between them.
This is not the same as the Application Profile feature, which helps you leverage built-in application orchestration functionality. See Automate Deployments with Application Profiles if you are interested in using API or Terraform to automate your deployments.
This article provides a conceptual example of a scenario where an edge node is equipped with a single GPU. It needs to perform two distinct tasks at different times:
- Day Profile: Run a video analytics application for security monitoring.
- Night Profile: Run a machine learning model training application.
Since both applications require exclusive access to the GPU, they cannot run at the same time. The LPS application provides a local control plane on the edge node to halt the "Day Profile" application and start the "Night Profile" application, without needing a connection to ZEDEDA Cloud.
Note: The code and commands shown in this article are part of a reference implementation and are for demonstration purposes only. A custom LPS application may use different mechanisms for control, such as a REST API instead of the file-based commands shown here.
This is a series of articles. You will likely follow them in this order.
- Manage App Instances with the Local Profile Server
- Local Profile Server for Graceful Shutdown with a UPS: A Use Case
- Local Profile Server for Managing App Profiles: A Use Case - You are here!
Prerequisites
- You must have at least the SysManager role in your ZEDEDA Cloud enterprise.
- You must have an edge node onboarded.
- Your edge node must be running EVE-OS version 12.0.1 or greater.
- You have Enabled SSH for your Edge Node.
- You must build your own application using the Offline Profile Server API doc.
- This article assumes that you have Linux knowledge.
Configure
Configuring an edge node for profile management involves setting up interfaces, creating a Network Instance, tagging the edge node and applications, and deploying the LPS application alongside the applications it will manage.
Set up an App Shared Interface
To manage application instances when the device is offline, you need at least one management interface and one app shared interface. After you onboard an edge node to ZEDEDA Cloud per the prerequisites:
- Go to Edge Nodes > YOUR_NODE.
- Click the Adapters tab and click the Pencil icon to edit.
- Under Network Adapters, configure Interface Usage:
- Configure at least one Management interface.
- Configure at least one App Shared interface.
- Click Save.
- Go to Edge Nodes > YOUR_NODE.
- Click the Basic Info tab and click the Pencil icon to edit.
- Configure three specific Tags on the edge node. The fixed keys are $ztag.local.profile.server.default, $ztag.local.profile.server.host, and $ztag.local.profile.server.token, while the values for the profile name and host are your choice:
-
Tag key: $ztag.local.profile.server.default
Tag value: day_profile
This tag key and value pair defines the default profile that needs to be brought up when the profile server is deployed, for example you would swap out day_profile with the name of your profile. Whichever profile name you use here must also appear in /mnt/profile.This will make sure that after the application instances are deployed, any application instances that are part of day_profile will be brought up by default, until you explicitly change the profile name. -
Tag Key: $ztag.local.profile.server.host
Tag Value: 10.5.20.254
This tag key and value pair has the IP of the profile server you’re deploying, for example where '10.5.20.254' is your profile server host. This is an IP from the IP range you will configure in the network instance subnet This is the IP you’re going to specify for the profile server application instance during its deployment. IP only, hostname not supported. -
Tag Key: $ztag.local.profile.server.token
Tag Value: YOUR_SECRET
This tag key and value pair defines the token that the LPS is required to use when sending commands to EVE-OS.
-
Tag key: $ztag.local.profile.server.default
- Click Save.
Create a Network Instance for the App Shared Network Interface
Create a network instance for the interface that you configured for the edge node:
- Go to Library > Network Instances > Add New.
- In the Details section:
- Select the Edge Node you configured during the onboarding prerequisites.
- Select the Kind as Local.
- Select the Port you configured as the App Shared interface in the edge node adapters page.
- In the IP Configuration section:
- Select Manual.
- Configure the Subnet, IP Address Range, and Gateway that contains the IP address of the profile server.
- Click Add.
Deploy the Offline Profile Server
Using the app you built in the prerequisites, deploy the app instance.
- Go to Edge App Instances > Add New.
- In the Edge App & Edge Nodes section, the Edge App is the app you built in the prerequisites, and the Edge Node is the one you onboarded in the prerequisites.
- In the Edge App Instance Identity section, there is nothing specific to Offline Profile Server. Configure it as you choose.
- In the Adapters & Networks section:
- Select the Network Instance you just created.
- Expand the Adapter.
- Expand the DHCP Custom.
- Enter the IP Address you provided in the profile server host tag, for example 10.5.20.254.
- In the Edge App Instance Identity section, there is nothing specific to Offline Profile Server in this example. Configure it as you choose.
- In the Review & Deploy section, click Deploy.
Manage Profiles
After the app is deployed, you can interact with the LPS application to manage the profiles. The method for this interaction depends on the LPS application's design. The following examples assume a reference LPS that is controlled by writing commands to files mounted into the container at /mnt.
Access the LPS Application
To issue commands, you first need to access the running LPS application instance. This can be done via SSH or another method supported by your application's container image.
Bash
..
# Example of SSHing into the LPS container
ssh lps-user@192.168.10.100
Switch Between Profiles
To switch from the active day_profile to the night_profile, you write the new profile name into the /mnt/profile file inside the LPS container.
Bash
..
# Inside the LPS container, command the switch to the night_profile
echo "night_profile" > /mnt/profile
After this change, the LPS will instruct EVE-OS to:
- Gracefully halt all applications tagged with day_profile.
- Start all applications tagged with night_profile.
Monitor Application Status
You can watch the state of the applications change in real-time by observing the status file that EVE-OS provides to the LPS.
Bash
..
# Watch the status file, which contains a JSON object with app states
watch -n 1 "cat /mnt/app-info-status.json | jq"
You will see the "Video-Analytics-App" state change to HALTED and the "ML-Training-App" state change to RUNNING.
Other Management Commands
This file-based LPS implementation supports other commands for managing the edge node and its applications.
-
Purge an Application: To completely remove a specific application instance ("app1" in this example) from the edge node:
Bash
..
echo "{\"displayname\": \"app1\", \"timestamp\": $(date +%s), \"command\": \"COMMAND_PURGE\"}" > /mnt/app-command.json
-
Shutdown All Applications: To gracefully halt all running applications on the edge node, regardless of their profile:
Bash
..
echo "{\"command\":\"COMMAND_SHUTDOWN\"}" > /mnt/dev-command.json
-
Power Off the Edge Node: To shut down all applications and then power off the edge node hardware:
Bash
..
echo "{\"command\":\"COMMAND_SHUTDOWN_POWEROFF\"}" > /mnt/dev-command.json