This repository was archived by the owner on Feb 4, 2020. It is now read-only.
forked from poseidon/terraform-render-bootstrap
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathconditional.tf
More file actions
111 lines (99 loc) · 5.3 KB
/
Copy pathconditional.tf
File metadata and controls
111 lines (99 loc) · 5.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# Assets generated only when certain options are chosen
# Populate flannel chart values file named flannel.yaml.
resource "local_file" "flannel" {
count = var.networking == "flannel" ? 1 : 0
content = templatefile("${path.module}/resources/charts/flannel.yaml",{
flannel_image = "${var.container_images["flannel"]}${var.container_arch}"
flannel_cni_image = var.container_images["flannel_cni"]
pod_cidr = var.pod_cidr
})
filename = "${var.asset_dir}/charts/kube-system/flannel.yaml"
}
# Populate flannel chart.
# TODO: Currently, there is no way in Terraform to copy local directory, so we use `template_dir` for it.
# The downside is, that any Terraform templating syntax stored in this directory will be evaluated, which may bring unexpected results.
resource "template_dir" "flannel" {
count = var.networking == "flannel" ? 1 : 0
source_dir = "${replace(path.module, path.cwd, ".")}/resources/charts/flannel"
destination_dir = "${var.asset_dir}/charts/kube-system/flannel"
}
# Render flannel.yaml for flannel chart.
data "template_file" "flannel" {
count = var.networking == "flannel" ? 1 : 0
template = "${file("${path.module}/resources/charts/flannel.yaml")}"
vars = {
flannel_image = "${var.container_images["flannel"]}${var.container_arch}"
flannel_cni_image = var.container_images["flannel_cni"]
pod_cidr = var.pod_cidr
}
}
# Populate calico chart values file named calico.yaml.
resource "local_file" "calico" {
count = var.networking == "calico" ? 1 : 0
content = templatefile("${path.module}/resources/charts/calico.yaml",{
calico_image = var.container_images["calico"]
calico_cni_image = var.container_images["calico_cni"]
network_mtu = var.network_mtu
network_encapsulation = indent(2, var.network_encapsulation == "vxlan" ? "vxlanMode: Always" : "ipipMode: Always")
ipip_enabled = var.network_encapsulation == "ipip" ? true : false
ipip_readiness = var.network_encapsulation == "ipip" ? indent(16, "- --bird-ready") : ""
vxlan_enabled = var.network_encapsulation == "vxlan" ? true : false
network_ip_autodetection_method = var.network_ip_autodetection_method
pod_cidr = var.pod_cidr
enable_reporting = var.enable_reporting
})
filename = "${var.asset_dir}/charts/kube-system/calico.yaml"
}
# Populate calico chart.
# TODO: Currently, there is no way in Terraform to copy local directory, so we use `template_dir` for it.
# The downside is, that any Terraform templating syntax stored in this directory will be evaluated, which may bring unexpected results.
resource "template_dir" "calico" {
count = var.networking == "calico" ? 1 : 0
source_dir = "${replace(path.module, path.cwd, ".")}/resources/charts/calico"
destination_dir = "${var.asset_dir}/charts/kube-system/calico"
}
# Render calico.yaml for calico chart.
data "template_file" "calico" {
count = var.networking == "calico" ? 1 : 0
template = "${file("${path.module}/resources/charts/calico.yaml")}"
vars = {
calico_image = var.container_images["calico"]
calico_cni_image = var.container_images["calico_cni"]
network_mtu = var.network_mtu
network_encapsulation = indent(2, var.network_encapsulation == "vxlan" ? "vxlanMode: Always" : "ipipMode: Always")
ipip_enabled = var.network_encapsulation == "ipip" ? true : false
ipip_readiness = var.network_encapsulation == "ipip" ? indent(16, "- --bird-ready") : ""
vxlan_enabled = var.network_encapsulation == "vxlan" ? true : false
network_ip_autodetection_method = var.network_ip_autodetection_method
pod_cidr = var.pod_cidr
enable_reporting = var.enable_reporting
}
}
# Populate kube-router chart values file named kube-router.yaml.
resource "local_file" "kube-router" {
count = var.networking == "kube-router" ? 1 : 0
content = templatefile("${path.module}/resources/charts/kube-router.yaml",{
kube_router_image = var.container_images["kube_router"]
flannel_cni_image = var.container_images["flannel_cni"]
network_mtu = var.network_mtu
})
filename = "${var.asset_dir}/charts/kube-system/kube-router.yaml"
}
# Populate kube-router chart.
# TODO: Currently, there is no way in Terraform to copy local directory, so we use `template_dir` for it.
# The downside is, that any Terraform templating syntax stored in this directory will be evaluated, which may bring unexpected results.
resource "template_dir" "kube-router" {
count = var.networking == "kube-router" ? 1 : 0
source_dir = "${replace(path.module, path.cwd, ".")}/resources/charts/kube-router"
destination_dir = "${var.asset_dir}/charts/kube-system/kube-router"
}
# Render kube-router.yaml for kube-router chart.
data "template_file" "kube-router" {
count = var.networking == "kube-router" ? 1 : 0
template = "${file("${path.module}/resources/charts/kube-router.yaml")}"
vars = {
kube_router_image = var.container_images["kube_router"]
flannel_cni_image = var.container_images["flannel_cni"]
network_mtu = var.network_mtu
}
}