Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ jobs:

- name: Install dependencies and build
run: |
cd ${{ matrix.repo }}
cd modules && make all
cd ../${{ matrix.repo }}
echo "Installing packages in $(pwd)"
npm ci
echo "Building $(pwd)"
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
.PHONY: lint
lint:
vale sync
vale canary-checker/docs
vale mission-control/docs
vale canary-checker/docs --glob='!**/{README,CHANGELOG,readme,security,SECURITY,CONTRIBUTING,benchmark,development,LICENSE}.md'
vale mission-control/docs --glob='!**/{README,CHANGELOG,readme,security,SECURITY,CONTRIBUTING,benchmark,development,LICENSE}.md'
markdownlint mission-control/docs
markdownlint canary-checker/docs

Expand Down
2 changes: 1 addition & 1 deletion canary-checker/docs/comparisons/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
title: Comparisons
sidebar_position: 4
sidebar_custom_props:
icon: material-symbols-light:text-compare-outline
icon: compare
---
2 changes: 1 addition & 1 deletion canary-checker/docs/concepts/expressions/index.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: Expressions
sidebar_custom_props:
icon: hugeicons:code
icon: code
---

canary-checker can be extended using expressions in 3 ways:
Expand Down
2 changes: 1 addition & 1 deletion canary-checker/docs/concepts/metrics.mdx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: Metrics
sidebar_custom_props:
icon: clarity:dashboard-line
icon: dashboard-line
---


Expand Down
2 changes: 1 addition & 1 deletion canary-checker/docs/concepts/secret-management.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: Env Vars
sidebar_custom_props:
icon: stash:search-box-light
icon: shield-lock
sidebar_position: 1
---

Expand Down
2 changes: 1 addition & 1 deletion canary-checker/docs/examples/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: Examples
sidebar_position: 3
hide_sidebar: true
sidebar_custom_props:
icon: stash:graduation-cap-light
icon: learning

---
import DocCardList from '@theme/DocCardList';
Expand Down
4 changes: 2 additions & 2 deletions canary-checker/docs/partials/_domain.mdx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Choose a routable `DOMAIN` for Mission Control
> See [Ingress](/reference/helm/mission-control#ingress) for more options on configuring the ingress including generating certs with cert-manager
> <p>See [Local Testing](../local-testing) for testing using a kind or minikube without a routable domain</p>
> See [Ingress](/installation/self-hosted/ingress) for more options on configuring the ingress including generating certs with cert-manager
> <p>See [Local Testing](/installation/local-testing) for testing using a kind or minikube without a routable domain</p>

12 changes: 0 additions & 12 deletions canary-checker/docs/reference/1-kubernetes-resource.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -184,15 +184,3 @@ When this canary is deleted, the **test** namespace is deleted and consequently

</div>
</details>

<details summary="Testing Helm Deployments in a Virtual Cluster">
<div>

This example demonstrates how to test a Helm deployment in a virtual cluster.

It creates a vcluster, installs the canary-checker helm chart, and then verifies the deployment is working using an http check.

```yaml title="vcluster-canary-checker.yaml" file=<rootDir>/modules/canary-checker/fixtures/k8s/vcluster-canary-checker.yaml
```
</div>
</details>
12 changes: 9 additions & 3 deletions canary-checker/docs/reference/1-kubernetes.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ sidebar_position: 0
sidebar_custom_props:
icon: k8s
---
import ReactMarkdown from 'react-markdown';

# <Icon name="k8s" /> Kubernetes

Expand All @@ -15,9 +16,14 @@ The Kubernetes check performs requests on Kubernetes resources such as Pods to g

<HealthCheck name="kubernetes" edition="standard" connection="kubeconfig" rows={[
{field: "kind", description: "Kubernetes object kind", scheme: 'string', required: true},
{field: "resource", description: " Queries resources related to specified Kubernetes object ", scheme: '[Resource Selector](#resource-selector)'},
{field: "namespaceSelector", description: "Namespace of the Kubernetes object",scheme: '[Resource Selector](#resource-selector)'},
{field: "namespace", description: "Failing checks are placed in this namespace, useful if you have shared namespaces"},
{field: "resource", description: "Filters resources by name, namespace, or labels", scheme: '[Resource Selector](#resource-selector)'},
{field: "namespaceSelector", description: "Filters namespaces by name or labels", scheme: '[Resource Selector](#resource-selector)'},
{field: "namespace", description:
<ReactMarkdown>
Failing checks are placed in this namespace, useful if you have shared namespaces.

**NOTE:** this does not change the namespace of the resources being queried</ReactMarkdown>
},
{field: "ignore", description: "Ignore the specified resources from the fetched resources. Can be a glob pattern.", scheme: '[]glob'},
{field: "healthy", description: "Fail the check if any resources are unhealthy", scheme: 'bool'},
{field: "ready", description: "Fail the check if any resources are not ready", scheme: 'bool'},
Expand Down
24 changes: 11 additions & 13 deletions canary-checker/docs/scripting/gotemplate.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,12 @@ Reports whether a given object has a property with the given key, or whether a g

### jq

Filters an input object or list using the [jq](https://stedolan.github.io/jq/) language, as implemented by [gojq](https://github.com/itchyny/gojq).
The `jq` function filters input using the [jq query language](https://stedolan.github.io/jq/), implemented via [gojq](https://github.com/itchyny/gojq).

Any JSON datatype may be used as input (NOTE: strings are not JSON-parsed but passed in as is). If the expression results in multiple items (no matter if streamed or as an array) they are wrapped in an array. Otherwise a single item is returned (even if resulting in an array with a single contained element).
Input can be any valid JSON data type, strings are passed directly without JSON parsing. The function returns:

- A single value for single results
- An array for multiple results (whether streamed or array output)
JQ filter expressions can be tested at [jqplay](https://jqplay.org/)

See also:
Expand Down Expand Up @@ -922,7 +924,7 @@ Adds all given operators. When one of the inputs is a floating-point number, the

Returns the least integer value greater than or equal to a given floating-point number. This wraps Go's [`math.Ceil`](https://golang.org/pkg/math/#Ceil).

**Note:** the return value of this function is a `float64` so that the special-cases `NaN` and `Inf` can be returned appropriately.
**Note:** the return value of this function is a `float64` so that the cases of `NaN` and `Inf` can be returned appropriately.

```go
{{ range (slice 5.1 42 "3.14" "0xFF" "NaN" "Inf" "-0") }}ceil {{ printf "%#v" . }} = {{ math.Ceil . }}{{"\n"}}{{ end }}
Expand All @@ -948,7 +950,7 @@ Divide the first number by the second. Division by zero is disallowed. The resul

Returns the greatest integer value less than or equal to a given floating-point number. This wraps Go's [`math.Floor`](https://golang.org/pkg/math/#Floor).

**Note:** the return value of this function is a `float64` so that the special-cases `NaN` and `Inf` can be returned appropriately.
**Note:** the return value of this function is a `float64` so that the cases of `NaN` and `Inf` can be returned appropriately.

```go
{{ range (slice 5.1 42 "3.14" "0xFF" "NaN" "Inf" "-0") }}floor {{ printf "%#v" . }} = {{ math.Floor . }}{{"\n"}}{{ end }}
Expand Down Expand Up @@ -1047,7 +1049,7 @@ Return the remainder from an integer division operation.

Returns the nearest integer, rounding half away from zero.

**Note:** the return value of this function is a `float64` so that the special-cases `NaN` and `Inf` can be returned appropriately.
**Note:** the return value of this function is a `float64` so that the cases of `NaN` and `Inf` can be returned appropriately.

```go
{{ range (slice -6.5 5.1 42.9 "3.5" 6.5) }}round {{ printf "%#v" . }} = {{ math.Round . }}{{"\n"}}{{ end }}
Expand Down Expand Up @@ -1635,7 +1637,7 @@ broken

Return the number of _runes_ (Unicode code-points) contained within the input. This is similar to the built-in `len` function, but `len` counts the length in _bytes_. The length of an input containing multi-byte code-points should therefore be measured with `strings.RuneCount`.

Inputs will first be converted to strings, and multiple inputs are concatenated.
Inputs are first converted to strings, and multiple inputs are concatenated.

This wraps Go's [`utf8.RuneCountInString`](https://golang.org/pkg/unicode/utf8/#RuneCountInString) function.

Expand Down Expand Up @@ -1840,10 +1842,7 @@ It is{{ if not $t.IsDST }} not{{ end }} daylight savings time.

Parses a timestamp defined by the given layout. This wraps [`time.Parse`](https://golang.org/pkg/time/#Parse).

A number of pre-defined layouts are provided as constants, defined
[here](https://golang.org/pkg/time/#pkg-constants).

Just like [`time.Now`](#now), this is usually used in conjunction with other functions.
A number of pre-defined layouts are provided as [constants](https://golang.org/pkg/time/#pkg-constants)

_Note: In the absence of a time zone indicator, `time.Parse` returns a time in UTC._

Expand Down Expand Up @@ -1952,15 +1951,14 @@ Return the local system's time zone offset, in seconds east of UTC.

Create a version 1 UUID (based on the current MAC address and the current date/time).

Use [`uuid.V4`](#v4) instead in most cases.

_Note:_ [`uuid.V4`](#v4) is recommended instead
```go
{{ uuid.V1 }} // 4d757e54-446d-11e9-a8fa-72000877c7b0
```

### V4

Create a version 4 UUID (randomly generated).
Create a version 4 UUID

This function consumes entropy.

Expand Down
2 changes: 1 addition & 1 deletion canary-checker/docs/troubleshooting.mdx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: Troubleshooting
sidebar_custom_props:
icon: material-symbols-light:troubleshoot
icon: troubleshoot
---

import Install from '@site/docs/snippets/_install.mdx'
Expand Down
2 changes: 1 addition & 1 deletion canary-checker/docs/types.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ hide_title: true
title: Common Types
sidebar_position: 3
sidebar_custom_props:
icon: fluent:library-16-regular
icon: library
---

import Types from '@site/docs/snippets/\_types.md'
Expand Down
2 changes: 1 addition & 1 deletion canary-checker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"@docusaurus/core": "^3.7.0",
"@docusaurus/plugin-client-redirects": "^3.7.0",
"@docusaurus/preset-classic": "^3.7.0",
"@flanksource/icons": "^1.0.24",
"@flanksource/icons": "^1.0.34",
"@floating-ui/react": "^0.26.28",
"@mdx-js/react": "^3.0.0",
"ansi-to-html": "^0.7.2",
Expand Down
144 changes: 144 additions & 0 deletions common/snippets/_resource-selector.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
---
title: Resource Selectors
sidebar_position: 2
sidebar_custom_props:
icon: stash:search-box-light
---

# Resource Selectors

Resource Selectors are used in multiple places including:

Check notice on line 10 in common/snippets/_resource-selector.md

View workflow job for this annotation

GitHub Actions / vale

[vale] common/snippets/_resource-selector.md#L10

[Flanksource.Passive] 'are used' looks like passive voice.
Raw output
{"message": "[Flanksource.Passive] 'are used' looks like passive voice.", "location": {"path": "common/snippets/_resource-selector.md", "range": {"start": {"line": 10, "column": 20}}}, "severity": "INFO"}

- Attaching components to a topology
- Creating relationships between configs and configs/components
- Finding resources to run health checks or playbooks on

| Field | Description | Scheme | Required |
| --------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------- | -------- |
| `id` | ID of the component | `string` | No |

Check notice on line 18 in common/snippets/_resource-selector.md

View workflow job for this annotation

GitHub Actions / vale

[vale] common/snippets/_resource-selector.md#L18

[Flanksource.ComplexWords] Consider using 'part' instead of 'component'.
Raw output
{"message": "[Flanksource.ComplexWords] Consider using 'part' instead of 'component'.", "location": {"path": "common/snippets/_resource-selector.md", "range": {"start": {"line": 18, "column": 31}}}, "severity": "INFO"}
| `name` | Name of the component/config | `string` | No |

Check notice on line 19 in common/snippets/_resource-selector.md

View workflow job for this annotation

GitHub Actions / vale

[vale] common/snippets/_resource-selector.md#L19

[Flanksource.ComplexWords] Consider using 'part' instead of 'component'.
Raw output
{"message": "[Flanksource.ComplexWords] Consider using 'part' instead of 'component'.", "location": {"path": "common/snippets/_resource-selector.md", "range": {"start": {"line": 19, "column": 33}}}, "severity": "INFO"}
| `namespace` | Select resources in this namespace only, if empty find resources in all namespaces | `string` | No |
| `types` | Match any of the types specified | `[]string` | No |
| `statuses` | Match any of the statuses specified | `[]string` | No |
| `labelSelector` | Kubernetes Style Label Selector | [LabelSelector](https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/) | No |
| `fieldSelector` | Kubernetes Style Field Selector Property fields of the component in kubernetes format (or database columns: owner, topology_id, parent_id) | [FieldSelector](https://kubernetes.io/docs/concepts/overview/working-with-objects/field-selectors/) | No |

Check notice on line 24 in common/snippets/_resource-selector.md

View workflow job for this annotation

GitHub Actions / vale

[vale] common/snippets/_resource-selector.md#L24

[Flanksource.ComplexWords] Consider using 'part' instead of 'component'.
Raw output
{"message": "[Flanksource.ComplexWords] Consider using 'part' instead of 'component'.", "location": {"path": "common/snippets/_resource-selector.md", "range": {"start": {"line": 24, "column": 76}}}, "severity": "INFO"}
| `agent` | Select resources created on this agent, Defaults to `local` | `uuid`, `{name}`, `local` or `all` | No |
| `cache` | Cache settings to use for the results, expensive selectors or selectors that are used often should be cached for longer periods. Defaults to `max-age=10m` | `no-cache`, `no-store` or `max-age={duration}` | No |

Check notice on line 26 in common/snippets/_resource-selector.md

View workflow job for this annotation

GitHub Actions / vale

[vale] common/snippets/_resource-selector.md#L26

[Flanksource.Passive] 'are used' looks like passive voice.
Raw output
{"message": "[Flanksource.Passive] 'are used' looks like passive voice.", "location": {"path": "common/snippets/_resource-selector.md", "range": {"start": {"line": 26, "column": 98}}}, "severity": "INFO"}

Check notice on line 26 in common/snippets/_resource-selector.md

View workflow job for this annotation

GitHub Actions / vale

[vale] common/snippets/_resource-selector.md#L26

[Flanksource.Passive] 'be cached' looks like passive voice.
Raw output
{"message": "[Flanksource.Passive] 'be cached' looks like passive voice.", "location": {"path": "common/snippets/_resource-selector.md", "range": {"start": {"line": 26, "column": 120}}}, "severity": "INFO"}
| `search` | Search for resources via key value pairs using parsing expression grammar | `#search` | No |

## Search

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

Supported operators:

| Operator | Syntax | Types |
| -------- | -------------------------------- | --------------------- |
| `=` | `field=value` | `string` `int` `json` |
| `!=` | `field!=value` | `string` `int` `json` |
| `*` | `field=*value` or `field=value*` | `string` `int` |
| `>` `<` | `field>value` or `field<value` | `datetime` `int` |

Supported fields for:

- [Catalog/Config](/reference/config-db/config):

| Field | Type |
| ------------ | ---------- |
| `name` | `string` |
| `source` | `string` |
| `namespace` | `string` |
| `type` | `string` |
| `status` | `string` |
| `labels` | `json` |
| `tags` | `json` |
| `config` | `json` |
| `health` | `string` |
| `agent` | `string` |
| `created_at` | `datetime` |
| `updated_at` | `datetime` |
| `deleted_at` | `datetime` |

- [Components](/reference/topology/components):

| Field | Type |
| ------------- | ---------- |
| `name` | `string` |
| `topology_id` | `string` |
| `namespace` | `string` |
| `type` | `string` |
| `status` | `string` |
| `labels` | `json` |
| `health` | `string` |
| `agent` | `string` |
| `created_at` | `datetime` |
| `updated_at` | `datetime` |
| `deleted_at` | `datetime` |

- [Health Checks](/reference/canary-checker/check):

| Field | Type |
| ------------ | ---------- |
| `name` | `string` |
| `canary_id` | `string` |
| `namespace` | `string` |
| `type` | `string` |
| `status` | `string` |
| `health` | `string` |
| `labels` | `json` |
| `agent` | `string` |
| `created_at` | `datetime` |
| `updated_at` | `datetime` |
| `deleted_at` | `datetime` |

## Examples

### Selecting Components in a Topology

```yaml title="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
```
Loading
Loading