From c6fa8d4cec0848cd9b3962aa2ded42b4e12e1e87 Mon Sep 17 00:00:00 2001 From: jnicholsthru Date: Fri, 28 Feb 2020 15:01:53 -0500 Subject: [PATCH 1/2] Removing the ambassador_namespace_single variable --- README.md | 1 - daemonset.tf | 12 ++---------- deployment.tf | 12 ++---------- variables.tf | 5 ----- 4 files changed, 4 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index 30432c3..edbc969 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,6 @@ module "ambassador" { | ambassador_image | Ambassador_image Image | string | `quay.io/datawire/ambassador` | no | | ambassador_image_tag | Ambassador_image image tag | string | `0.40.2` | no | | ambassador_namespace_name | Set the AMBASSADOR_NAMESPACE environment variable | string | `metadata.namespace` | no | -| ambassador_namespace_single | Set the AMBASSADOR_SINGLE_NAMESPACE environment variable | string | `false` | no | | cluster_role_name | Set cluster rolne name, defaults to name | string | `` | no | | daemon_set | If true Create a daemonSet. By default Deployment controller will be created | string | `false` | no | | exporter_configuration | Prometheus exporter configuration in YALM format | string | `` | no | diff --git a/daemonset.tf b/daemonset.tf index 88814fd..57883a8 100644 --- a/daemonset.tf +++ b/daemonset.tf @@ -1,6 +1,6 @@ # Create a deployment for the service resource "kubernetes_daemonset" "this" { - count = "${var.daemon_set && ! var.ambassador_namespace_single ? 1 : 0}" + count = "${var.daemon_set ? 1 : 0}" metadata { name = "${var.name}" @@ -107,10 +107,6 @@ resource "kubernetes_daemonset" "this" { name = "AMBASSADOR_ID" value = "${var.ambassador_id}" }, - { - name = "AMBASSADOR_SINGLE_NAMESPACE" - value = "${var.ambassador_namespace_single}" - }, { name = "AMBASSADOR_DEBUG" value = "${var.ambassador_debug}" @@ -187,7 +183,7 @@ resource "kubernetes_daemonset" "this" { # Create a deployment for the service resource "kubernetes_daemonset" "this_namespace_single" { - count = "${var.daemon_set && var.ambassador_namespace_single ? 1 : 0}" + count = "${var.daemon_set ? 1 : 0}" metadata { name = "${var.name}" @@ -294,10 +290,6 @@ resource "kubernetes_daemonset" "this_namespace_single" { name = "AMBASSADOR_ID" value = "${var.ambassador_id}" }, - { - name = "AMBASSADOR_SINGLE_NAMESPACE" - value = "${var.ambassador_namespace_single}" - }, { name = "AMBASSADOR_DEBUG" value = "${var.ambassador_debug}" diff --git a/deployment.tf b/deployment.tf index b36b928..0c64925 100644 --- a/deployment.tf +++ b/deployment.tf @@ -1,6 +1,6 @@ # Create a deployment for the service resource "kubernetes_deployment" "this" { - count = "${! var.daemon_set && ! var.ambassador_namespace_single ? 1 : 0}" + count = "${! var.daemon_set ? 1 : 0}" metadata { name = "${var.name}" @@ -108,10 +108,6 @@ resource "kubernetes_deployment" "this" { name = "AMBASSADOR_ID" value = "${var.ambassador_id}" }, - { - name = "AMBASSADOR_SINGLE_NAMESPACE" - value = "${var.ambassador_namespace_single}" - }, { name = "AMBASSADOR_DEBUG" value = "${var.ambassador_debug}" @@ -188,7 +184,7 @@ resource "kubernetes_deployment" "this" { # Create a deployment for the service resource "kubernetes_deployment" "this_namespace_single" { - count = "${! var.daemon_set && var.ambassador_namespace_single ? 1 : 0}" + count = "${! var.daemon_set ? 1 : 0}" metadata { name = "${var.name}" @@ -296,10 +292,6 @@ resource "kubernetes_deployment" "this_namespace_single" { name = "AMBASSADOR_ID" value = "${var.ambassador_id}" }, - { - name = "AMBASSADOR_SINGLE_NAMESPACE" - value = "${var.ambassador_namespace_single}" - }, { name = "AMBASSADOR_DEBUG" value = "${var.ambassador_debug}" diff --git a/variables.tf b/variables.tf index 27f24f4..35628a0 100644 --- a/variables.tf +++ b/variables.tf @@ -96,11 +96,6 @@ variable "service_account_name" { description = "Service account to be used" } -variable "ambassador_namespace_single" { - description = "Set the AMBASSADOR_SINGLE_NAMESPACE environment variable" - default = false -} - variable "ambassador_namespace_name" { description = "Set the AMBASSADOR_NAMESPACE environment variable" default = "metadata.namespace" From 64d4bf99200becc31551f39817c487d85b69b133 Mon Sep 17 00:00:00 2001 From: jnicholsthru Date: Fri, 28 Feb 2020 15:05:32 -0500 Subject: [PATCH 2/2] Removing the single_namespace services entirely --- daemonset.tf | 183 ------------------------------------------------- deployment.tf | 184 -------------------------------------------------- 2 files changed, 367 deletions(-) diff --git a/daemonset.tf b/daemonset.tf index 57883a8..fc53e3e 100644 --- a/daemonset.tf +++ b/daemonset.tf @@ -180,186 +180,3 @@ resource "kubernetes_daemonset" "this" { depends_on = ["kubernetes_namespace.this", "kubernetes_service_account.this"] } - -# Create a deployment for the service -resource "kubernetes_daemonset" "this_namespace_single" { - count = "${var.daemon_set ? 1 : 0}" - - metadata { - name = "${var.name}" - namespace = "${var.namespace_name}" - } - - spec { - selector { - app = "${var.name}" - } - - template { - metadata { - annotations { - "sidecar.istio.io/inject" = false - "prometheus.io/port" = "9102" - "prometheus.io/scrape" = true - } - - labels = [ - { - terrafrom = "true" - }, - { - app = "${var.name}" - }, - ] - } - - spec = [ - { - service_account_name = "${var.name}" - restart_policy = "Always" - - volume = [ - { - name = "stats-exporter-mapping-config" - - config_map = { - name = "${var.name}-config" - - items = [ - { - key = "exporterConfiguration" - path = "mapping-config.yaml" - }, - ] - } - }, - ] - - container = [ - { - name = "${var.name}-statsd-sink" - image = "${var.exporter_image}:${var.exporter_image_tag}" - image_pull_policy = "${var.image_pull_policy}" - - args = [ - "-statsd.listen-address=:8125", - "-statsd.mapping-config=/statsd-exporter/mapping-config.yaml", - ] - - port = [ - { - container_port = 9102 - name = "metrics" - protocol = "TCP" - }, - { - container_port = 8125 - name = "listener" - protocol = "TCP" - }, - ] - - volume_mount = [ - { - mount_path = "/statsd-exporter/" - name = "stats-exporter-mapping-config" - read_only = true - }, - ] - }, - { - name = "${var.name}" - image = "${var.ambassador_image}:${var.ambassador_image_tag}" - image_pull_policy = "${var.image_pull_policy}" - termination_message_path = "/dev/termination-log" - - resources { - requests { - memory = "${var.resources_requests_memory}" - cpu = "${var.resources_requests_cpu}" - } - - limits { - memory = "${var.resources_limits_memory}" - cpu = "${var.resources_limits_cpu}" - } - } - - env = [ - { - name = "AMBASSADOR_ID" - value = "${var.ambassador_id}" - }, - { - name = "AMBASSADOR_DEBUG" - value = "${var.ambassador_debug}" - }, - { - name = "AMBASSADOR_NAMESPACE" - - value_from = { - field_ref = { - field_path = "${var.ambassador_namespace_name}" - } - } - }, - ] - - port = [ - { - name = "http" - container_port = 80 - protocol = "TCP" - }, - { - name = "https" - container_port = 443 - protocol = "TCP" - }, - { - name = "admin" - container_port = 8877 - protocol = "TCP" - }, - ] - - liveness_probe = [ - { - initial_delay_seconds = 3 - success_threshold = 1 - timeout_seconds = 1 - - http_get = [ - { - path = "/ambassador/v0/check_alive" - port = 8877 - scheme = "HTTP" - }, - ] - }, - ] - - readiness_probe = [ - { - initial_delay_seconds = 3 - success_threshold = 1 - timeout_seconds = 1 - - http_get = [ - { - path = "/ambassador/v0/check_ready" - port = 8877 - scheme = "HTTP" - }, - ] - }, - ] - }, - ] - }, - ] - } - } - - depends_on = ["kubernetes_namespace.this", "kubernetes_service_account.this"] -} diff --git a/deployment.tf b/deployment.tf index 0c64925..ead8c67 100644 --- a/deployment.tf +++ b/deployment.tf @@ -181,187 +181,3 @@ resource "kubernetes_deployment" "this" { depends_on = ["kubernetes_namespace.this", "kubernetes_service_account.this"] } - -# Create a deployment for the service -resource "kubernetes_deployment" "this_namespace_single" { - count = "${! var.daemon_set ? 1 : 0}" - - metadata { - name = "${var.name}" - namespace = "${var.namespace_name}" - } - - spec { - replicas = "${var.replica_count}" - - selector { - app = "${var.name}" - } - - template { - metadata { - annotations { - "sidecar.istio.io/inject" = false - "prometheus.io/port" = "9102" - "prometheus.io/scrape" = true - } - - labels { - terrafrom = "true" - } - - labels { - app = "${var.name}" - } - } - - spec = [ - { - service_account_name = "${local.service_account_name}" - restart_policy = "Always" - - volume = [ - { - name = "stats-exporter-mapping-config" - - config_map = { - name = "${var.name}-config" - - items = [ - { - key = "exporterConfiguration" - path = "mapping-config.yaml" - }, - ] - } - }, - ] - - container = [ - { - name = "${var.name}-statsd-sink" - image = "${var.exporter_image}:${var.exporter_image_tag}" - image_pull_policy = "${var.image_pull_policy}" - - args = [ - "-statsd.listen-address=:8125", - "-statsd.mapping-config=/statsd-exporter/mapping-config.yaml", - ] - - port = [ - { - container_port = 9102 - name = "metrics" - protocol = "TCP" - }, - { - container_port = 8125 - name = "listener" - protocol = "TCP" - }, - ] - - volume_mount = [ - { - mount_path = "/statsd-exporter/" - name = "stats-exporter-mapping-config" - read_only = true - }, - ] - }, - { - name = "${var.name}" - image = "${var.ambassador_image}:${var.ambassador_image_tag}" - image_pull_policy = "${var.image_pull_policy}" - termination_message_path = "/dev/termination-log" - - resources { - requests { - memory = "${var.resources_requests_memory}" - cpu = "${var.resources_requests_cpu}" - } - - limits { - memory = "${var.resources_limits_memory}" - cpu = "${var.resources_limits_cpu}" - } - } - - env = [ - { - name = "AMBASSADOR_ID" - value = "${var.ambassador_id}" - }, - { - name = "AMBASSADOR_DEBUG" - value = "${var.ambassador_debug}" - }, - { - name = "AMBASSADOR_NAMESPACE" - - value_from = { - field_ref = { - field_path = "${var.ambassador_namespace_name}" - } - } - }, - ] - - port = [ - { - name = "http" - container_port = 80 - protocol = "TCP" - }, - { - name = "https" - container_port = 443 - protocol = "TCP" - }, - { - name = "admin" - container_port = 8877 - protocol = "TCP" - }, - ] - - liveness_probe = [ - { - initial_delay_seconds = 3 - success_threshold = 1 - timeout_seconds = 1 - - http_get = [ - { - path = "/ambassador/v0/check_alive" - port = 8877 - scheme = "HTTP" - }, - ] - }, - ] - - readiness_probe = [ - { - initial_delay_seconds = 3 - success_threshold = 1 - timeout_seconds = 1 - - http_get = [ - { - path = "/ambassador/v0/check_ready" - port = 8877 - scheme = "HTTP" - }, - ] - }, - ] - }, - ] - }, - ] - } - } - - depends_on = ["kubernetes_namespace.this", "kubernetes_service_account.this"] -}