Skip to content

Commit

Permalink
adding IWE support
Browse files Browse the repository at this point in the history
  • Loading branch information
scotttyso committed Apr 12, 2022
1 parent 67bf245 commit 888c84d
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 14 deletions.
4 changes: 3 additions & 1 deletion modules/kubernetes_policies/locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ locals {
for key, value in v.virtual_infrastructure : {
cluster = value.cluster != null ? value.cluster : "default"
datastore = value.datastore != null ? value.datastore : "datastore1"
portgroup = value.portgroup != null ? value.portgroup : ["VM Network"]
interfaces = value.interfaces != null ? value.interfaces : ["VM Network"]
mtu = value.mtu != null ? value.mtu : 0
provider_name = value.provider_name != null ? value.provider_name : ""
resource_pool = value.resource_pool != null ? value.resource_pool : ""
type = value.type != null ? value.type : "vmware"
}
Expand Down
46 changes: 33 additions & 13 deletions modules/kubernetes_policies/virtual_machine_infra_config.tf
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ variable "virtual_machine_infra_config" {
{
cluster = "default"
datastore = "datastore1"
portgroup = ["VM Network"]
interfaces = ["VM Network"]
mtu = 0
provider_name = ""
resource_pool = ""
type = "vmware"
}
Expand All @@ -26,10 +28,13 @@ variable "virtual_machine_infra_config" {
* description - A description for the policy.
* tags - List of key/value Attributes to Assign to the Policy.
* target - Name of the IWE or vSphere Target discovered in Intersight, to provision the cluster to.
* vsphere_cluster - vSphere Cluster to assign the K8S Cluster Deployment.
* vsphere_datastore - vSphere Datastore to assign the K8S Cluster Deployment.r\n
* vsphere_portgroup - vSphere Port Group to assign the K8S Cluster Deployment.r\n
* vsphere_resource_pool - vSphere Resource Pool to assign the K8S Cluster Deployment.r\n
* virtual_infrastructure - List of Virtual Infrastructure Configuration Parameters
- cluster: (VMware) - vSphere Cluster to assign the K8S Cluster Deployment.
- datastore: (VMware) - vSphere Datastore to assign the K8S Cluster Deployment.
- interfaces: (Both) - vSphere Port Group to assign the K8S Cluster Deployment.
- mtu: (IWE) - MTU to assign to the Interface
- provider_name: (IWE) - In other words, to which named network from the Instructure Provider will the port be connected.
- resource_pool: (VMware) - vSphere Resource Pool to assign the K8S Cluster Deployment.
EOT
type = map(object(
{
Expand All @@ -38,11 +43,13 @@ variable "virtual_machine_infra_config" {
target = string
virtual_infrastructure = list(object(
{
cluster = string
datastore = string
portgroup = list(string)
cluster = optional(string)
datastore = optional(string)
interfaces = list(string)
mtu = optional(number)
provider_name = optional(string)
resource_pool = optional(string)
type = optional(string)
type = string
}
))
}
Expand Down Expand Up @@ -91,7 +98,7 @@ resource "intersight_kubernetes_virtual_machine_infra_config_policy" "virtual_ma
Passphrase = var.vsphere_password
ResourcePool = vm_config.value.resource_pool
})
interfaces = vm_config.value.portgroup
interfaces = vm_config.value.interfaces
object_type = "kubernetes.EsxiVirtualMachineInfraConfig"

}
Expand All @@ -100,12 +107,25 @@ resource "intersight_kubernetes_virtual_machine_infra_config_policy" "virtual_ma
for_each = { for k, v in each.value.virtual_infrastructure : k => v if v.type == "iwe" }
content {
additional_properties = jsonencode({
Datastore = vm_config.value.datastore
Cluster = vm_config.value.cluster
Mtu = vm_config.value.datastore
DiskMode = vm_config.value.disk_mode
Passphrase = var.vsphere_password
ResourcePool = vm_config.value.resource_pool
})
network_interfaces = vm_config.value.network_interfaces
interfaces = vm_config.value.interfaces
network_interfaces {
mtu = vm_config.value.mtu
name = vm_config.value.name
pools {
moid = vm_config.value.pool != "" ? ip_pools.pools[vm_config.value.pool].id : ""
}
provider_name = vm_config.value.provider_name
vrf {
moid = each.value.vrf != "" ? each.value.vrf : ""
object_type = "vrf.Vrf"
}
}
object_type = "kubernetes.HyperFlexApVirtualMachineInfraConfig"

}
}
Expand Down

0 comments on commit 888c84d

Please sign in to comment.