2019-01-31 23:24:36 +08:00
|
|
|
# Configure the Packet Provider
|
2019-04-24 13:22:01 +08:00
|
|
|
provider "packet" {
|
|
|
|
version = "~> 2.0"
|
|
|
|
}
|
2019-01-31 23:24:36 +08:00
|
|
|
|
|
|
|
resource "packet_ssh_key" "k8s" {
|
2019-10-29 15:02:42 +08:00
|
|
|
count = var.public_key_path != "" ? 1 : 0
|
2019-01-31 23:24:36 +08:00
|
|
|
name = "kubernetes-${var.cluster_name}"
|
2019-10-29 15:02:42 +08:00
|
|
|
public_key = chomp(file(var.public_key_path))
|
2019-01-31 23:24:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
resource "packet_device" "k8s_master" {
|
2019-10-29 15:02:42 +08:00
|
|
|
depends_on = [packet_ssh_key.k8s]
|
|
|
|
|
|
|
|
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
|
|
|
|
project_id = var.packet_project_id
|
2019-01-31 23:24:36 +08:00
|
|
|
tags = ["cluster-${var.cluster_name}", "k8s-cluster", "kube-master", "etcd", "kube-node"]
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "packet_device" "k8s_master_no_etcd" {
|
2019-10-29 15:02:42 +08:00
|
|
|
depends_on = [packet_ssh_key.k8s]
|
|
|
|
|
|
|
|
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
|
|
|
|
project_id = var.packet_project_id
|
2019-01-31 23:24:36 +08:00
|
|
|
tags = ["cluster-${var.cluster_name}", "k8s-cluster", "kube-master"]
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "packet_device" "k8s_etcd" {
|
2019-10-29 15:02:42 +08:00
|
|
|
depends_on = [packet_ssh_key.k8s]
|
|
|
|
|
|
|
|
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
|
|
|
|
project_id = var.packet_project_id
|
2019-01-31 23:24:36 +08:00
|
|
|
tags = ["cluster-${var.cluster_name}", "etcd"]
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "packet_device" "k8s_node" {
|
2019-10-29 15:02:42 +08:00
|
|
|
depends_on = [packet_ssh_key.k8s]
|
|
|
|
|
|
|
|
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
|
|
|
|
project_id = var.packet_project_id
|
2019-01-31 23:24:36 +08:00
|
|
|
tags = ["cluster-${var.cluster_name}", "k8s-cluster", "kube-node"]
|
|
|
|
}
|
2019-10-29 15:02:42 +08:00
|
|
|
|