Skip to content

Commit

Permalink
Merge pull request #157 from flanksource/resource-selector
Browse files Browse the repository at this point in the history
chore: update resource selector documentation
  • Loading branch information
moshloop authored Feb 16, 2024
2 parents d63ba02 + 569da5b commit ec2346d
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 22 deletions.
44 changes: 44 additions & 0 deletions canary-checker/docs/reference/resource_selector.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# ResourceSelector

We use resource selectors to link components with each other

| Field | Description | Scheme | Required |
|---------------|----------------------------------------------------------------------------------------------------------------------------------------|----------|----------|
| id | ID of the component | string | |
| name | Name of the component | string | |
| namespace | Namespace of the component | string | |
| types | List of types of the component | []string | |
| statuses | List of statuses of the component | []string | |
| labelSelector | Labels to select the component in kubernetes format | string | |
| fieldSelector | Property fields of the component in kubernetes format (or database columns: owner, topology_id, parent_id) | string | |
| agent | ID or name of the agent (Default: local agent). Use 'all' to select all the agents | string | |
| cache | One of 'no-cache' (should not fetch from cache but can be cached), 'no-store' (should not cache) or 'max-age=X' (cache for X duration) | string | |


A resource selector fetches components that satisfy all the parameters, you can use multiple selectors to aggregate

## Example
```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 labelled with gpu tag
selectors:
- types: ['Kubernetes::Node']
fieldSelector: 'instance-type=spot'
labelSelector: 'sku-type=gpu'

- name: Components with labels of team payments and team orders
# Using multiple selectors to aggregate
selectors:
- labelSelector: 'team=payments'
- labelSelector: 'team=orders'
```
1 change: 1 addition & 0 deletions mission-control/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ sync:
cp docs/canary-checker/concepts/secret-management.md docs/reference/
cp docs/canary-checker/reference/connection.md docs/reference/
cp docs/canary-checker/concepts/connections.md docs/reference/
cp docs/canary-checker/reference/resource_selector.md docs/reference/
cp -r ../canary-checker/src/components src/
cp -r ../canary-checker/src/theme src/
cp -r ../canary-checker/src/css src/
Expand Down
9 changes: 0 additions & 9 deletions mission-control/docs/topology/concepts/linking-components.md

This file was deleted.

9 changes: 1 addition & 8 deletions mission-control/docs/topology/references/components.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Components are the building blocks of a Topology. The component specification pr
| `lookup` | Lookup component definitions from an external source, use the `forEach` property to iterate over the results to further enrich each component. | [`Lookup`](lookup#lookup) | |
| `properties` | Customize component properties as to be visualized on Mission control UI | [`[]Property`](./property#property) | |
| `relationships` | Specify relationship of component | [`[]RelationshipSpec`](#relationshipspec) | |
| `selectors` | Specify component for topology based on `fieldSelector` and `labelSelector` | [`[]ResourceSelector`](#resourceselector) | |
| `selectors` | Specify component for topology based on `fieldSelector` and `labelSelector` | [`[]ResourceSelector`](/reference/resource_selector) | |
| `forEach` | Only applies when using lookup. When specified, the components and properties specified under ForEach will be templated using the components returned by the lookup. | [`ForEach`](#foreach) | `optional` |

### ID
Expand All @@ -39,13 +39,6 @@ Components are the building blocks of a Topology. The component specification pr
| `ref` | Set reference for components relationship | `string` | |
| `type` | Set the type of relationship, e.g. dependsOn, subcomponentOf, providesApis, consumesApis | `string` | |

### ResourceSelector

| Field | Description | Scheme | Required |
| --------------- | --------------------------------------------------------------------------------- | -------- | -------- |
| `name` | Set name for selector | `string` | |
| `fieldSelector` | Select Kubernetes or Canary object based on the value of specified resource field | `string` | |
| `labelSelector` | Select Kubernetes or Canary object based on label. e.g. app, canary. | `string` | |

### ForEach

Expand Down
10 changes: 5 additions & 5 deletions mission-control/sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -660,11 +660,6 @@ const sidebars = {
id: 'topology/concepts/topology',
label: 'Topology',
},
{
type: 'doc',
id: 'topology/concepts/linking-components',
label: 'Components',
},
{
type: 'doc',
id: 'topology/concepts/properties',
Expand Down Expand Up @@ -926,6 +921,11 @@ const sidebars = {
},
],
},
{
type: 'doc',
id: 'reference/resource_selector',
label: 'Resource Selector',
},
],
overview: [
{
Expand Down

0 comments on commit ec2346d

Please sign in to comment.