Skip to content

Commit

Permalink
Revert "removing count/environments variable dependencies"
Browse files Browse the repository at this point in the history
This reverts commit 9355710.
  • Loading branch information
yaman committed Sep 3, 2019
1 parent 1e07f9d commit c10c96b
Showing 1 changed file with 20 additions and 19 deletions.
39 changes: 20 additions & 19 deletions main.tf
Original file line number Diff line number Diff line change
@@ -1,33 +1,35 @@
resource "kubernetes_config_map" "nginx_configuration" {
count = length(var.environments)
metadata {
name = "nginx-configuration"
namespace = "${var.namespace}"
namespace = var.environments[count.index]
labels = { "app.kubernetes.io/name" = "ingress-nginx", "app.kubernetes.io/part-of" = "ingress-nginx" }
}
}

resource "kubernetes_config_map" "tcp_services" {
count = length(var.environments)
metadata {
name = "tcp-services"
namespace = "${var.namespace}"
namespace = var.environments[count.index]
labels = { "app.kubernetes.io/name" = "ingress-nginx", "app.kubernetes.io/part-of" = "ingress-nginx" }
}
}

resource "kubernetes_config_map" "udp_services" {

count = length(var.environments)
metadata {
name = "udp-services"
namespace = "${var.namespace}"
namespace = var.environments[count.index]
labels = { "app.kubernetes.io/name" = "ingress-nginx", "app.kubernetes.io/part-of" = "ingress-nginx" }
}
}

resource "kubernetes_service_account" "nginx_ingress_serviceaccount" {

count = length(var.environments)
metadata {
name = "nginx-ingress-serviceaccount"
namespace = "${var.namespace}"
namespace = var.environments[count.index]
labels = { "app.kubernetes.io/name" = "ingress-nginx", "app.kubernetes.io/part-of" = "ingress-nginx" }
}
}
Expand Down Expand Up @@ -70,10 +72,10 @@ resource "kubernetes_cluster_role" "nginx_ingress_clusterrole" {
}

resource "kubernetes_role" "nginx_ingress_role" {

count = length(var.environments)
metadata {
name = "nginx-ingress-role"
namespace = "${var.namespace}"
namespace = var.environments[count.index]
labels = { "app.kubernetes.io/name" = "ingress-nginx", "app.kubernetes.io/part-of" = "ingress-nginx" }
}
rule {
Expand All @@ -100,16 +102,16 @@ resource "kubernetes_role" "nginx_ingress_role" {
}

resource "kubernetes_role_binding" "nginx_ingress_role_nisa_binding" {

count = length(var.environments)
metadata {
name = "nginx-ingress-role-nisa-binding"
namespace = "${var.namespace}"
namespace = var.environments[count.index]
labels = { "app.kubernetes.io/name" = "ingress-nginx", "app.kubernetes.io/part-of" = "ingress-nginx" }
}
subject {
kind = "ServiceAccount"
name = "nginx-ingress-serviceaccount"
namespace = "${var.namespace}"
namespace = var.environments[count.index]
}
role_ref {
api_group = "rbac.authorization.k8s.io"
Expand All @@ -119,15 +121,15 @@ resource "kubernetes_role_binding" "nginx_ingress_role_nisa_binding" {
}

resource "kubernetes_cluster_role_binding" "nginx_ingress_clusterrole_nisa_binding" {

count = length(var.environments)
metadata {
name = "${var.namespace}-nginx-ingress-clusterrole-nisa-binding"
name = "${var.environments[count.index]}-nginx-ingress-clusterrole-nisa-binding"
labels = { "app.kubernetes.io/name" = "ingress-nginx", "app.kubernetes.io/part-of" = "ingress-nginx" }
}
subject {
kind = "ServiceAccount"
name = "nginx-ingress-serviceaccount"
namespace = "${var.namespace}"
namespace = var.environments[count.index]
}
role_ref {
api_group = "rbac.authorization.k8s.io"
Expand All @@ -137,10 +139,10 @@ resource "kubernetes_cluster_role_binding" "nginx_ingress_clusterrole_nisa_bindi
}

resource "kubernetes_deployment" "nginx_ingress_controller" {

count = length(var.environments)
metadata {
name = "nginx-ingress-controller"
namespace = "${var.namespace}"
namespace = var.environments[count.index]
labels = { "app.kubernetes.io/name" = "ingress-nginx", "app.kubernetes.io/part-of" = "ingress-nginx" }
}
spec {
Expand Down Expand Up @@ -222,10 +224,10 @@ resource "kubernetes_deployment" "nginx_ingress_controller" {
}

resource "kubernetes_service" "ingress_nginx" {

count = length(var.environments)
metadata {
name = "ingress-nginx"
namespace = "${var.namespace}"
namespace = var.environments[count.index]
labels = { "app.kubernetes.io/name" = "ingress-nginx", "app.kubernetes.io/part-of" = "ingress-nginx" }
}
spec {
Expand All @@ -245,4 +247,3 @@ resource "kubernetes_service" "ingress_nginx" {
}
}

version = "0.0.2"

0 comments on commit c10c96b

Please sign in to comment.