Skip to content

Commit

Permalink
Add loki and promtail tolerations
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmytro Ostapenko committed Jun 2, 2023
1 parent 970ddf9 commit a3b9150
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 16 deletions.
28 changes: 15 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,21 +83,23 @@ loki_resources | Compute Resources required by loki container. CPU/RAM requests
promtail_resources | Compute Resources required by promtail container. CPU/RAM requests | `map` | <pre>{<br> request_cpu = "20m"<br> request_memory = "50Mi"<br>}</pre> | <pre>{<br> request_cpu = "20m"<br> request_memory = "50Mi"<br>}</pre> | no

### Loki variables
Name | Description | Type | Default | Example | Required
--- | --- | --- | --- |--- |---
loki_name | Loki application name | `string` | `loki` | n/a | no
loki_docker_image | Image for Loki container | `string` | `grafana/loki:2.3.0` | n/a | no
loki_termination_grace_period_seconds | Grace period applies to the total time it takes for both the PreStop hook to execute and for the Container to stop normally | `integer` | `4800` | n/a | no
loki_port | Port mapping to kubernetes service | <pre>list(object({<br> name = string<br> internal_port = integer<br> external_port = integer<br>}))</pre> | <pre>\[<br> {<br> name = "http-metrics"<br> internal_port = 3100<br> external_port = 3100<br> }<br>]</pre> | n/a | no
loki_node_selector | Select node to deploy loki stack | `map` | `null` | <pre>{<br> (local.node_spot_label_key) = false<br> (local.node_multi_az_label_key) = true<br>}</pre> | no
loki_service_account_annotations | Add additional account annotations to Loki service account | `map` | `ReadWriteMany` | n/a | no
Name | Description | Type | Default | Example | Required
--- |-----------------------------------------------------------------------------------------------------------------------------| --- |--------------------------------------------------------------------------------------------------------------------------------|--- |---
loki_name | Loki application name | `string` | `loki` | n/a | no
loki_docker_image | Image for Loki container | `string` | `grafana/loki:2.3.0` | n/a | no
loki_termination_grace_period_seconds | Grace period applies to the total time it takes for both the PreStop hook to execute and for the Container to stop normally | `integer` | `4800` | n/a | no
loki_port | Port mapping to kubernetes service | <pre>list(object({<br> name = string<br> internal_port = integer<br> external_port = integer<br>}))</pre> | <pre>\[<br> {<br> name = "http-metrics"<br> internal_port = 3100<br> external_port = 3100<br> }<br>]</pre> | n/a | no
loki_node_selector | Select node to deploy loki stack | `map` | `null` | <pre>{<br> (local.node_spot_label_key) = false<br> (local.node_multi_az_label_key) = true<br>}</pre> | no
loki_toleration | Loki Pod node tolerations | <pre>list(object({<br> effect = string // (Optional)<br> key = string // (Optional)<br> operator = string // (Optional)<br> toleration_seconds = number // (Optional)<br> value = string // (Optional)<br> }))</pre> | `[]` | <pre>[<br> {<br> effect = "NoSchedule"<br> key = "gpu"<br> operator = "Equal"<br> value = "true"<br> }<br>]</pre> | no |
loki_service_account_annotations | Add additional account annotations to Loki service account | `map` | `ReadWriteMany` | n/a | no

### Promtail
Name | Description | Type | Default | Example | Required
--- | --- | --- | --- |--- |---
promtail_name | Promtail application name | `string` | `monitoring-alertmanager-pv` | n/a | no
promtail_docker_image | Image for Promtail container | `string` | `2Gi` | n/a | no
promtail_internal_port | Port mapping to daemon-set | <pre>list(object({<br> name = string<br> internal_port = integer<br>}))</pre> | <pre>\[<br> {<br> name = "http-metrics"<br> internal_port = 3100<br> }<br>]</pre> | n/a | no
Name | Description | Type | Default | Example | Required
--- |-------------------------------| --- | --- |--- |---
promtail_name | Promtail application name | `string` | `monitoring-alertmanager-pv` | n/a | no
promtail_docker_image | Image for Promtail container | `string` | `2Gi` | n/a | no
promtail_internal_port | Port mapping to daemon-set | <pre>list(object({<br> name = string<br> internal_port = integer<br>}))</pre> | <pre>\[<br> {<br> name = "http-metrics"<br> internal_port = 3100<br> }<br>]</pre> | n/a | no
promtail_toleration | Promtail pod node tolerations | <pre>list(object({<br> effect = string // (Optional)<br> key = string // (Optional)<br> operator = string // (Optional)<br> toleration_seconds = number // (Optional)<br> value = string // (Optional)<br> }))</pre> | `[]` | <pre>[<br> {<br> effect = "NoSchedule"<br> key = "gpu"<br> operator = "Equal"<br> value = "true"<br> }<br>]</pre> | no |

### Storage variables
Name | Description | Type | Default | Example | Required
Expand Down
1 change: 1 addition & 0 deletions loki.tf
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ module "loki_stateful_set" {
args = ["-config.file=/etc/loki/loki.yaml"]

node_selector = var.loki_node_selector
toleration = var.loki_toleration
internal_port = var.loki_port

security_context = [
Expand Down
9 changes: 6 additions & 3 deletions promtail.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,15 @@ module "promtail_daemonset" {
name = var.promtail_name
namespace = var.create_namespace ? kubernetes_namespace.namespace[0].id : var.namespace

args = ["-config.file=/etc/promtail/promtail.yaml", "-client.url=http://${module.loki_service.name}:3100/loki/api/v1/push"]
args = [
"-config.file=/etc/promtail/promtail.yaml", "-client.url=http://${module.loki_service.name}:3100/loki/api/v1/push"
]

service_account_name = kubernetes_service_account.promtail.metadata[0].name
service_account_token = true

resources = var.promtail_resources
resources = var.promtail_resources
toleration = var.promtail_toleration

env_field = {
"HOSTNAME" = "spec.nodeName"
Expand All @@ -50,7 +53,7 @@ module "promtail_daemonset" {
period_seconds = 10
success_threshold = 1
timeout_seconds = 1
http_get = {
http_get = {
path = "/ready"
port = var.promtail_internal_port.0.name
scheme = "HTTP"
Expand Down
7 changes: 7 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ variable "loki_port" {
variable "loki_node_selector" {
default = null
}
variable "loki_toleration" {
default = []
}
variable "loki_service_account_annotations" {
default = {}
}
Expand All @@ -90,6 +93,10 @@ variable "promtail_internal_port" {
]
}

variable "promtail_toleration" {
default = []
}


variable "provider_type" {
description = "Choose what type of provider you want (aws, azure, gcp and local)" // SUPPORTS ONLY: aws, azure, gcp and local
Expand Down

0 comments on commit a3b9150

Please sign in to comment.