khuedoan-homelab/platform/main.tf

88 lines
1.6 KiB
Terraform
Raw Normal View History

2020-11-04 22:46:38 +07:00
provider "rke" {
2020-11-15 12:31:58 +07:00
debug = true
}
provider "kubernetes" {
config_path = "${path.root}/kube_config.yaml"
}
2020-11-15 12:31:58 +07:00
provider "helm" {
kubernetes {
config_path = "${path.root}/kube_config.yaml"
2020-11-04 22:46:38 +07:00
}
2020-11-15 12:31:58 +07:00
}
2020-11-04 22:46:38 +07:00
resource rke_cluster "cluster" {
dynamic "nodes" {
for_each = [
2020-11-15 00:01:57 +07:00
"192.168.1.110",
"192.168.1.111",
"192.168.1.112"
2020-11-04 22:46:38 +07:00
]
content {
address = nodes.value
user = "root"
2020-11-15 12:31:58 +07:00
role = [
2020-11-05 01:09:18 +07:00
"controlplane",
"etcd",
"worker"
]
ssh_key = file("~/.ssh/id_rsa")
}
}
dynamic "nodes" {
for_each = [
2020-11-15 00:01:57 +07:00
"192.168.1.113"
2020-11-05 01:09:18 +07:00
]
content {
address = nodes.value
user = "root"
2020-11-15 12:31:58 +07:00
role = [
2020-11-05 01:09:18 +07:00
"worker"
2020-11-04 22:46:38 +07:00
]
ssh_key = file("~/.ssh/id_rsa")
}
}
ingress {
provider = "none"
}
2020-11-04 22:46:38 +07:00
}
2020-11-05 01:09:18 +07:00
resource "local_file" "kube_config_yaml" {
filename = "${path.root}/kube_config.yaml"
2020-11-04 22:46:38 +07:00
content = rke_cluster.cluster.kube_config_yaml
2020-10-28 23:30:16 +07:00
}
2020-11-15 12:31:58 +07:00
resource "helm_release" "metallb" {
name = "metallb"
repository = "https://charts.bitnami.com/bitnami"
chart = "metallb"
version = "1.0.1"
namespace = "metallb-system"
create_namespace = true
set {
2020-11-15 12:48:00 +07:00
name = "configInline"
2020-11-15 12:47:30 +07:00
value = <<EOT
address-pools:
- name: default
protocol: layer2
addresses:
- 192.168.1.150-192.168.1.180
EOT
2020-11-15 12:31:58 +07:00
}
}
2020-11-15 23:47:40 +07:00
resource "helm_release" "prometheus" {
name = "kube-prometheus-stack"
repository = "https://prometheus-community.github.io/helm-charts"
chart = "kube-prometheus-stack"
version = "11.1.2"
namespace = "monitoring-system"
create_namespace = true
}