Skip to content

Commit

Permalink
update topology documentation (#185)
Browse files Browse the repository at this point in the history
* chore: add title to yaml blocks and remove checks related fields from
component lookup

* chore: update topology catalog

* chore: fix browser titles

* chore: fix links

* fix: for each documentation

* chore: add descriptions to the examples

* docs: update forEach

* doc: config db lookup

* exec lookup

* kubernetes lookup

* component lookup

* fix: postgres component lookup and disable redis lookup

* mysql and mssql

* prometheus lookup and hide mongo

* chore: highlight lookups

* modify exec lookup example

* chore: add result variable to all lookups
  • Loading branch information
adityathebe authored Mar 12, 2024
1 parent 1fe0da9 commit e0e8e48
Show file tree
Hide file tree
Showing 25 changed files with 695 additions and 539 deletions.
16 changes: 0 additions & 16 deletions .vscode/settings.json

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,23 +1,31 @@
# Config
# Catalog

Configs can be associated to a component using the `config` property. A linked config shows up in the component page in the right hand side panel.
You can link components with configs. The linked config items appears in the component page in the right hand side panel.

![Component Config relationship](../images/component-config-relationship.jpg)
To establish this relationship, you need to specify which config items to link with using the `config` field.

```yaml title="topology.yaml"
![Component Config relationship](../images/component-config-relationship.png)

```yaml title="kubernetes-cluster.yaml"
apiVersion: canaries.flanksource.com/v1
kind: Topology
metadata:
name: test-topology-property-merge
name: kubernetes-cluster
spec:
schedule: '@every 10m'
components:
- configs:
- name: flanksource-canary-cluster
type: EKS
- icon: pods
lookup:
kubernetes:
- display:
javascript: JSON.stringify(k8s.getPodTopology(results))
kind: Pod
name: k8s-pods
configs:
- type: Kubernetes::Pod
```
## Config
## Config Selector
| Field | Description | Scheme | Required |
| ------------- | ----------------------------------------- | ------------------- | -------- |
Expand Down
99 changes: 0 additions & 99 deletions mission-control/docs/topology/concepts/for-each.md

This file was deleted.

8 changes: 4 additions & 4 deletions mission-control/docs/topology/concepts/health-checks.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ Health checks can be associated in 2 ways:

## Check

| Field | Description | Scheme | Required |
| ---------- | -------------------------------- | ------------------------------------------------------------- | -------- |
| `inline` | Define a new health check inline | [`CanarySpec`](../../canary-checker/reference/canary-spec.md) | |
| `selector` | Select an existing health check | [`[]ResourceSelector`](../../reference/resource_selector) | |
| Field | Description | Scheme | Required |
| ---------- | -------------------------------- | -------------------------------------------------------------- | -------- |
| `inline` | Define a new health check inline | [`CanarySpec`](../../canary-checker/reference/canary-spec.mdx) | |
| `selector` | Select an existing health check | [`[]ResourceSelector`](../../reference/resource_selector) | |

### Selector

Expand Down
106 changes: 106 additions & 0 deletions mission-control/docs/topology/concepts/lookup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
# Component lookup

Lookup enables you to form components from an external source eg: an HTTP endpoint, kubernetes clusters or a database.
The response from the external sources are then "shaped" to a component using the `display` field.
The `display` field contains several scripting mechanism to transform any arbitrary data to a [component](../references/components.md).

```yaml title="kubernetes-ingress-classes.yaml"
apiVersion: canaries.flanksource.com/v1
kind: Topology
metadata:
name: kubernetes-ingress-classes
namespace: default
spec:
schedule: '@every 30s'
components:
- name: Ingress
type: Ingress
icon: server
// highlight-start
lookup:
configDB:
- query: SELECT name FROM config_items WHERE type = 'Kubernetes::IngressClass'
expr: |
dyn(results).map(e, {
'name': e.name,
'type': "Ingress",
}).toJSON()
// highlight-end
```

This topology will create a root **"Ingress"** component with all the ingresses in a kubernetes cluster as its child components.

| Field | Description | Type | Required |
| ------------ | -------------------------------------------- | --------------------------------------------- | -------- |
| `configDB` | Lookup catalogs in configDB. | [`[]ConfigDB`](../references/configdb.md) | |
| `exec` | Lookup by running (bash/powershell) scripts. | [`[]Exec`](../references/exec.md) | |
| `kubernetes` | Lookup kubernetes resources | [`[]Kubernetes`](../references/kubernetes.md) | |
| `http` | Lookup an HTTP endpoint. | [`[]HTTP`](../references/http.md) | |
| `mongodb` | Query records from a MongoDB database. | [`[]MongoDB`](../references/mongo.md) | |
| `mssql` | Query records from a MSSQL database. | [`[]Mssql`](../references/mssql.md) | |
| `mysql` | Query records from a MySQL database. | [`[]Mysql`](../references/mysql.md) | |
| `postgres` | Query records from a Postgres database. | [`[]Postgres`](../references/postgres.md) | |
| `redis` | Query records from a Redis server. | [`[]Redis`](../references/redis.md) | |
| `prometheus` | Query metrics from Prometheus. | [`[]Prometheus`](../references/prometheus.md) | |

## For Each

The forEach operation allows you to perform operations that you would apply to all the components crafted during the lookup phase.

In the example above, we can add a kubernetes check on each of the ingresses as follows

```yaml title="kubernetes-ingress-classes.yaml"
apiVersion: canaries.flanksource.com/v1
kind: Topology
metadata:
name: kubernetes-ingress-classes
namespace: default
spec:
schedule: '@every 30s'
components:
- name: Ingress
type: Ingress
icon: server
lookup:
configDB:
- query: SELECT name FROM config_items WHERE type = 'Kubernetes::IngressClass'
expr: |
dyn(results).map(e, {
'name': e.name,
'type': "Ingress",
}).toJSON()
// highlight-start
forEach:
checks:
- inline:
kubernetes:
- kind: Pod
ready: true
resource:
labelSelector: 'app.kubernetes.io/name=ingress-{{.component.name}}&app.kubernetes.io/component=controller'
// highlight-end
```

| Field | Description | Scheme | Required |
| ------------ | -------------------------------------------------------------- | ------------------------------------------------------------ | -------- |
| `components` | Create sub-components for each component | [`[]Component`](../references/components.md) | |
| `properties` | Create or lookup properties for each component | [`[]Property`](./properties.md) | |
| `configs` | Link configuration items for each component | [`[]ConfigSelector`](./catalog.md#config-selector) | |
| `checks` | Create or link health checks for each component | [`[]CheckSelector`](./health-checks.md#check) | |
| `selectors` | Select existing components to be used as the child components. | [`[]ResourceSelector`](../../reference/resource_selector.md) | |

## Templating

All the fields in forEach are templatable. They receive the following two variables:

| Field | Description | Scheme |
| ------------ | -------------------------- | -------------------------------------------- |
| `component` | Component from the lookup | [`[]Component`](../references/components.md) |
| `properties` | The component's properties | `map[string]any` |

### Relationship Spec

| Field | Description | Scheme | Required |
| ------ | ---------------------------------------------------------------------------------------- | -------- | -------- |
| `ref` | Set reference for components relationship | `string` | |
| `type` | Set the type of relationship, e.g. dependsOn, subcomponentOf, providesApis, consumesApis | `string` | |
Loading

0 comments on commit e0e8e48

Please sign in to comment.