Skip to main content

Resource Selectors

Resource Selectors are used in multiple places including:

  • Attaching components to a topology
  • Creating relationships between configs and configs/components
  • Finding resources to run health checks or playbooks on
FieldDescriptionSchemeRequired
idID of the componentstringNo
nameName of the component/configstringNo
namespaceSelect resources in this namespace only, if empty find resources in all namespacesstringNo
typesMatch any of the types specified[]stringNo
statusesMatch any of the statuses specified[]stringNo
labelSelectorKubernetes Style Label SelectorLabelSelectorNo
fieldSelectorKubernetes Style Field Selector Property fields of the component in kubernetes format (or database columns: owner, topology_id, parent_id)FieldSelectorNo
agentSelect resources created on this agent, Defaults to localuuid, {name}, local or allNo
cacheCache settings to use for the results, expensive selectors or selectors that are are use very often should be cached for longer periods. Defaults to max-age=10mno-cache, no-store or max-age={duration}No
searchSearch for resources via key value pairs using parsing expression grammarstringNo

The query syntax is field1=value1 field2>value2 field3=value3* field4=*value4. * is for prefix and suffix matching.

Supported operators:

OperatorSyntaxTypes
=field=valuestring int json
!=field!=valuestring int json
*field=*value or field=value*string int
> <field>value or field<valuedatetime int

Supported fields for:

FieldType
namestring
sourcestring
namespacestring
typestring
statusstring
labelsjson
tagsjson
configjson
healthstring
agentstring
created_atdatetime
updated_atdatetime
deleted_atdatetime
FieldType
namestring
topology_idstring
namespacestring
typestring
statusstring
labelsjson
healthstring
agentstring
created_atdatetime
updated_atdatetime
deleted_atdatetime
FieldType
namestring
canary_idstring
namespacestring
typestring
statusstring
healthstring
labelsjson
agentstring
created_atdatetime
updated_atdatetime
deleted_atdatetime

Examples

Selecting Components in a Topology

topology-component-selectors.yaml
kind: Topology
metadata:
name: Example
spec:
components:
- name: Components with healthy status in kube-system namespace of all agents
selectors:
- statuses: ['healthy']
namespace: kube-system
agent: all

- name: Components with Node type with spot instance property labeled with gpu tag
selectors:
- types: ['Kubernetes::Node']
fieldSelector: 'instance-type=spot'
labelSelector: 'sku-type=gpu'

- name: Components with labels of team payments or team orders
# Using multiple selectors to aggregate
selectors:
- labelSelector: 'team=payments'
- labelSelector: 'team=orders'

- name: Kubernetes components which start with kafka created in last 24h
# Suffix and Prefix matches are supported using *
selectors:
- search: name=kafka* type=Kubernetes* created_at>now-24h

- name: All components updated between a specific interval
selectors:
- search: updated_at>2024-10-10 updated_at<2024-10-17

- name: Component with name httpbin-service
# Not giving any key will do a name lookup (ie name=httpbin-service)
selectors:
- search: httpbin-service

- name: Components with label cluster
# JSON lookups are also supported
selectors:
- search: labels.cluster=prod

- name: Link configs which have logistics-api image
configs:
- search: config.spec.template.spec.containers[0].name=docker.io/example/logistics-api:latest