Skip to content

Commit

Permalink
Merge pull request #116 from flanksource/canary-checker-testing
Browse files Browse the repository at this point in the history
Canary checker testing
  • Loading branch information
moshloop authored Dec 26, 2023
2 parents 0c7d165 + 33b9fd0 commit 58607fd
Show file tree
Hide file tree
Showing 8 changed files with 108 additions and 21 deletions.
2 changes: 1 addition & 1 deletion canary-checker/docs/concepts/grafana.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Grafana

Default grafana dashboards are available, they can be installed with
Default grafana dashboards are available. After you deploy Grafana, these dashboards can be installed with

```
--set grafanaDashboards=true --set serviceMonitor=true
Expand Down
2 changes: 1 addition & 1 deletion canary-checker/docs/concepts/health-evaluation.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ spec:
- name: http pass response 200 status code
endpoint: https://httpbin.demo.aws.flanksource.com/status/200
test:
expr: "code in [200,201,301] and sslAge < Duration('7d')"
expr: "code in [200,201,301] && sslAge < Duration('7d')"
```
:::info Boolean
Expand Down
6 changes: 4 additions & 2 deletions canary-checker/docs/concepts/metrics-exporter.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
title: Metrics Exporter
---

Canary checker can export custom metrics from any check type, replacing and/or consolidating multiple standaline Prometheus Exporters into a single exporter.


Canary checker can export custom metrics from any check type, replacing and/or consolidating multiple standalone Prometheus Exporters into a single exporter.

In the example below, exchange rates against the USD are exported by first calling an HTTP api and then using the values from the JSON response to create the metrics:

Expand Down Expand Up @@ -45,7 +47,7 @@ spec:
value: ILS
- name: exchange_rate_api
type: histogram
valueExpr: result.elapsed.getMilliseconds()
value: result.elapsed.getMilliseconds()
```
Which would output:
Expand Down
1 change: 1 addition & 0 deletions canary-checker/docs/concepts/transforms.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ spec:
schedule: "*/5 * * * *"
alertmanager:
- url: alertmanager.example.com
name: alert-manager-transform
alerts:
- .*
ignore:
Expand Down
6 changes: 3 additions & 3 deletions canary-checker/docs/concepts/troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

## Enable trace and debug

To increase the amount of logs for a particular trace add a `trace: true` annotation:
To increase the amount of logs for a particular trace add a `debug: true` or `trace: true` annotation:

```yaml trace.yaml
apiVersion: canaries.flanksource.com/v1
Expand Down Expand Up @@ -36,10 +36,10 @@

## Run checks immediately using `next-runtime`

To run a canary outside of its normall schedule add the annotation:
To run a canary outside of its normal schedule add the annotation:

```bash
kubectl annotate canary <canary> next-runtime=$(date -Iseconds) -n
kubectl annotate canary <canary> next-runtime=$(date -Iseconds)
```

## Temporarily pause a canary using `suspend`
Expand Down
4 changes: 2 additions & 2 deletions canary-checker/docs/database.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ To specify a username and password for the chart-managed Postgres server, create

### Connecting to an external db

In order to connect to an existing Postgres server, a database must be created on the server, along with a user that has administrator permissions for the database.git
In order to connect to an existing Postgres server, a database must be created on the server, along with a user that has administrator permissions for the database.

```yaml title="values.yaml"
db:
Expand All @@ -57,6 +57,6 @@ db:
create: false
secretKeyRef:
name: postgres-connection # name of secret that contains a key containging the postgres connection URI
key: POSTGRES_URL # name of the key in the secret that contains the postgres connection URI
key: POSTGRES_URL # name of the key in the secret that contains the postgres connection URI. The URI must be in the format 'postgresql://"$user":"$password"@"$host"/"$database"'
# ...
```
25 changes: 22 additions & 3 deletions canary-checker/docs/getting-started.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Getting Started

1. Install canary checker:
## Install canary checker

```bash
helm repo add flanksource https://flanksource.github.io/charts
helm repo update
helm install canary-checker flanksource/canary-checker -n "canary-checker" --create-namespace
```

2. Create a new check
## Create a new check

```yaml title="canary.yaml"
apiVersion: canaries.flanksource.com/v1
Expand All @@ -24,7 +24,7 @@
url: https://httpbin.demo.aws.flanksource.com/status/500
```

And then apply it to the cluster:
And then apply it to the cluster:

```shell
kubectl apply -f canary.yaml
Expand All @@ -50,8 +50,27 @@

4. Check the Dashboard

You can access the web dashboard by forwarding the port:

```bash
kubectl -n canary-checker port-forward svc/canary-checker-ui 8080:80
```

![](./images/http-checks.png)

[http://localhost:8080](http://localhost:8080)

The canary checker itself only presents an API. To view the data graphically, the Flanksource UI is required, and is installed by default. The UI should be configured in [values.yaml](https://github.com/flanksource/canary-checker/blob/699f31a2326034f761ba1b30d966436d6318dd06/chart/values.yaml#L105) to allow external access via ingress

| Parameter | Description |
|------------------------------------|---------------------------------------------------------------|
| `flanksource-ui.ingress.host` | URL at which the UI will be accessed |
| `flanksource-ui.ingress.annotations` | Map of annotations required by the ingress controller or certificate issuer |
| `flanksource-ui.ingress.tls` | Map of configuration options for TLS |

More details regarding ingress configuration can be found in the [kubernetes documentation](https://kubernetes.io/docs/concepts/services-networking/ingress/)


## Getting Help

If you have any questions about canary checker:
Expand Down
83 changes: 74 additions & 9 deletions canary-checker/docs/helm.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,17 @@ image: /static/img/icons/helm.svg

The recommended method for installing Canary Checker is using [helm](https://helm.sh/)

## 1. Add the Flanksource helm repository
## 1. Deploy Canary Checker

### Using Helm

Add the Flanksource helm repository

```bash
helm repo add flanksource https://flanksource.github.io/charts
helm repo update
```

## 2. Deploy Canary Checker using Helm

To install into a new `canary-checker` namespace, run

```bash
Expand All @@ -41,6 +43,70 @@ flanksource-ui:
- canary-checker.127.0.0.1.nip.io
```
### Using Flux CD
```yaml title=helmrelease.yaml
apiVersion: v1
kind: Namespace
metadata:
name: canary-checker
---
apiVersion: source.toolkit.fluxcd.io/v1beta2
kind: HelmRepository
metadata:
name: flanksource
namespace: canary-checker
spec:
interval: 5m
url: https://flanksource.github.io/charts
---
apiVersion: helm.toolkit.fluxcd.io/v2beta1
kind: HelmRelease
metadata:
name: canary-checker
namespace: canary-checker
spec:
interval: 5m
chart:
spec:
chart: canary-checker
sourceRef:
kind: HelmRepository
name: flanksource
interval: 1m
values:
flanksource-ui:
ingress:
host: canary-checker.127.0.0.1.nip.io
annotations:
kubernetes.io/ingress.class: nginx
kubernetes.io/tls-acme: "true"
tls:
- secretName: canary-checker-tls
hosts:
- canary-checker.127.0.0.1.nip.io
```
```yaml title=canary-checker-kustomization.yaml
apiVersion: kustomize.toolkit.fluxcd.io/v1
kind: Kustomization
metadata:
name: canary-checker
namespace: flux-system
spec:
interval: 5m
sourceRef:
kind: GitRepository
name: <Flux Gitrepo Name>
path: path/to/canary-checker/helmrelease/folder
prune: true
healthChecks: # wait for the HelmRelease to be reconciled with
- apiVersion: helm.toolkit.fluxcd.io/v2beta1
kind: HelmRelease
name: canary-checker
namespace: canary-checker
```
:::info
Note the default installation of canary-checker uses an embedded postgres database and does not persist history, see: [Database](database)
:::
Expand All @@ -61,26 +127,25 @@ spec:
EOF
```

## 4. Check the results via the CLI
## 4. Check the results via the [CLI](./cli)

```bash
kubectl get canary
```

```shell-session
$ kubectl get canary
NAME INTERVAL STATUS LAST CHECK UPTIME 1H LATENCY 1H LAST TRANSITIONED
http-check. 30 Passed 13s 18/18 (100.0%) 480ms 13s
NAME INTERVAL STATUS LAST CHECK UPTIME 1H LATENCY 1H LAST TRANSITIONED
http-check 30 Passed 13s 18/18 (100.0%) 480ms 13s
```

## 5. Access the dashboard

You can access the web dashboard by forwarding the port:

```bash
kubectl port-forward svc/canary-checker-ui 8080:80
kubectl -n canary-checker port-forward svc/canary-checker-ui 8080:80
```

![](./images/http-checks.png)
[http://localhost:8080](http://localhost:8080)


Expand Down

0 comments on commit 58607fd

Please sign in to comment.