sguyennet / terraform-vsphere-kubespray

Deploy a Kubernetes HA cluster on VMware vSphere
https://blog.inkubate.io/install-and-manage-automatically-a-kubernetes-cluster-on-vmware-vsphere-with-terraform-and-kubespray/
Apache License 2.0
172 stars 88 forks source link

How can I deploy without resource pool? #29

Open Piyaphong opened 4 years ago

Piyaphong commented 4 years ago

I try to deploy k8s on vsphere. My Vsphere cluster is not have DRS license It's mean I cannot create resource pool. How can I modify configure to deploy k8s cluster.

pierreyves-lebrun commented 4 years ago

Same problem here, is there a way to use this project without a DRS license?

gregjan commented 4 years ago

Here is a diff that captures the two things I changed.. First I skipped the creation of a dedicated resource for k8s. Then I made all subsequent nodes have a parent of the "default" resource. So this eliminates the cluster resource in the middle that requires DRS.

diff --git a/vsphere-kubespray.tf b/vsphere-kubespray.tf
index 31d3f14..0ac714f 100644
--- a/vsphere-kubespray.tf
+++ b/vsphere-kubespray.tf
@@ -419,16 +419,16 @@ resource "vsphere_folder" "folder" {
 }

 # Create a resource pool for the Kubernetes VMs #
-resource "vsphere_resource_pool" "resource_pool" {
-  name                    = "${var.vsphere_resource_pool}"
-  parent_resource_pool_id = "${data.vsphere_compute_cluster.cluster.resource_pool_id}"
-}
+# resource "vsphere_resource_pool" "resource_pool" {
+#   name                    = "${var.vsphere_resource_pool}"
+#   parent_resource_pool_id = "${data.vsphere_compute_cluster.cluster.resource_pool_id}"
+# }

 # Create the Kubernetes master VMs #
 resource "vsphere_virtual_machine" "master" {
   count            = "${length(var.vm_master_ips)}"
   name             = "${var.vm_name_prefix}-master-${count.index}"
-  resource_pool_id = "${vsphere_resource_pool.resource_pool.id}"
+  resource_pool_id = "${data.vsphere_compute_cluster.cluster.resource_pool_id}"
   datastore_id     = "${data.vsphere_datastore.datastore.id}"
   folder           = "${vsphere_folder.folder.path}"

@@ -488,7 +488,7 @@ resource "vsphere_compute_cluster_vm_anti_affinity_rule" "master_anti_affinity_r
 resource "vsphere_virtual_machine" "worker" {
   count            = "${length(var.vm_worker_ips)}"
   name             = "${var.vm_name_prefix}-worker-${count.index}"
-  resource_pool_id = "${vsphere_resource_pool.resource_pool.id}"
+  resource_pool_id = "${data.vsphere_compute_cluster.cluster.resource_pool_id}"
   datastore_id     = "${data.vsphere_datastore.datastore.id}"
   folder           = "${vsphere_folder.folder.path}"

@@ -556,7 +556,7 @@ resource "vsphere_virtual_machine" "worker" {
 resource "vsphere_virtual_machine" "haproxy" {
   count            = "${length(var.vm_haproxy_ips)}"
   name             = "${var.vm_name_prefix}-haproxy-${count.index}"
-  resource_pool_id = "${vsphere_resource_pool.resource_pool.id}"
+  resource_pool_id = "${data.vsphere_compute_cluster.cluster.resource_pool_id}"
   datastore_id     = "${data.vsphere_datastore.datastore.id}"
   folder           = "${vsphere_folder.folder.path}"

-- 
pierreyves-lebrun commented 4 years ago

I eventually figured it out, thanks anyway!