Skip to content

Commit

Permalink
Update tempo_cluster schema (#198)
Browse files Browse the repository at this point in the history
* update tempo_cluster schema

* update version

* resolve comments

* use uppercase enums
  • Loading branch information
michaeldmitry authored Dec 2, 2024
1 parent a04d3b8 commit 2ccb05c
Show file tree
Hide file tree
Showing 8 changed files with 592 additions and 1 deletion.
184 changes: 184 additions & 0 deletions docs/json_schemas/tempo_cluster/v1/provider.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
{
"$defs": {
"BaseModel": {
"properties": {},
"title": "BaseModel",
"type": "object"
},
"TempoClusterProviderAppData": {
"description": "TempoClusterProviderAppData.",
"properties": {
"worker_config": {
"contentMediaType": "application/json",
"contentSchema": {
"type": "string"
},
"description": "The tempo configuration that the requirer should run with.Yaml-encoded. Must conform to the schema that the presently deployed workload version supports; for example see: https://grafana.com/docs/tempo/latest/configuration/#configure-tempo.",
"title": "Worker Config",
"type": "string"
},
"loki_endpoints": {
"anyOf": [
{
"contentMediaType": "application/json",
"contentSchema": {
"additionalProperties": {
"type": "string"
},
"type": "object"
},
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "List of loki-push-api endpoints to which the worker node can push any logs it generates.",
"title": "Loki Endpoints"
},
"ca_cert": {
"anyOf": [
{
"contentMediaType": "application/json",
"contentSchema": {
"type": "string"
},
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "CA certificate for tls encryption.",
"title": "Ca Cert"
},
"server_cert": {
"anyOf": [
{
"contentMediaType": "application/json",
"contentSchema": {
"type": "string"
},
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Server certificate for tls encryption.",
"title": "Server Cert"
},
"privkey_secret_id": {
"anyOf": [
{
"contentMediaType": "application/json",
"contentSchema": {
"type": "string"
},
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "ID of a Juju secret that holds the private key used by the coordinator for TLS encryption.",
"title": "Privkey Secret Id"
},
"remote_write_endpoints": {
"anyOf": [
{
"contentMediaType": "application/json",
"contentSchema": {
"items": {
"additionalProperties": {
"type": "string"
},
"type": "object"
},
"type": "array"
},
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Endpoints to which the workload (and the worker charm) can push metrics to.",
"title": "Remote Write Endpoints"
},
"charm_tracing_receivers": {
"anyOf": [
{
"contentMediaType": "application/json",
"contentSchema": {
"additionalProperties": {
"type": "string"
},
"type": "object"
},
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Endpoints to which the worker node can push its charm traces to.It is a mapping from protocol names such as `zipkin`, `otlp_grpc`, `otlp_http`.",
"title": "Charm Tracing Receivers"
},
"workload_tracing_receivers": {
"anyOf": [
{
"contentMediaType": "application/json",
"contentSchema": {
"additionalProperties": {
"type": "string"
},
"type": "object"
},
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Endpoints to which the worker node can push its workload traces to.It is a mapping from protocol names such as `zipkin`, `otlp_grpc`, `otlp_http`.",
"title": "Workload Tracing Receivers"
}
},
"required": [
"worker_config"
],
"title": "TempoClusterProviderAppData",
"type": "object"
}
},
"description": "The schema for the provider side of this interface.",
"properties": {
"unit": {
"anyOf": [
{
"$ref": "#/$defs/BaseModel"
},
{
"type": "null"
}
],
"default": null
},
"app": {
"$ref": "#/$defs/TempoClusterProviderAppData"
}
},
"required": [
"app"
],
"title": "ProviderSchema",
"type": "object"
}
116 changes: 116 additions & 0 deletions docs/json_schemas/tempo_cluster/v1/requirer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
{
"$defs": {
"TempoClusterRequirerAppData": {
"description": "TempoClusterRequirerAppData.",
"properties": {
"role": {
"contentMediaType": "application/json",
"contentSchema": {
"$ref": "#/$defs/TempoRole"
},
"title": "Role",
"type": "string"
}
},
"required": [
"role"
],
"title": "TempoClusterRequirerAppData",
"type": "object"
},
"TempoClusterRequirerUnitData": {
"description": "TempoClusterRequirerUnitData.",
"properties": {
"juju_topology": {
"contentMediaType": "application/json",
"contentSchema": {
"$ref": "#/$defs/_Topology"
},
"title": "Juju Topology",
"type": "string"
},
"address": {
"contentMediaType": "application/json",
"contentSchema": {
"type": "string"
},
"title": "Address",
"type": "string"
}
},
"required": [
"juju_topology",
"address"
],
"title": "TempoClusterRequirerUnitData",
"type": "object"
},
"TempoRole": {
"description": "Tempo component role names.\n\nReferences:\n arch:\n -> https://grafana.com/docs/tempo/latest/operations/architecture/\n config:\n -> https://grafana.com/docs/tempo/latest/configuration/#server",
"enum": [
"all",
"querier",
"query-frontend",
"ingester",
"distributor",
"compactor",
"metrics-generator"
],
"title": "TempoRole",
"type": "string"
},
"_Topology": {
"description": "JujuTopology as defined by cos-lib.",
"properties": {
"application": {
"title": "Application",
"type": "string"
},
"charm_name": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"title": "Charm Name"
},
"unit": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"title": "Unit"
}
},
"required": [
"application",
"charm_name",
"unit"
],
"title": "_Topology",
"type": "object"
}
},
"description": "The schema for the requirer side of this interface.",
"properties": {
"unit": {
"$ref": "#/$defs/TempoClusterRequirerUnitData"
},
"app": {
"$ref": "#/$defs/TempoClusterRequirerAppData"
}
},
"required": [
"unit",
"app"
],
"title": "RequirerSchema",
"type": "object"
}
54 changes: 54 additions & 0 deletions interfaces/tempo_cluster/v1/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# `tempo_cluster`

## Usage

`tempo_cluster` is an interface meant to exchange cluster configuration in distributed Tempo deployments.
Multiple [Tempo worker](https://github.com/canonical/tempo-worker-k8s-operator) applications can relate to a [Tempo coordinator](https://github.com/canonical/tempo-coordinator-k8s-operator) application over the `tempo_cluster` interface, and send their role and topology, in order to join the cluster.
The coordinator will use the same relation to convey to the workers back the configuration that they must run with.

## Direction

This interface implements a provider/requirer pattern. The coordinator charm is the provider of the relation, the worker charm is the requirer. Information flows back and forth: first the requirer shares some data necessary for the coordinator to know the role of the worker, then the provider replies back with the configuration it should run with.

```mermaid
flowchart TD
Requirer -- Role, JujuTopology --> Provider
Provider -- Config --> Requirer
```

## Behavior

### Provider
The provider is expected to...
- update the gossip rings in all configurations with the addresses of all worker units that are joining the cluster (regardless of their role).
- share the exact same configuration to all nodes, regardless of the role they declare, via application databag.

### Requirer
The requirer application is expected to...
- publish its role as soon as possible via application databag.
Each requirer unit is expected to...
- publish its address and JujuTopology as soon as possible, via unit databag.

## Relation Data

[\[Pydantic Schema\]](./schema.py)

#### Example
```yaml
provider:
app:
worker_config:
# <a very large chunk of yaml, conforming to Tempo configuration specification: https://grafana.com/docs/tempo/latest/configuration/#configure-tempo>
unit: {}

requirer:
app:
role: receiver
unit:
juju_topology:
model: "mymodel",
model_uuid: "1231234120941234",
application: "tempo-receiver",
charm_name: "tempo-worker-k8s",
unit: "tempo-receiver/2",
```
18 changes: 18 additions & 0 deletions interfaces/tempo_cluster/v1/interface.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: tempo_cluster
internal: true
version: 1
status: published

providers:
- name: tempo-coordinator-k8s
url: https://github.com/canonical/tempo-coordinator-k8s-operator
test_setup:
location: tests/interface/conftest.py
identifier: cluster_tester

requirers:
- name: tempo-worker-k8s
url: https://github.com/canonical/tempo-worker-k8s-operator

maintainer: observability

Loading

0 comments on commit 2ccb05c

Please sign in to comment.