Skip to content

Commit

Permalink
Update docker tags. Remove template provider. Update modules versions.
Browse files Browse the repository at this point in the history
  • Loading branch information
bohdantverdyi committed Jan 24, 2023
1 parent 0dc9fb6 commit f956231
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 54 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Name | Description
--- | --- |
Terraform | >= v0.14.9
Helm provider | >= 2.1.0
Kubernetes provider | >= v2.1.0
Kubernetes provider | >= v2.0.1

## Usage
```
Expand Down
32 changes: 32 additions & 0 deletions locals.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
locals {
default = {
aws = {
template = "${path.module}/templates/aws_loki.yaml"
vars = {
S3_REGION = var.s3_region
S3_NAME = var.s3_name
}
},
azure = {
template = "${path.module}/templates/azure_loki.yaml"
vars = {
ACCOUNT_KEY = var.storage_account_access_key
ACCOUNT_NAME = var.storage_account_name
CONTAINER_NAME = var.container_name
}
},
gcp = {
template = "${path.module}/templates/gcp_loki.yaml"
vars = {
GCS_BUCKET_NAME = var.gcs_bucket_name
}
},
local = {
template = "${path.module}/templates/local_loki.yaml"
vars = {
LOCAL_STORAGE_PATH = "/data/loki/chunks"
RETENTION_PERIOD = var.local_storage_retention_period
}
}
}
}
14 changes: 3 additions & 11 deletions loki.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,6 @@ resource "kubernetes_service_account" "loki" {
}
}

# Generate config
data "template_file" "loki_config" {
for_each = local.default

template = local.default[var.provider_type].template
vars = local.default[var.provider_type].vars
}

# Add config to secret
resource "kubernetes_secret" "loki" {
metadata {
Expand All @@ -32,14 +24,14 @@ resource "kubernetes_secret" "loki" {
}

data = {
"loki.yaml" = data.template_file.loki_config[var.provider_type].rendered
"loki.yaml" = templatefile(local.default[var.provider_type].template, local.default[var.provider_type].vars)
}
}

# Deploy loki as stateful-set
module "loki_stateful_set" {
source = "terraform-iaac/stateful-set/kubernetes"
version = "1.3.1"
version = "1.4.2"

image = var.loki_docker_image
name = var.loki_name
Expand Down Expand Up @@ -124,7 +116,7 @@ module "loki_stateful_set" {

module "loki_service" {
source = "terraform-iaac/service/kubernetes"
version = "1.0.3"
version = "1.0.4"

app_name = module.loki_stateful_set.name
app_namespace = module.loki_stateful_set.namespace
Expand Down
9 changes: 3 additions & 6 deletions promtail.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ resource "kubernetes_config_map" "promtail" {
# Deploy per node
module "promtail_daemonset" {
source = "terraform-iaac/daemonset/kubernetes"
version = "1.3.1"
version = "1.4.2"

image = var.promtail_docker_image
name = var.promtail_name
Expand All @@ -30,12 +30,9 @@ module "promtail_daemonset" {

resources = var.promtail_resources

env_field = [
{
name = "HOSTNAME"
field_path = "spec.nodeName"
env_field = {
"HOSTNAME" = "spec.nodeName"
}
]
internal_port = var.promtail_internal_port

security_context = [
Expand Down
37 changes: 2 additions & 35 deletions variables.tf
Original file line number Diff line number Diff line change
@@ -1,36 +1,3 @@
locals {
default = {
aws = {
template = file("${path.module}/templates/aws_loki.yaml")
vars = {
S3_REGION = var.s3_region
S3_NAME = var.s3_name
}
},
azure = {
template = file("${path.module}/templates/azure_loki.yaml")
vars = {
ACCOUNT_KEY = var.storage_account_access_key
ACCOUNT_NAME = var.storage_account_name
CONTAINER_NAME = var.container_name
}
},
gcp = {
template = file("${path.module}/templates/gcp_loki.yaml")
vars = {
GCS_BUCKET_NAME = var.gcs_bucket_name
}
},
local = {
template = file("${path.module}/templates/local_loki.yaml")
vars = {
LOCAL_STORAGE_PATH = "/data/loki/chunks"
RETENTION_PERIOD = var.local_storage_retention_period
}
}
}
}

# Resources for services
variable "loki_resources" {
description = "(Optional) Compute Resources required by loki container. CPU/RAM requests"
Expand Down Expand Up @@ -58,7 +25,7 @@ variable "loki_name" {
default = "loki"
}
variable "loki_docker_image" {
default = "grafana/loki:2.5.0"
default = "grafana/loki:2.7.1"
}
variable "loki_termination_grace_period_seconds" {
default = 4800
Expand All @@ -84,7 +51,7 @@ variable "promtail_name" {
default = "promtail"
}
variable "promtail_docker_image" {
default = "grafana/promtail:2.5.0"
default = "grafana/promtail:2.7.1"
}

variable "promtail_internal_port" {
Expand Down
2 changes: 1 addition & 1 deletion versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ terraform {
required_version = ">= 0.14.1"

required_providers {
kubernetes = ">= 1.11.0"
kubernetes = ">= 2.0.1"
helm = ">= 2.1.0"
}
}

0 comments on commit f956231

Please sign in to comment.