Select devices into a fleet by using the CLI

Define a label selector to add devices into a fleet.

About this task

Note

Fleet selectors can only match against device labels. If you want to target devices based on hardware, operating systems, or custom agent attributes, you must first map those attributes to labels during enrollment by using label-from-systeminfo. For an example, see Example: fleet selection from system information.

Complete the following tasks:

Procedure

  1. 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,stage=development'
  2. If 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/v1beta1
    kind: Fleet
    metadata:
      name: my-fleet
    spec:
      selector:
        matchLabels:
          type: pos-terminal
          stage: development
    # ...
  3. Apply the change by running the following command:
    flightctl apply -f my-fleet.yaml
  4. Check that no devices in the fleet have overlapping selectors by running the following command:
    flightctl get devices -l 'type=pos-terminal,stage=development' -o json | jq -r '.items[].status.conditions[] | select(.type=="MultipleOwners").status'

    If the output shows False for each device, no other fleet selects the same devices. If any device shows True, review your fleet selectors to remove the overlap.

    Additional resources