Skip to content

Commit

Permalink
chore: merged from main
Browse files Browse the repository at this point in the history
Signed-off-by: Bruno Bressi <[email protected]>
  • Loading branch information
puffitos committed Jan 5, 2024
2 parents 685d9d8 + ab56ca0 commit 9fb176d
Show file tree
Hide file tree
Showing 17 changed files with 170 additions and 123 deletions.
1 change: 1 addition & 0 deletions .github/workflows/end2end.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ jobs:
--set extraArgs.loaderType=file \
--set extraArgs.loaderFilePath=/runconfig/checks.yaml \
--set image.tag=${{ steps.version.outputs.value }} \
--set startupConfig.sparrowName=the-sparrow.com \
chart
- name: Check Pods
run: |
Expand Down
112 changes: 51 additions & 61 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@

- [About this component](#about-this-component)
- [Installation](#installation)
- [Binary](#binary)
- [Container Image](#container-image)
- [Helm](#helm)
- [Binary](#binary)
- [Container Image](#container-image)
- [Helm](#helm)
- [Usage](#usage)
- [Container Image](#container-image-1)
- [Image](#image)
- [Configuration](#configuration)
- [Startup](#startup)
- [Loader](#loader)
- [Runtime](#runtime)
- [TargetManager](#target-manager)
- [Check: Health](#check-health)
- [Startup](#startup)
- [Loader](#loader)
- [Runtime](#runtime)
- [Target Manager](#target-manager)
- [Check: Health](#check-health)
- [Health Metrics](#health-metrics)
- [Check: Latency](#check-latency)
- [Latency Metrics](#latency-metrics)
- [Check: Latency](#check-latency)
- [Latency Metrics](#latency-metrics)
- [API](#api)
- [Metrics](#metrics)
- [Code of Conduct](#code-of-conduct)
Expand Down Expand Up @@ -108,15 +108,14 @@ Additionally check out the sparrow [configuration](#configuration) variants.
## Usage
Use `sparrow run` to execute the instance using the binary. A `sparrowName` (a valid DNS name) is required to be passed,
else
Use `sparrow run` to execute the instance using the binary. A `sparrowName` (a valid DNS name) is required to be passed, else
the sparrow will not start:

```sh
sparrow run --sparrowName sparrow.telekom.de
```

### Container Image
### Image

Run a `sparrow` container by using e.g. `docker run ghcr.io/caas-team/sparrow`.

Expand Down Expand Up @@ -161,10 +160,9 @@ Available loader:

### Runtime

Besides the technical startup configuration the configuration for the `sparrow` checks is loaded dynamically from an
HTTP endpoint. The `loader` is able to load the configuration dynamically during the runtime. Checks can be enabled,
disabled and configured. The available loader confutation options for the startup configuration can be found
in [here](sparrow_run.md)
In addition to the technical startup configuration, the `sparrow` checks' configuration can be dynamically loaded from an HTTP endpoint during runtime. The `loader` is capable of dynamically loading and configuring checks. You can enable, disable, and configure checks as needed.

For detailed information on available loader configuration options, please refer to [this documentation](docs/sparrow_run.md).

Example format of a runtime configuration:

Expand All @@ -173,7 +171,7 @@ apiVersion: 0.0.1
kind: Config
checks:
health:
enabled: true
targets: []
```

### Target Manager
Expand All @@ -183,14 +181,14 @@ This is done via a `TargetManager` interface, which can be configured on startup
are listed below and can be set in a startup YAML configuration file (per default `tmconfig.yaml` in the current
directory).

| Type | Description | Default |
|--------------------------------------|---------------------------------------------------------------------------|----------------------|
| `targetManager.checkInterval` | The interval to check for new targets. | `300s` |
| `targetManager.unhealthyThreshold` | The threshold to mark a target as unhealthy and remove it from the state. | `600s` |
| `targetManager.registrationInterval` | The interval to register the current sparrow at the targets backend. | `300s` |
| `targetManager.gitlab.token` | The token to authenticate against the gitlab instance. | `""` |
| `targetManager.gitlab.baseUrl` | The base URL of the gitlab instance. | `https://gitlab.com` |
| `targetManager.gitlab.projectId` | The project ID of the gitlab project to use as a remote state backend. | `""` |
| Type | Description | Default |
| ------------------------------------ | ------------------------------------------------------------------------------------ | -------------------- |
| `targetManager.checkInterval` | The interval in seconds to check for new targets. | `300s` |
| `targetManager.unhealthyThreshold` | The threshold in seconds to mark a target as unhealthy and remove it from the state. | `600s` |
| `targetManager.registrationInterval` | The interval in seconds to register the current sparrow at the targets backend. | `300s` |
| `targetManager.gitlab.token` | The token to authenticate against the gitlab instance. | `""` |
| `targetManager.gitlab.baseUrl` | The base URL of the gitlab instance. | `https://gitlab.com` |
| `targetManager.gitlab.projectId` | The project ID of the gitlab project to use as a remote state backend. | `""` |

Currently, only one target manager exists: the Gitlab target manager. It uses a gitlab project as the remote state
backend. The various `sparrow` instances will
Expand All @@ -209,54 +207,46 @@ which is named after the DNS name of the `sparrow`. The state file contains the

Available configuration options:

- `checks.health.enabled` (boolean): Currently not used.
- `checks.health.targets` (list of strings): List of targets to send health probe. Needs to be a valid url. Can be
another `sparrow` instance. Use health endpoint, e.g. `https://sparrow-dns.telekom.de/checks/health`. The
remote `sparrow` instance needs the `healthEndpoint` enabled.
- `checks.health.healthEndpoint` (boolean): Needs to be activated when the `sparrow` should expose its own health
endpoint. Mandatory if another `sparrow` instance wants to perform a health check.
another `sparrow` instance. Automatically used when target manager is activated otherwise use the health endpoint of the remote sparrow, e.g. `https://sparrow-dns.telekom.de/checks/health`.

Example configuration:

```YAML
checks:
health:
enabled: true
targets:
- "https://gitlab.devops.telekom.de"
healthEndpoint: false
```

#### Health Metrics

- `sparrow_health_up`
- Type: Gauge
- Description: Health of targets
- Labelled with `target`
- Type: Gauge
- Description: Health of targets
- Labelled with `target`

### Check: Latency

Available configuration options:

- `checks`
- `latency`
- `enabled` (boolean): Currently not used.
- `interval` (integer): Interval in seconds to perform the latency check.
- `timeout` (integer): Timeout in seconds for the latency check.
- `retry`
- `count` (integer): Number of retries for the latency check.
- `delay` (integer): Delay in seconds between retries for the latency check.
- `targets` (list of strings): List of targets to send latency probe. Needs to be a valid url. Can be
another `sparrow` instance. Use latency endpoint, e.g. `https://sparrow-dns.telekom.de/checks/latency`. The
remote `sparrow` instance needs the `latencyEndpoint` enabled.
- `latencyEndpoint` (boolean): Needs to be activated when the `sparrow` should expose its own latency endpoint.
Mandatory if another `sparrow` instance wants to perform a latency check.
Example configuration:
- `latency`
- `interval` (integer): Interval in seconds to perform the latency check.
- `timeout` (integer): Timeout in seconds for the latency check.
- `retry`
- `count` (integer): Number of retries for the latency check.
- `delay` (integer): Delay in seconds between retries for the latency check.
- `targets` (list of strings): List of targets to send latency probe. Needs to be a valid url. Can be
another `sparrow` instance. Automatically used when the target manager is enabled otherwise
use latency endpoint, e.g. `https://sparrow-dns.telekom.de/checks/latency`.
- `latencyEndpoint` (boolean): Needs to be activated when the `sparrow` should expose its own latency endpoint.
Mandatory if another `sparrow` instance wants to perform a latency check.
Example configuration:

```yaml
checks:
latency:
enabled: true
interval: 1
timeout: 3
retry:
Expand All @@ -270,19 +260,19 @@ checks:
#### Latency Metrics

- `sparrow_latency_duration_seconds`
- Type: Gauge
- Description: Latency with status information of targets
- Labelled with `target` and `status`
- Type: Gauge
- Description: Latency with status information of targets
- Labelled with `target` and `status`

- `sparrow_latency_count`
- Type: Counter
- Description: Count of latency checks done
- Labelled with `target`
- Type: Counter
- Description: Count of latency checks done
- Labelled with `target`

- `sparrow_latency_duration`
- Type: Histogram
- Description: Latency of targets in seconds
- Labelled with `target`
- Type: Histogram
- Description: Latency of targets in seconds
- Labelled with `target`

## API

Expand Down Expand Up @@ -314,7 +304,7 @@ The application itself and all end-user facing content will be made available in
The following channels are available for discussions, feedback, and support requests:

| Type | Channel |
|------------|--------------------------------------------------------------------------------------------------------------------------------------------------------|
| ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
| **Issues** | <a href="/../../issues/new/choose" title="General Discussion"><img src="https://img.shields.io/github/issues/caas-team/sparrow?style=flat-square"></a> |

## How to Contribute
Expand Down
4 changes: 2 additions & 2 deletions chart/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ description: A Helm chart to install Sparrow
type: application
keywords:
- monitoring
version: 0.0.2
appVersion: "v0.1.0"
version: 0.0.3
appVersion: "v0.2.0"
icon: https://github.com/caas-team/sparrow/blob/main/docs/img/sparrow.png
sources:
- https://github.com/caas-team/sparrow
Expand Down
8 changes: 5 additions & 3 deletions chart/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# sparrow

![Version: 0.0.2](https://img.shields.io/badge/Version-0.0.2-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: v0.1.0](https://img.shields.io/badge/AppVersion-v0.1.0-informational?style=flat-square)
![Version: 0.0.3](https://img.shields.io/badge/Version-0.0.3-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: v0.2.0](https://img.shields.io/badge/AppVersion-v0.2.0-informational?style=flat-square)

A Helm chart to install Sparrow

Expand Down Expand Up @@ -43,7 +43,7 @@ A Helm chart to install Sparrow
| podSecurityContext.supplementalGroups[0] | int | `1000` | |
| replicaCount | int | `1` | |
| resources | object | `{}` | |
| runtimeConfig | object | `{"health":{"enabled":true,"healthEndpoint":false,"targets":["https://www.example.com/","https://www.google.com/"]},"latency":{"enabled":true,"interval":1,"retry":{"count":3,"delay":1},"targets":["https://example.com/","https://google.com/"],"timeout":3}}` | runtime configuration of the Sparrow see: https://github.com/caas-team/sparrow#runtime |
| runtimeConfig | object | `{"health":{"targets":["https://www.example.com/","https://www.google.com/"]},"latency":{"interval":1,"retry":{"count":3,"delay":1},"targets":["https://example.com/","https://google.com/"],"timeout":3}}` | runtime configuration of the Sparrow see: https://github.com/caas-team/sparrow#runtime |
| securityContext.allowPrivilegeEscalation | bool | `false` | |
| securityContext.capabilities.drop[0] | string | `"ALL"` | |
| securityContext.privileged | bool | `false` | |
Expand All @@ -56,7 +56,9 @@ A Helm chart to install Sparrow
| serviceAccount.automount | bool | `true` | Automatically mount a ServiceAccount's API credentials? |
| serviceAccount.create | bool | `true` | Specifies whether a service account should be created |
| serviceAccount.name | string | `""` | The name of the service account to use. If not set and create is true, a name is generated using the fullname template |
| startupConfig | object | `{}` | startup configuration of the Sparrow see: https://github.com/caas-team/sparrow/blob/main/docs/sparrow_run.md |
| targetManagerConfig | object | `{}` | target manager configuration of the Sparrow (part of the startup) |
| tolerations | list | `[]` | |

----------------------------------------------
Autogenerated from chart metadata using [helm-docs v1.12.0](https://github.com/norwoodj/helm-docs/releases/v1.12.0)
Autogenerated from chart metadata using [helm-docs v1.11.3](https://github.com/norwoodj/helm-docs/releases/v1.11.3)
6 changes: 0 additions & 6 deletions chart/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,3 @@ Create the name of the service account to use
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}

{{- define "startupConfig" -}}
{{- range $key, $value := .Values.startupConfig }}
{{ $key }}: {{ $value }}
{{- end }}
{{- end }}
3 changes: 0 additions & 3 deletions chart/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,13 @@ data:
checks:
{{- if .Values.runtimeConfig.health}}
health:
enabled: {{ .Values.runtimeConfig.health.enabled }}
targets:
{{- with .Values.runtimeConfig.health.targets }}
{{- toYaml . | nindent 10 }}
{{- end }}
healthEndpoint: {{ .Values.runtimeConfig.health.healthEndpoint }}
{{- end }}
{{- if .Values.runtimeConfig.latency }}
latency:
enabled: true
interval: {{ .Values.runtimeConfig.latency.interval | default 1 }}
timeout: {{ .Values.runtimeConfig.latency.timeout | default 3 }}
retry:
Expand Down
17 changes: 11 additions & 6 deletions chart/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,21 @@ spec:
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
{{- if or .Values.extraArgs .Values.startupConfig}}
{{- if or .Values.extraArgs .Values.startupConfig .Values.targetManagerConfig}}
- args:
{{- end }}
{{- if .Values.startupConfig}}
- --config
- /startupconfig/.sparrow.yaml
{{- else if .Values.extraArgs }}
- --config
- /startupconfig/.sparrow.yaml
{{- end }}
{{- if .Values.targetManagerConfig}}
- --tmconfig
- /startupconfig/tmconfig.yaml
{{- end }}
{{- if .Values.extraArgs }}
{{- range $key, $value := .Values.extraArgs }}
- --{{ $key }}
- {{ $value }}
- --{{ $key }}
- {{ $value }}
{{- end }}
{{- end }}
{{- if .Values.env }}
Expand Down
9 changes: 7 additions & 2 deletions chart/templates/secret.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- if .Values.startupConfig}}
{{- if or .Values.startupConfig .Values.targetManagerConfig }}
apiVersion: v1
kind: Secret
type: Opaque
Expand All @@ -7,5 +7,10 @@ metadata:
labels:
{{- include "sparrow.labels" . | nindent 4 }}
data:
.sparrow.yaml: {{ include "startupConfig" . | b64enc }}
{{- if .Values.startupConfig}}
.sparrow.yaml: {{ toYaml .Values.startupConfig | b64enc }}
{{- end }}
{{- if .Values.targetManagerConfig}}
tmconfig.yaml: {{ toYaml .Values.targetManagerConfig | b64enc }}
{{- end }}
{{- end }}
18 changes: 13 additions & 5 deletions chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ extraArgs:

# -- startup configuration of the Sparrow
# see: https://github.com/caas-team/sparrow/blob/main/docs/sparrow_run.md
# startupConfig:
startupConfig: {}
# apiAddress:
# loaderFilePath: /runconfig/checks.yaml
# loaderHttpRetryCount:
Expand All @@ -111,19 +111,27 @@ extraArgs:
# loaderHttpUrl:
# loaderInterval:
# loaderType: http | file
# tmconfig: /startupconfig/tmconfig.yaml
# sparrowName: the-sparrow.com


# -- target manager configuration of the Sparrow (part of the startup)
targetManagerConfig: {}
# checkInterval: 300s
# unhealthyThreshold: 600s
# registrationInterval: 300s
# gitlab:
# token: ""
# baseUrl: https://gitlab.com
# projectId: ""

# -- runtime configuration of the Sparrow
# see: https://github.com/caas-team/sparrow#runtime
runtimeConfig:
health:
enabled: true
targets:
- "https://www.example.com/"
- "https://www.google.com/"
healthEndpoint: false
latency:
enabled: true
interval: 1
timeout: 3
retry:
Expand Down
4 changes: 2 additions & 2 deletions cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func NewCmdRun() *cobra.Command {
}

cmd.PersistentFlags().String(flagMapping.ApiAddress, ":8080", "api: The address the server is listening on")
cmd.PersistentFlags().String(flagMapping.SparrowName, "sparrow", "The DNS name of the sparrow")
cmd.PersistentFlags().String(flagMapping.SparrowName, "", "The DNS name of the sparrow")
cmd.PersistentFlags().StringP(flagMapping.LoaderType, "l", "http",
"defines the loader type that will load the checks configuration during the runtime. The fallback is the fileLoader")
cmd.PersistentFlags().Int(flagMapping.LoaderInterval, defaultLoaderInterval, "defines the interval the loader reloads the configuration in seconds")
Expand All @@ -71,7 +71,7 @@ func NewCmdRun() *cobra.Command {
cmd.PersistentFlags().Int(flagMapping.LoaderHttpRetryCount, defaultHttpRetryCount, "http loader: Amount of retries trying to load the configuration")
cmd.PersistentFlags().Int(flagMapping.LoaderHttpRetryDelay, defaultHttpRetryDelay, "http loader: The initial delay between retries in seconds")
cmd.PersistentFlags().String(flagMapping.LoaderFilePath, "config.yaml", "file loader: The path to the file to read the runtime config from")
cmd.PersistentFlags().String(flagMapping.TargetManagerConfig, "tmconfig.yaml", "target manager: The path to the file to read the target manager config from")
cmd.PersistentFlags().String(flagMapping.TargetManagerConfig, "", "target manager: The path to the file to read the target manager config from")

_ = viper.BindPFlag(flagMapping.ApiAddress, cmd.PersistentFlags().Lookup(flagMapping.ApiAddress))
_ = viper.BindPFlag(flagMapping.SparrowName, cmd.PersistentFlags().Lookup(flagMapping.SparrowName))
Expand Down
4 changes: 2 additions & 2 deletions docs/sparrow_run.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ sparrow run [flags]
--loaderHttpUrl string http loader: The url where to get the remote configuration
--loaderInterval int defines the interval the loader reloads the configuration in seconds (default 300)
-l, --loaderType string defines the loader type that will load the checks configuration during the runtime. The fallback is the fileLoader (default "http")
--sparrowName string The DNS name of the sparrow (default "sparrow")
--tmconfig string target manager: The path to the file to read the target manager config from (default "tmconfig.yaml")
--sparrowName string The DNS name of the sparrow
--tmconfig string target manager: The path to the file to read the target manager config from
```

### Options inherited from parent commands
Expand Down
Loading

0 comments on commit 9fb176d

Please sign in to comment.