-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update topology documentation (#185)
* 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
1 parent
1fe0da9
commit e0e8e48
Showing
25 changed files
with
695 additions
and
539 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
26 changes: 17 additions & 9 deletions
26
...-control/docs/topology/concepts/config.md → ...control/docs/topology/concepts/catalog.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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` | | |
Oops, something went wrong.