MachineInventorySelectorTemplate reference

The MachineInventorySelectorTemplate is a user defined resource that will be used as the blueprint to create the required MachineInventorySelectors.

It is the resource responsible of defining the matching criteria to pair an inventoried machine with a Cluster resource.

The relevant key is the selector which includes label selector expressions.

MachineInventorySelectorTemplate

  1. apiVersion: elemental.cattle.io/v1beta1
  2. kind: MachineInventorySelectorTemplate
  3. metadata:
  4. name: my-machine-selector
  5. namespace: fleet-default
  6. spec:
  7. template:
  8. spec:
  9. selector:
  10. ...

template.spec.selector can include matchLabels and or matchExpressions keys.

template.spec.selector.matchLabels

It is a map of {key,value} pairs (map[string]string). When multiple labels are provided all labels must match.

Example

  1. ...
  2. spec:
  3. template:
  4. spec:
  5. selector:
  6. matchLabels:
  7. element: fire
  8. manufacturer: somevalue

A Cluster defined with the above selector will only attempt to provision nodes inventoried including these two labels.

template.spec.selector.matchExpressions

It is a list of label selectors, each label selectors can be defined as:

KeyTypeDescription
keystringThis is the label key the selector applies on
operatorstringRepresents the relationship of the key to a set of values. Valid operators are ‘In’, ‘NotIn’, ‘Exists’ and ‘DoesNotExist’
values[]stringValues is an array of string values. If the operator is ‘In’ or ‘NotIn’, the values array must be non-empty. If the operator is ‘Exists’ or ‘DoesNotExist’, the values array must be empty

Example

  1. ...
  2. spec:
  3. template:
  4. spec:
  5. selector:
  6. matchExpressions:
  7. - key: element
  8. operator: In
  9. values: [ 'fire' ]
  10. - key: manufacturer
  11. operator: Exists

A Cluster defined with the above selector will only attempt to provision nodes inventoried with the element=fire label and including a manufacturer label defined with any value.