You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

63 lines
2.1 KiB

  1. # Configure the Packet Provider
  2. provider "packet" {
  3. version = "~> 2.0"
  4. }
  5. resource "packet_ssh_key" "k8s" {
  6. count = var.public_key_path != "" ? 1 : 0
  7. name = "kubernetes-${var.cluster_name}"
  8. public_key = chomp(file(var.public_key_path))
  9. }
  10. resource "packet_device" "k8s_master" {
  11. depends_on = [packet_ssh_key.k8s]
  12. count = var.number_of_k8s_masters
  13. hostname = "${var.cluster_name}-k8s-master-${count.index + 1}"
  14. plan = var.plan_k8s_masters
  15. facilities = [var.facility]
  16. operating_system = var.operating_system
  17. billing_cycle = var.billing_cycle
  18. project_id = var.packet_project_id
  19. tags = ["cluster-${var.cluster_name}", "k8s-cluster", "kube-master", "etcd", "kube-node"]
  20. }
  21. resource "packet_device" "k8s_master_no_etcd" {
  22. depends_on = [packet_ssh_key.k8s]
  23. count = var.number_of_k8s_masters_no_etcd
  24. hostname = "${var.cluster_name}-k8s-master-${count.index + 1}"
  25. plan = var.plan_k8s_masters_no_etcd
  26. facilities = [var.facility]
  27. operating_system = var.operating_system
  28. billing_cycle = var.billing_cycle
  29. project_id = var.packet_project_id
  30. tags = ["cluster-${var.cluster_name}", "k8s-cluster", "kube-master"]
  31. }
  32. resource "packet_device" "k8s_etcd" {
  33. depends_on = [packet_ssh_key.k8s]
  34. count = var.number_of_etcd
  35. hostname = "${var.cluster_name}-etcd-${count.index + 1}"
  36. plan = var.plan_etcd
  37. facilities = [var.facility]
  38. operating_system = var.operating_system
  39. billing_cycle = var.billing_cycle
  40. project_id = var.packet_project_id
  41. tags = ["cluster-${var.cluster_name}", "etcd"]
  42. }
  43. resource "packet_device" "k8s_node" {
  44. depends_on = [packet_ssh_key.k8s]
  45. count = var.number_of_k8s_nodes
  46. hostname = "${var.cluster_name}-k8s-node-${count.index + 1}"
  47. plan = var.plan_k8s_nodes
  48. facilities = [var.facility]
  49. operating_system = var.operating_system
  50. billing_cycle = var.billing_cycle
  51. project_id = var.packet_project_id
  52. tags = ["cluster-${var.cluster_name}", "k8s-cluster", "kube-node"]
  53. }