2021-05-27 18:58:24 +00:00
|
|
|
# Configure the Equinix Metal Provider
|
2022-04-27 17:34:13 +00:00
|
|
|
provider "metal" {
|
2019-04-24 05:22:01 +00:00
|
|
|
}
|
2019-01-31 15:24:36 +00:00
|
|
|
|
2022-04-27 17:34:13 +00:00
|
|
|
resource "metal_ssh_key" "k8s" {
|
2019-10-29 07:02:42 +00:00
|
|
|
count = var.public_key_path != "" ? 1 : 0
|
2019-01-31 15:24:36 +00:00
|
|
|
name = "kubernetes-${var.cluster_name}"
|
2019-10-29 07:02:42 +00:00
|
|
|
public_key = chomp(file(var.public_key_path))
|
2019-01-31 15:24:36 +00:00
|
|
|
}
|
|
|
|
|
2022-04-27 17:34:13 +00:00
|
|
|
resource "metal_device" "k8s_master" {
|
|
|
|
depends_on = [metal_ssh_key.k8s]
|
2019-10-29 07:02:42 +00:00
|
|
|
|
|
|
|
count = var.number_of_k8s_masters
|
|
|
|
hostname = "${var.cluster_name}-k8s-master-${count.index + 1}"
|
|
|
|
plan = var.plan_k8s_masters
|
|
|
|
facilities = [var.facility]
|
|
|
|
operating_system = var.operating_system
|
|
|
|
billing_cycle = var.billing_cycle
|
2022-04-27 17:34:13 +00:00
|
|
|
project_id = var.metal_project_id
|
2021-04-29 12:20:50 +00:00
|
|
|
tags = ["cluster-${var.cluster_name}", "k8s_cluster", "kube_control_plane", "etcd", "kube_node"]
|
2019-01-31 15:24:36 +00:00
|
|
|
}
|
|
|
|
|
2022-04-27 17:34:13 +00:00
|
|
|
resource "metal_device" "k8s_master_no_etcd" {
|
|
|
|
depends_on = [metal_ssh_key.k8s]
|
2019-10-29 07:02:42 +00:00
|
|
|
|
|
|
|
count = var.number_of_k8s_masters_no_etcd
|
|
|
|
hostname = "${var.cluster_name}-k8s-master-${count.index + 1}"
|
|
|
|
plan = var.plan_k8s_masters_no_etcd
|
|
|
|
facilities = [var.facility]
|
|
|
|
operating_system = var.operating_system
|
|
|
|
billing_cycle = var.billing_cycle
|
2022-04-27 17:34:13 +00:00
|
|
|
project_id = var.metal_project_id
|
2021-04-29 12:20:50 +00:00
|
|
|
tags = ["cluster-${var.cluster_name}", "k8s_cluster", "kube_control_plane"]
|
2019-01-31 15:24:36 +00:00
|
|
|
}
|
|
|
|
|
2022-04-27 17:34:13 +00:00
|
|
|
resource "metal_device" "k8s_etcd" {
|
|
|
|
depends_on = [metal_ssh_key.k8s]
|
2019-10-29 07:02:42 +00:00
|
|
|
|
|
|
|
count = var.number_of_etcd
|
|
|
|
hostname = "${var.cluster_name}-etcd-${count.index + 1}"
|
|
|
|
plan = var.plan_etcd
|
|
|
|
facilities = [var.facility]
|
|
|
|
operating_system = var.operating_system
|
|
|
|
billing_cycle = var.billing_cycle
|
2022-04-27 17:34:13 +00:00
|
|
|
project_id = var.metal_project_id
|
2019-01-31 15:24:36 +00:00
|
|
|
tags = ["cluster-${var.cluster_name}", "etcd"]
|
|
|
|
}
|
|
|
|
|
2022-04-27 17:34:13 +00:00
|
|
|
resource "metal_device" "k8s_node" {
|
|
|
|
depends_on = [metal_ssh_key.k8s]
|
2019-10-29 07:02:42 +00:00
|
|
|
|
|
|
|
count = var.number_of_k8s_nodes
|
|
|
|
hostname = "${var.cluster_name}-k8s-node-${count.index + 1}"
|
|
|
|
plan = var.plan_k8s_nodes
|
|
|
|
facilities = [var.facility]
|
|
|
|
operating_system = var.operating_system
|
|
|
|
billing_cycle = var.billing_cycle
|
2022-04-27 17:34:13 +00:00
|
|
|
project_id = var.metal_project_id
|
2021-04-29 12:20:50 +00:00
|
|
|
tags = ["cluster-${var.cluster_name}", "k8s_cluster", "kube_node"]
|
2019-01-31 15:24:36 +00:00
|
|
|
}
|
2019-10-29 07:02:42 +00:00
|
|
|
|