Install MetalLB

This commit is contained in:
Khue Doan 2020-11-15 12:31:58 +07:00
parent 7dafb3709d
commit 52b6cfe8ae
2 changed files with 38 additions and 4 deletions

View File

@ -1,6 +1,12 @@
provider "rke" {
debug = true
debug = true
}
provider "helm" {
kubernetes {
config_path = "${path.root}/kube_config.yaml"
}
}
resource rke_cluster "cluster" {
dynamic "nodes" {
@ -12,7 +18,7 @@ resource rke_cluster "cluster" {
content {
address = nodes.value
user = "root"
role = [
role = [
"controlplane",
"etcd",
"worker"
@ -28,7 +34,7 @@ resource rke_cluster "cluster" {
content {
address = nodes.value
user = "root"
role = [
role = [
"worker"
]
ssh_key = file("~/.ssh/id_rsa")
@ -40,3 +46,26 @@ resource "local_file" "kube_config_yaml" {
filename = "${path.root}/kube_config.yaml"
content = rke_cluster.cluster.kube_config_yaml
}
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 {
name = "configInline"
value = yamlencode({
address-pools = {
name = "default"
protocol = "layer2"
addresses = [
"192.168.1.150-192.168.1.180"
]
}
})
}
}

View File

@ -12,8 +12,13 @@ terraform {
required_providers {
rke = {
source = "rancher/rke"
source = "rancher/rke"
version = "1.1.3"
}
helm = {
source = "hashicorp/helm"
version = "1.3.2"
}
}
}