From 3f38152c893fd2c298962690c618f5adef197f63 Mon Sep 17 00:00:00 2001 From: Jesus Vazquez Date: Fri, 8 Feb 2019 11:11:05 +0100 Subject: [PATCH 01/13] Define trickster requests and limits --- apps/prometheus/inputs.tf | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/apps/prometheus/inputs.tf b/apps/prometheus/inputs.tf index fa24fd7..db90470 100644 --- a/apps/prometheus/inputs.tf +++ b/apps/prometheus/inputs.tf @@ -109,3 +109,31 @@ variable "prometheus_io_scrape" { type = "string" default = "true" } + +################################################################################ +## Trickster +################################################################################ + +variable "trickster_memory_limit" { + description = "Memory limit for the kubernetes trickster pod" + type = "string" + default = "6Gi" +} + +variable "trickster_memory_request" { + description = "Memory request (minimum) for the kubernetes trickster pod" + type = "string" + default = "1Gi" +} + +variable "trickster_cpu_limit" { + description = "CPU limit for the trickster kubernetes pod" + type = "string" + default = "2" +} + +variable "trickster_cpu_request" { + description = "CPU request for the trickster kubernetes pod" + type = "string" + default = "1" +} \ No newline at end of file From 374dfbfaa53be230352533356a8db688b93b5a38 Mon Sep 17 00:00:00 2001 From: Jesus Vazquez Date: Fri, 8 Feb 2019 11:11:20 +0100 Subject: [PATCH 02/13] Add trickster volumes for configuration and boltdb --- apps/prometheus/replication-controller.tf | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/apps/prometheus/replication-controller.tf b/apps/prometheus/replication-controller.tf index 891556b..3fd58d1 100644 --- a/apps/prometheus/replication-controller.tf +++ b/apps/prometheus/replication-controller.tf @@ -72,6 +72,20 @@ resource "kubernetes_replication_controller" "prometheus" { } } + volume { + name = "trickster-config" + + config_map { + name = "trickster-config" + default_mode = 420 + } + } + + volume { + name = "trickster-boltdb-cache" + empty_dir {} + } + container { image = "weaveworks/watch:master-5b2a6e5" name = "config-watcher" From 228ad4db2ea289aaaa77af47c6becfd9ddcf1f39 Mon Sep 17 00:00:00 2001 From: Jesus Vazquez Date: Fri, 8 Feb 2019 11:13:04 +0100 Subject: [PATCH 03/13] Add trickster as a sidecar container to prometheus --- apps/prometheus/replication-controller.tf | 32 +++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/apps/prometheus/replication-controller.tf b/apps/prometheus/replication-controller.tf index 3fd58d1..b9cdc5b 100644 --- a/apps/prometheus/replication-controller.tf +++ b/apps/prometheus/replication-controller.tf @@ -180,6 +180,38 @@ resource "kubernetes_replication_controller" "prometheus" { timeout_seconds = "${var.readinessprobe_timeout_seconds}" } } + + container { + image = "tricksterio/trickster:0.1.7" + name = "trickster" + + resources { + requests { + memory = "${var.trickster_memory_request}" + cpu = "${var.trickster_cpu_request}" + } + + limits { + memory = "${var.trickster_memory_limit}" + cpu = "${var.trickster_cpu_limit}" + } + } + + port { + container_port = "${var.prometheus-port}" // Uses the same port as prometheus. + } + + volume_mount { + name = "trickster-config" + mount_path = "/etc/trickster/" + } + + volume_mount { + name = "trickster-boltdb-cache" + mount_path = "/tmp/trickster/" + } + + } } } } From ad325bc5fd7cab1d4c83a1f1e5cdb31fa4cdf691 Mon Sep 17 00:00:00 2001 From: Jesus Vazquez Date: Fri, 8 Feb 2019 12:16:43 +0100 Subject: [PATCH 04/13] Add trickster config map and inputs --- apps/prometheus/config-map.tf | 19 +++++++++++++++++++ apps/prometheus/inputs.tf | 5 +++++ 2 files changed, 24 insertions(+) diff --git a/apps/prometheus/config-map.tf b/apps/prometheus/config-map.tf index 2bc0a41..0f72b66 100644 --- a/apps/prometheus/config-map.tf +++ b/apps/prometheus/config-map.tf @@ -1,3 +1,7 @@ +################################################################################ +## Prometheus +################################################################################ + resource "kubernetes_config_map" "prometheus" { metadata { name = "prometheus-configuration" @@ -34,3 +38,18 @@ resource "k8s_manifest" "recordingrules" { content = "${data.template_file.recordingrules.rendered}" depends_on = ["kubernetes_config_map.prometheus"] } + +################################################################################ +## Trickster +################################################################################ + +resource "kubernetes_config_map" "trickster" { + metadata { + name = "trickster-config" + namespace = "${kubernetes_namespace.prometheus.metadata.0.name}" + } + + data { + trickster.yml = "${var.trickster_config}" + } +} \ No newline at end of file diff --git a/apps/prometheus/inputs.tf b/apps/prometheus/inputs.tf index db90470..a582aa6 100644 --- a/apps/prometheus/inputs.tf +++ b/apps/prometheus/inputs.tf @@ -114,6 +114,11 @@ variable "prometheus_io_scrape" { ## Trickster ################################################################################ +variable "trickster_config" { + description = "Valid rendered trickster.yaml config" + type = "string" +} + variable "trickster_memory_limit" { description = "Memory limit for the kubernetes trickster pod" type = "string" From 03cd62d4435c4552703fa252991662379754d560 Mon Sep 17 00:00:00 2001 From: Jesus Vazquez Date: Fri, 8 Feb 2019 15:16:02 +0100 Subject: [PATCH 05/13] Add variable for trickster port --- apps/prometheus/config-map.tf | 2 +- apps/prometheus/inputs.tf | 8 +++++++- apps/prometheus/replication-controller.tf | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/apps/prometheus/config-map.tf b/apps/prometheus/config-map.tf index 0f72b66..8b4cb9a 100644 --- a/apps/prometheus/config-map.tf +++ b/apps/prometheus/config-map.tf @@ -52,4 +52,4 @@ resource "kubernetes_config_map" "trickster" { data { trickster.yml = "${var.trickster_config}" } -} \ No newline at end of file +} diff --git a/apps/prometheus/inputs.tf b/apps/prometheus/inputs.tf index a582aa6..9d83c8a 100644 --- a/apps/prometheus/inputs.tf +++ b/apps/prometheus/inputs.tf @@ -114,6 +114,12 @@ variable "prometheus_io_scrape" { ## Trickster ################################################################################ +variable "trickster_port" { + description = "Port where trickster is going to listen. We're using the 9092 to avoid collisions with prometheus port. This port is unallocated by the community to avoid conflicts with kafka but we're not going to have this problem inside our replication controller." + type = "string" + default = "9092" +} + variable "trickster_config" { description = "Valid rendered trickster.yaml config" type = "string" @@ -141,4 +147,4 @@ variable "trickster_cpu_request" { description = "CPU request for the trickster kubernetes pod" type = "string" default = "1" -} \ No newline at end of file +} diff --git a/apps/prometheus/replication-controller.tf b/apps/prometheus/replication-controller.tf index b9cdc5b..efec185 100644 --- a/apps/prometheus/replication-controller.tf +++ b/apps/prometheus/replication-controller.tf @@ -198,7 +198,7 @@ resource "kubernetes_replication_controller" "prometheus" { } port { - container_port = "${var.prometheus-port}" // Uses the same port as prometheus. + container_port = "${var.trickster_port}" } volume_mount { From 8d54cb8e4cc8ddf84c98628ba97b0a98357f8706 Mon Sep 17 00:00:00 2001 From: Jesus Vazquez Date: Fri, 8 Feb 2019 16:46:26 +0100 Subject: [PATCH 06/13] Add arguments to the trickster container --- apps/prometheus/replication-controller.tf | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/apps/prometheus/replication-controller.tf b/apps/prometheus/replication-controller.tf index efec185..a500fc2 100644 --- a/apps/prometheus/replication-controller.tf +++ b/apps/prometheus/replication-controller.tf @@ -201,6 +201,11 @@ resource "kubernetes_replication_controller" "prometheus" { container_port = "${var.trickster_port}" } + args = [ + "--config=/etc/trickster/trickster.conf", + "--proxy-port=9092", + ] + volume_mount { name = "trickster-config" mount_path = "/etc/trickster/" From f4413d637a907d380e38de56e54161b2aad6c3a9 Mon Sep 17 00:00:00 2001 From: Jesus Vazquez Date: Fri, 8 Feb 2019 16:47:32 +0100 Subject: [PATCH 07/13] Update name of the trickster config map --- apps/prometheus/config-map.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/prometheus/config-map.tf b/apps/prometheus/config-map.tf index 8b4cb9a..fea166f 100644 --- a/apps/prometheus/config-map.tf +++ b/apps/prometheus/config-map.tf @@ -50,6 +50,6 @@ resource "kubernetes_config_map" "trickster" { } data { - trickster.yml = "${var.trickster_config}" + trickster.conf = "${var.trickster_config}" } } From 60a4dc7e30b2548d50b1836c0cf5efc132e34f91 Mon Sep 17 00:00:00 2001 From: Jesus Vazquez Date: Tue, 12 Feb 2019 10:21:21 +0100 Subject: [PATCH 08/13] Add trickster service --- apps/prometheus/service.tf | 23 ------------------ apps/prometheus/services.tf | 47 +++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 23 deletions(-) delete mode 100644 apps/prometheus/service.tf create mode 100644 apps/prometheus/services.tf diff --git a/apps/prometheus/service.tf b/apps/prometheus/service.tf deleted file mode 100644 index a10d837..0000000 --- a/apps/prometheus/service.tf +++ /dev/null @@ -1,23 +0,0 @@ -resource "kubernetes_service" "prometheus" { - metadata { - annotations { - prometheus_io_scrape = "${var.prometheus_io_scrape}" - } - - name = "${kubernetes_replication_controller.prometheus.metadata.0.name}" - namespace = "${kubernetes_namespace.prometheus.metadata.0.name}" - } - - spec { - selector { - app = "${kubernetes_replication_controller.prometheus.metadata.0.labels.app}" - } - - session_affinity = "ClientIP" - - port { - port = "${var.prometheus-port}" - target_port = "${var.prometheus-port}" - } - } -} diff --git a/apps/prometheus/services.tf b/apps/prometheus/services.tf new file mode 100644 index 0000000..61b55f9 --- /dev/null +++ b/apps/prometheus/services.tf @@ -0,0 +1,47 @@ +resource "kubernetes_service" "prometheus" { + metadata { + annotations { + prometheus_io_scrape = "${var.prometheus_io_scrape}" + } + + name = "${kubernetes_replication_controller.prometheus.metadata.0.name}" + namespace = "${kubernetes_namespace.prometheus.metadata.0.name}" + } + + spec { + selector { + app = "${kubernetes_replication_controller.prometheus.metadata.0.labels.app}" + } + + session_affinity = "ClientIP" + + port { + port = "${var.prometheus-port}" + target_port = "${var.prometheus-port}" + } + } +} + +resource "kubernetes_service" "trickster" { + metadata { + annotations { + prometheus_io_scrape = "${var.prometheus_io_scrape}" + } + + name = "trickster-${kubernetes_replication_controller.prometheus.metadata.0.name}" + namespace = "${kubernetes_namespace.prometheus.metadata.0.name}" + } + + spec { + selector { + app = "${kubernetes_replication_controller.prometheus.metadata.0.labels.app}" + } + + session_affinity = "ClientIP" + + port { + port = "${var.trickster_port}" + target_port = "${var.trickster_port}" + } + } +} \ No newline at end of file From c21474efda8990e6c3b7d862db4d033afb5bb966 Mon Sep 17 00:00:00 2001 From: Jesus Vazquez Date: Tue, 12 Feb 2019 12:25:59 +0100 Subject: [PATCH 09/13] Add prometheus_io_port annotation to trickster --- apps/prometheus/inputs.tf | 6 ++++++ apps/prometheus/services.tf | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/apps/prometheus/inputs.tf b/apps/prometheus/inputs.tf index 9d83c8a..297694a 100644 --- a/apps/prometheus/inputs.tf +++ b/apps/prometheus/inputs.tf @@ -120,6 +120,12 @@ variable "trickster_port" { default = "9092" } +variable "trickster_metrics_port" { + description = "Port where trickster exposes its metrics." + type = "string" + default = "8082" +} + variable "trickster_config" { description = "Valid rendered trickster.yaml config" type = "string" diff --git a/apps/prometheus/services.tf b/apps/prometheus/services.tf index 61b55f9..9cf7752 100644 --- a/apps/prometheus/services.tf +++ b/apps/prometheus/services.tf @@ -26,6 +26,7 @@ resource "kubernetes_service" "trickster" { metadata { annotations { prometheus_io_scrape = "${var.prometheus_io_scrape}" + prometheus_io_port = "${var.trickster_metrics_port}" } name = "trickster-${kubernetes_replication_controller.prometheus.metadata.0.name}" @@ -44,4 +45,4 @@ resource "kubernetes_service" "trickster" { target_port = "${var.trickster_port}" } } -} \ No newline at end of file +} From a5e67c5c17b261efd5742a1ef6956c10f4064add Mon Sep 17 00:00:00 2001 From: Jesus Vazquez Date: Tue, 12 Feb 2019 12:43:06 +0100 Subject: [PATCH 10/13] Expose trickster metrics port --- apps/prometheus/replication-controller.tf | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/apps/prometheus/replication-controller.tf b/apps/prometheus/replication-controller.tf index a500fc2..ef972e2 100644 --- a/apps/prometheus/replication-controller.tf +++ b/apps/prometheus/replication-controller.tf @@ -201,6 +201,11 @@ resource "kubernetes_replication_controller" "prometheus" { container_port = "${var.trickster_port}" } + port { + container_port = "${var.trickster_metrics_port}" + } + + args = [ "--config=/etc/trickster/trickster.conf", "--proxy-port=9092", From 68f6f7e5d163bda14fca09c2f95e2b93311059c4 Mon Sep 17 00:00:00 2001 From: Jesus Vazquez Date: Tue, 12 Feb 2019 12:53:41 +0100 Subject: [PATCH 11/13] Add the metrics port to the trickster service definition --- apps/prometheus/services.tf | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/apps/prometheus/services.tf b/apps/prometheus/services.tf index 9cf7752..79c8e60 100644 --- a/apps/prometheus/services.tf +++ b/apps/prometheus/services.tf @@ -44,5 +44,10 @@ resource "kubernetes_service" "trickster" { port = "${var.trickster_port}" target_port = "${var.trickster_port}" } + + port { + port = "${var.trickster_metrics_port}" + target_port = "${var.trickster_metrics_port}" + } } } From f9c3128b494cc60c88b3522f1862c2a3f304beb8 Mon Sep 17 00:00:00 2001 From: Jesus Vazquez Date: Tue, 12 Feb 2019 13:02:46 +0100 Subject: [PATCH 12/13] Give names to ports --- apps/prometheus/services.tf | 2 ++ 1 file changed, 2 insertions(+) diff --git a/apps/prometheus/services.tf b/apps/prometheus/services.tf index 79c8e60..daef58c 100644 --- a/apps/prometheus/services.tf +++ b/apps/prometheus/services.tf @@ -41,11 +41,13 @@ resource "kubernetes_service" "trickster" { session_affinity = "ClientIP" port { + name = "trickster-port" port = "${var.trickster_port}" target_port = "${var.trickster_port}" } port { + name = "trickster-metrics-port" port = "${var.trickster_metrics_port}" target_port = "${var.trickster_metrics_port}" } From 96a0728b5b11a71d111e213e0c0bd32f1fca5271 Mon Sep 17 00:00:00 2001 From: Jesus Vazquez Date: Tue, 12 Feb 2019 18:16:36 +0100 Subject: [PATCH 13/13] Add trickster outputs to the module --- apps/prometheus/outputs.tf | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/apps/prometheus/outputs.tf b/apps/prometheus/outputs.tf index 4cd2344..2f47a6a 100644 --- a/apps/prometheus/outputs.tf +++ b/apps/prometheus/outputs.tf @@ -12,3 +12,11 @@ output "prometheus_service_port" { output "prometheus_namespace" { value = "${kubernetes_namespace.prometheus.metadata.0.name}" } + +output "trickster_service_name" { + value = "${kubernetes_service.trickster.metadata.0.name}" +} + +output "trickster_service_port" { + value = "${var.trickster_port}" +} \ No newline at end of file