Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[tf] COS (and Minio) terraform modules #227

Merged
merged 69 commits into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from 68 commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
1ef5c50
s3 fix as a local exec
sed-i Oct 24, 2024
10cd27e
sleep longer
sed-i Oct 24, 2024
0314a60
Update
sed-i Oct 24, 2024
ed4c745
Move null resource outside
sed-i Oct 24, 2024
0806d4c
Fixes before merge
sed-i Oct 24, 2024
595b842
Add gagent
sed-i Oct 24, 2024
1e1b19b
Fix
sed-i Oct 24, 2024
b03e6e4
Fix
sed-i Oct 24, 2024
f6ac831
add self-monitoring relations
Abuelodelanada Nov 13, 2024
288dd9d
add mimir and loki traicing relations
Abuelodelanada Nov 13, 2024
770068e
add Grafana tracing relation
Abuelodelanada Nov 13, 2024
413ff84
grafana-agent send traces to Tempo
Abuelodelanada Nov 13, 2024
d4b586a
migrate to issue bot
simskij Nov 12, 2024
17dbade
add repos and gitignore
simskij Nov 12, 2024
c656512
migrate to issue bot
simskij Nov 12, 2024
375649f
add terraform ignres to .gitignore
Abuelodelanada Nov 13, 2024
522177c
Merge branch 'main' into self-monitoring
Abuelodelanada Nov 13, 2024
40dfbaf
Merge branch 'main' into self-monitoring
Abuelodelanada Nov 13, 2024
e1dc1cb
grafana agent scrapes mimir's metrics endpoint
Abuelodelanada Nov 13, 2024
45461ff
Merge branch 'main' into self-monitoring
Abuelodelanada Nov 15, 2024
802b95e
add loki's bucket name as variable
Abuelodelanada Nov 15, 2024
9ebffce
add missing output
Abuelodelanada Nov 15, 2024
fb1a452
fix output
Abuelodelanada Nov 15, 2024
02eee2a
add buckets and s3_integrator names
Abuelodelanada Nov 15, 2024
d244e06
linting
Abuelodelanada Nov 15, 2024
97e2eda
minio variables added
Abuelodelanada Nov 15, 2024
bb146a7
add bucket_name output for tempo and mimir
Abuelodelanada Nov 15, 2024
cd35c12
add outputs for se-integrator
Abuelodelanada Nov 15, 2024
c9c783f
fix outputs
Abuelodelanada Nov 15, 2024
33020d4
fix relations
Abuelodelanada Nov 15, 2024
db3ec47
add minio
Abuelodelanada Nov 15, 2024
3cee384
add s3-workaround
Abuelodelanada Nov 15, 2024
9fd86bc
fix charm-tracing endpoints names
Abuelodelanada Nov 16, 2024
54bbd00
fix traicing endpoits
Abuelodelanada Nov 16, 2024
7283bea
linting
Abuelodelanada Nov 16, 2024
5399685
mc_binary_url variable added
Abuelodelanada Nov 16, 2024
b87362d
s3-workaround.tf refactor
Abuelodelanada Nov 16, 2024
78ffcf8
mote linting...
Abuelodelanada Nov 16, 2024
2a23045
segregation of responsibilities: script -> logic, terraform -> execution
Abuelodelanada Nov 22, 2024
0226856
linting
Abuelodelanada Nov 22, 2024
74c017d
refactor s3
Abuelodelanada Nov 22, 2024
3a88214
add missing versions.tf and fix url
Abuelodelanada Nov 22, 2024
5f8e06e
add missing model_name
Abuelodelanada Nov 23, 2024
c3c5471
general fixes to s3 and cos models
Abuelodelanada Nov 23, 2024
aaf3d1b
linting
Abuelodelanada Nov 25, 2024
6703d55
make s3fix.sh executable
Abuelodelanada Nov 25, 2024
a8b32ab
fix bucket names
Abuelodelanada Nov 25, 2024
f0653d7
refactor tempo outputs.tf
Abuelodelanada Nov 25, 2024
22c50dd
add tempo send-remote-write relation to mimir
Abuelodelanada Nov 26, 2024
706bbda
rename and make s3management.sh idempotent
Abuelodelanada Nov 26, 2024
9916644
refactor and execute s3management always
Abuelodelanada Nov 26, 2024
d0c5a5f
fiz relations and remove ref
Abuelodelanada Nov 26, 2024
97f19e1
Merge branch 'main' into self-monitoring
Abuelodelanada Nov 26, 2024
7c86a64
rename integration names
Abuelodelanada Nov 26, 2024
c375e48
fix description strinf
Abuelodelanada Nov 26, 2024
c7fa368
add sensitive = true to minio password
Abuelodelanada Nov 26, 2024
17a87a3
rename output.tf -> outputs.tf
Abuelodelanada Nov 26, 2024
0516043
fix README.md
Abuelodelanada Nov 26, 2024
94e4bd9
add missing variables
Abuelodelanada Nov 26, 2024
33200d7
improve descriptions
Abuelodelanada Nov 26, 2024
d435478
add units for mimir, loki and tempo
Abuelodelanada Nov 26, 2024
6ec3d06
fix grafana (charm-tracing) relation
Abuelodelanada Nov 26, 2024
56013ae
linting
Abuelodelanada Nov 26, 2024
4391bf4
fix sample deployment in README.md
Abuelodelanada Nov 27, 2024
5663547
more README.md improvements
Abuelodelanada Nov 27, 2024
e1e2a8e
rename s3->minio and decouple from cos module
Abuelodelanada Nov 27, 2024
00a8220
refactor s3management.sh
Abuelodelanada Nov 27, 2024
e737153
Merge branch 'main' into self-monitoring
Abuelodelanada Nov 28, 2024
19bf652
add missing output
Abuelodelanada Nov 29, 2024
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
18 changes: 11 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
**/dist/**

# Local .terraform directories
# Terraform
**/.terraform/*

# .tfstate files
*.tfstate
*.tfstate.*

# Crash log files
*.tfplan
.terraform.lock.hcl
crash.log
.terraform/
terraform.tfvars
terraform.tfvars.json
*.backup
*.bak
crash.log
crash.*.log

# Exclude all .tfvars files, which are likely to contain sensitive data, such as
# password, private keys, and other secrets. These should not be part of version
# control as they are data points which are potentially sensitive and subject
# password, private keys, and other secrets. These should not be part of version
# control as they are data points which are potentially sensitive and subject
# to change depending on the environment.
*.tfvars
*.tfvars.json
Expand Down
94 changes: 87 additions & 7 deletions terraform/modules/cos/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Terraform module for COS HA solution

This is a Terraform module facilitating the deployment of COS HA solution, using the [Terraform juju provider](https://github.com/juju/terraform-provider-juju/). For more information, refer to the provider [documentation](https://registry.terraform.io/providers/juju/juju/latest/docs).
This is a Terraform module facilitating the deployment of COS HA solution, using the [Terraform juju provider](https://github.com/juju/terraform-provider-juju/). For more information, refer to the provider [documentation](https://registry.terraform.io/providers/juju/juju/latest/docs).

The HA solution consists of the following Terraform modules:
- [grafana-k8s](https://github.com/canonical/grafana-k8s-operator): Visualization, monitoring,and dashboards.
Expand All @@ -10,7 +10,7 @@ The HA solution consists of the following Terraform modules:

This Terraform module deploys COS with Mimir and Loki in their microservices modes, and grafana, prometheus, and loki in monolithic mode.

> [!NOTE]
> [!NOTE]
> `s3-integrator` itself doesn't act as an S3 object storage system. For the HA solution to be functional, `s3-integrator` needs to point to an S3-like storage. See [this guide](https://discourse.charmhub.io/t/cos-lite-docs-set-up-minio/15211) to learn how to connect to an S3-like storage for traces.

## Requirements
Expand All @@ -23,8 +23,26 @@ The module offers the following configurable inputs:

| Name | Type | Description | Required |
| - | - | - | - |
| `channel`| string | Channel that the charms are deployed from | latest/edge |
| `model_name`| string | Name of the model that the charm is deployed on | |
| `channel` | string | Channel that the charms are deployed from | latest/edge |
| `model_name` | string | Name of the model that the charm is deployed on | |
| `use_tls` | bool | Specify whether to use TLS or not for coordinator-worker communication |
| `minio_user` | string | User for MinIO |
| `minio_password` | string | Password for MinIO |
| `loki_backend_units` | number | Number of Loki worker units with backend role |
| `loki_backend_units` | number | Number of Loki worker units with backend role |
| `loki_read_units` | number | Number of Loki worker units with read role |
| `loki_write_units` | number | Number of Loki worker units with write role |
| `mimir_backend_units` | number | Number of Mimir worker units with backend role |
| `mimir_read_units` | number | Number of Mimir worker units with read role |
| `mimir_write_units` | number | Number of Mimir worker units with write role |
| `tempo_compactor_units` | number | Number of Tempo worker units with compactor role |
| `tempo_distributor_units` | number | Number of Tempo worker units with distributor role |
| `tempo_ingester_units` | number | Number of Tempo worker units with ingester role |
| `tempo_metrics_generator_units` | number | Number of Tempo worker units with metrics_generator role |
| `tempo_querier_units` | number | Number of Tempo worker units with querier role |
| `tempo_query_frontend_units` | number | Number of Tempo worker units with query_frontend role |



### Outputs
Upon application, the module exports the following outputs:
Expand All @@ -44,7 +62,69 @@ Users should ensure that Terraform is aware of the `juju_model` dependency of th

To deploy this module with its needed dependency, you can run `terraform apply -var="model_name=<MODEL_NAME>" -auto-approve`. This would deploy all COS HA solution modules in the same model.

### High Availability
### High Availability

By default, this Terraform module will deploy each worker with `1` unit. If you want to scale each Loki, Mimir or Tempo worker unit please check the variables available for that purpose in `variables.tf`. For instance to deploy 3 units of each Loki worker, you can run:

```shell
terraform apply -var='minio_password=Password' -var='minio_user=User' -var='model_name=test'\
-var='loki_backend_units=3' -var='loki_read_units=3' -var='loki_write_units=3'
```


### Minimal sample deployment.

In orrder to deploy COS with just one unit per worker charm create a `main.rf` file with the following content.

```hcl
# COS module that deploy the whole Canonical Observability Stack
module "cos" {
source = "git::https://github.com/canonical/observability//terraform/modules/cos"
model_name = var.model_name
minio_password = var.minio_password
minio_user = var.minio_user
}

# S3 module that deploy the Object Storage MinIO required by COS
module "minio" {
source = "git::https://github.com/canonical/observability//terraform/modules/minio"
model_name = var.model_name
channel = var.channel
minio_user = var.minio_user
minio_password = var.minio_password

loki = module.cos.loki
mimir = module.cos.mimir
tempo = module.cos.tempo
}

variable "channel" {
description = "Charms channel"
type = string
default = "latest/edge"
}

variable "model_name" {
description = "Model name"
type = string
}
variable "minio_user" {
description = "User for MinIO"
type = string
}

variable "minio_password" {
description = "Password for MinIO"
type = string
sensitive = true
}
```


Then execute:

```shell
$ tofu init

By default, this Terraform module will deploy each worker with `1` unit. To configure the module to run `x` units of any worker role, you can run `terraform apply -var="model_name=<MODEL_NAME>" -var="<ROLE>_units=<x>" -auto-approve`.
See each ... for the recommended scale for each role.
$ tofu apply -var='minio_password=Password' -var='minio_user=User' -var='model_name=test'
```
Loading