Chapter 1. Managing device fleets
The Red Hat Edge Manager simplifies the management of a large number of devices and workloads through device fleets. A fleet is a resource that defines a group of devices governed by a common device template and management policies.
When you make a change to the device template, all devices in the fleet receive the changes when the Red Hat Edge Manager agent detects the new target specification.
Device monitoring in a fleet is also simplified because you can check the status summary of the whole fleet.
Fleet-level management offers the following advantages:
- Scales your operations because you perform operations only once for each fleet instead of once for each device.
- Minimizes the risk of configuration mistakes and configuration drift.
- Automatically applies the target configuration when you add devices to the fleet or replace devices in the fleet.
The fleet specification consists of the following features:
- Label selector
- Determines which devices are part of the fleet.
- Device template
- Defines the configuration that the Red Hat Edge Manager enforces on devices in the fleet.
- Policies
- Govern how devices are managed, for example, how changes to the device template are rolled out to the devices.
You can have both individually managed and fleet-managed devices at the same time. When a device is selected into a fleet, the Red Hat Edge Manager creates the device specification for the new device based on the device template. If you update the device template for a fleet or a new device joins the fleet, the Red Hat Edge Manager enforces the new specification in the fleet.
If a device is not selected into any fleets, the device is considered user-managed or unmanaged. For user-managed devices, you must update the device specification either manually or through an external automation.
Important: A device cannot be member of more than one fleet at the same time.
For more information, see Labels and label selectors.
1.1. Device selection into a fleet Copy linkLink copied to clipboard!
By default, devices are not assigned to a fleet. Instead, each fleet uses a selector that defines which labels a device must have to be added to the fleet.
To understand how to use labels in a fleet, see the following example:
The following list shows point-of-sales terminal devices and their labels:
| Device | Labels |
| A |
|
| B |
|
| C |
|
| D |
|
If all point-of-sales terminals uses the same configuration and are managed by the same operations team, you can define a single fleet called
pos-terminals
type=pos-terminal
However, you might want to create separate fleets for the different organizations for development or production. You can define a fleet for development with the
type=pos-terminal, stage=development
type=pos-terminal, stage=production
Important: You must define selectors in a way that two fleets do not select the same device. For example, if one fleet selects
region=east
stage=production
OverlappingSelectors
true
1.2. Device templates Copy linkLink copied to clipboard!
A device template of a fleet contains a device specification that is applied to all devices in the fleet when the template is updated.
For example, you can specify in the device template of a fleet that all devices in the fleet must run the
quay.io/flightctl/rhel:9.5
The Red Hat Edge Manager service then rolls out the target specification to all devices in the fleet and the Red Hat Edge Manager agents update each devices accordingly.
You can change other specification items in the device template and the Red Hat Edge Manager apply the changes in the same way.
However, sometimes not all of the devices in the fleet need to have the exact same specification. The Red Hat Edge Manager allows templates to contain placeholders that are populated based on the device name or label values.
The syntax of the placeholders matches that of Go templates. However, you can only use simple text and actions.
The use of conditionals or loops in the placeholders is not supported.
You can reference anything from the metadata of a device, such as
{{ .metadata.labels.key }}
{{ .metadata.name }}
You can also use the following functions in your placeholders:
-
The function changes the value to uppercase. For example, the function is
upper.{{ upper .metadata.name }} -
The function changes the value to lowercase. For example, the function is
lower.{{ lower .metadata.labels.key }} -
The function replaces all occurrences of a substring with another string. For example, the function is
replace.{{ replace "old" "new" .metadata.labels.key }} -
The function returns a default value if accessing a missing label. For example, he function is
getOrDefault.{{ getOrDefault .metadata.labels "key" "default" }}
You can combine the functions in pipelines, for example, a combined function is
{{ getOrDefault .metadata.labels "key" "default" | upper | replace " " "-" }}
Note: Ensure using proper Go template syntax. For example,
{{ .metadata.labels.target-revision }}
{{ index .metadata.labels "target-revision" }}
You can use the placeholders in device templates in the following ways:
-
You can label devices by deployment stage, for example, stage labels are and
stage: testing. Then, you can use the label with thestage: productionkey as placeholder when referencing the operating system image to use, for example, usestageor when referencing a configuration folder in a Git repository.quay.io/myorg/myimage:latest-{{ .metadata.labels.stage }} -
You can label devices by deployment site, for example, deployment sites are and
site: factory-berlin.site: factory-madrid -
Then, you can use the label with the key as parameter when referencing the secret with network access credentials in Kubernetes.
site
The following fields in device templates support placeholders:
| Field | Placeholders supported in |
| Operating System Image | repository name, image name, image tag |
| Git Config Provider | target revision, path |
| HTTP Config Provider | URL suffix, path |
| Inline Config Provider | content, path |
1.3. Selecting devices into a fleet by using the CLI Copy linkLink copied to clipboard!
Define label selector to add devices into a fleet.
Complete the following tasks:
Run the following command to verify that the label selector returns the devices that you want to add to the fleet:
flightctl get devices -l type=pos-terminal -l stage=developmentIf running the command returns the expected list of devices, you can define a fleet that selects the devices by using the following YAML file:
apiVersion: flightctl.io/v1alpha1 kind: Fleet metadata: name: my_fleet spec: selector: matchLabels: type: pos-terminal stage: development [...]Apply the change by running the following command:
flightctl apply -f my_fleet.yamlCheck for any overlaps with the selector of other fleets by running the following command:
flightctl get fleets/my_fleet -o json | jq -r '.status.conditions[] | select(.type=="OverlappingSelectors").status'See the following example output:
False