Skip to content

Commit

Permalink
enabled support for the add-ons module
Browse files Browse the repository at this point in the history
  • Loading branch information
scotttyso committed Jul 28, 2021
1 parent 357b723 commit 5eaa9a9
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 63 deletions.
28 changes: 14 additions & 14 deletions modules/iks/backup/locals.backup
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ locals {
# Intersight and Tenant Variables
#__________________________________________________________

endpoint = data.terraform_remote_state.tenant.outputs.endpoint
org_name = data.terraform_remote_state.tenant.outputs.organization
org_moid = data.terraform_remote_state.tenant.outputs.org_moid
tags = data.terraform_remote_state.tenant.outputs.tags
endpoint = data.terraform_remote_state.organization.outputs.endpoint
organization = data.terraform_remote_state.organization.outputs.organization
org_moid = data.terraform_remote_state.organization.outputs.org_moid
tags = data.terraform_remote_state.organization.outputs.tags
#__________________________________________________________
#
# IKS Cluster Variables
Expand Down Expand Up @@ -44,18 +44,18 @@ locals {
}
#__________________________________________________________
#
# Assign Global Attributes from tenant Workspace
# Assign Global Attributes from organization Workspace
#__________________________________________________________

# IP Pool moid's
ip_pools = data.terraform_remote_state.tenant.outputs.ip_pools
ip_pools = data.terraform_remote_state.organization.outputs.ip_pools
# Kubernetes Policies moid's
k8s_addon_policies = data.terraform_remote_state.tenant.outputs.k8s_addon_policies
k8s_network_cidr = data.terraform_remote_state.tenant.outputs.k8s_network_cidr
k8s_nodeos_config = data.terraform_remote_state.tenant.outputs.k8s_nodeos_config
k8s_runtime_policies = data.terraform_remote_state.tenant.outputs.k8s_runtime_policies
k8s_trusted_registries = data.terraform_remote_state.tenant.outputs.k8s_trusted_registries
k8s_version_policies = data.terraform_remote_state.tenant.outputs.k8s_version_policies
k8s_vm_infra_config = data.terraform_remote_state.tenant.outputs.k8s_vm_infra_config
k8s_vm_instance_type = data.terraform_remote_state.tenant.outputs.k8s_vm_instance_type
k8s_addon_policies = data.terraform_remote_state.organization.outputs.k8s_addon_policies
k8s_network_cidr = data.terraform_remote_state.organization.outputs.k8s_network_cidr
k8s_nodeos_config = data.terraform_remote_state.organization.outputs.k8s_nodeos_config
k8s_runtime_policies = data.terraform_remote_state.organization.outputs.k8s_runtime_policies
k8s_trusted_registries = data.terraform_remote_state.organization.outputs.k8s_trusted_registries
k8s_version_policies = data.terraform_remote_state.organization.outputs.k8s_version_policies
k8s_vm_infra_config = data.terraform_remote_state.organization.outputs.k8s_vm_infra_config
k8s_vm_instance_type = data.terraform_remote_state.organization.outputs.k8s_vm_instance_type
}
28 changes: 14 additions & 14 deletions modules/iks/backup/locals.backup2
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ locals {
# Intersight and Tenant Variables
#__________________________________________________________

endpoint = data.terraform_remote_state.tenant.outputs.endpoint
organization = data.terraform_remote_state.tenant.outputs.organization
org_moid = data.terraform_remote_state.tenant.outputs.org_moid
tags = data.terraform_remote_state.tenant.outputs.tags
endpoint = data.terraform_remote_state.organization.outputs.endpoint
organization = data.terraform_remote_state.organization.outputs.organization
org_moid = data.terraform_remote_state.organization.outputs.org_moid
tags = data.terraform_remote_state.organization.outputs.tags
#__________________________________________________________
#
# IKS Cluster Variables
Expand Down Expand Up @@ -44,18 +44,18 @@ locals {
}
#__________________________________________________________
#
# Assign Global Attributes from tenant Workspace
# Assign Global Attributes from organization Workspace
#__________________________________________________________

# IP Pool moid's
ip_pools = data.terraform_remote_state.tenant.outputs.ip_pools
ip_pools = data.terraform_remote_state.organization.outputs.ip_pools
# Kubernetes Policies moid's
k8s_addon_policies = data.terraform_remote_state.tenant.outputs.k8s_addon_policies
k8s_network_cidr = data.terraform_remote_state.tenant.outputs.k8s_network_cidr
k8s_nodeos_config = data.terraform_remote_state.tenant.outputs.k8s_nodeos_config
k8s_runtime_policies = data.terraform_remote_state.tenant.outputs.k8s_runtime_policies
k8s_trusted_registries = data.terraform_remote_state.tenant.outputs.k8s_trusted_registries
k8s_version_policies = data.terraform_remote_state.tenant.outputs.k8s_version_policies
k8s_vm_infra_config = data.terraform_remote_state.tenant.outputs.k8s_vm_infra_config
k8s_vm_instance_type = data.terraform_remote_state.tenant.outputs.k8s_vm_instance_type
k8s_addon_policies = data.terraform_remote_state.organization.outputs.k8s_addon_policies
k8s_network_cidr = data.terraform_remote_state.organization.outputs.k8s_network_cidr
k8s_nodeos_config = data.terraform_remote_state.organization.outputs.k8s_nodeos_config
k8s_runtime_policies = data.terraform_remote_state.organization.outputs.k8s_runtime_policies
k8s_trusted_registries = data.terraform_remote_state.organization.outputs.k8s_trusted_registries
k8s_version_policies = data.terraform_remote_state.organization.outputs.k8s_version_policies
k8s_vm_infra_config = data.terraform_remote_state.organization.outputs.k8s_vm_infra_config
k8s_vm_instance_type = data.terraform_remote_state.organization.outputs.k8s_vm_instance_type
}
7 changes: 4 additions & 3 deletions modules/iks/locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ locals {
# Intersight and Tenant Variables
#__________________________________________________________

endpoint = data.terraform_remote_state.organization.outputs.endpoint
org_moid = data.terraform_remote_state.organization.outputs.org_moid
tags = data.terraform_remote_state.organization.outputs.tags
endpoint = data.terraform_remote_state.organization.outputs.endpoint
organization = data.terraform_remote_state.organization.outputs.organization
org_moid = data.terraform_remote_state.organization.outputs.org_moid
tags = data.terraform_remote_state.organization.outputs.tags
#__________________________________________________________
#
# IKS Cluster Variables
Expand Down
60 changes: 30 additions & 30 deletions modules/iks/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ module "iks_addon_profile" {
name = local.k8s_addon_policies["${a}"].name
}
]
cluster_moid = module.iks_cluster["${each.key}"].moid
name = "${var.organization}_${each.key}_addons"
org_moid = local.org_moid
tags = each.value.tags != [] ? each.value.tags : local.tags
iks_cluster_moid = module.iks_cluster[each.key].cluster_moid
name = "${var.organization}_${each.key}_addons"
org_moid = local.org_moid
tags = each.value.tags != [] ? each.value.tags : local.tags
}


Expand All @@ -61,19 +61,19 @@ module "control_plane_node_group" {
depends_on = [
module.iks_cluster,
]
source = "terraform-cisco-modules/imm/intersight//modules/k8s_node_group_profile"
for_each = local.iks_cluster
action = each.value.action_control_plane
description = each.value.description != "" ? each.value.description : "${var.organization}_${each.key} Control Plane Node Profile"
cluster_moid = module.iks_cluster[each.key].moid
desired_size = each.value.control_plane_desired_size
ip_pool_moid = local.ip_pools[each.value.ip_pool_moid]
labels = each.value.control_plane_k8s_labels
max_size = each.value.control_plane_max_size
name = "${var.organization}_${each.key}_control_plane"
node_type = each.value.worker_desired_size == "0" ? "ControlPlaneWorker" : "ControlPlane"
tags = each.value.tags != [] ? each.value.tags : local.tags
version_moid = local.k8s_version_policies[each.value.k8s_version_moid]
source = "terraform-cisco-modules/imm/intersight//modules/k8s_node_group_profile"
for_each = local.iks_cluster
action = each.value.action_control_plane
description = each.value.description != "" ? each.value.description : "${var.organization}_${each.key} Control Plane Node Profile"
desired_size = each.value.control_plane_desired_size
iks_profile_moid = module.iks_cluster[each.key].profile_moid
ip_pool_moid = local.ip_pools[each.value.ip_pool_moid]
labels = each.value.control_plane_k8s_labels
max_size = each.value.control_plane_max_size
name = "${var.organization}_${each.key}_control_plane"
node_type = each.value.worker_desired_size == "0" ? "ControlPlaneWorker" : "ControlPlane"
tags = each.value.tags != [] ? each.value.tags : local.tags
version_moid = local.k8s_version_policies[each.value.k8s_version_moid]
}

module "control_plane_vm_infra_provider" {
Expand All @@ -100,19 +100,19 @@ module "worker_node_group" {
depends_on = [
module.iks_cluster
]
source = "terraform-cisco-modules/imm/intersight//modules/k8s_node_group_profile"
for_each = local.iks_cluster
action = each.value.action_worker
description = each.value.description != "" ? each.value.description : "${var.organization}_${each.key} Worker Node Profile"
cluster_moid = module.iks_cluster[each.key].moid
desired_size = each.value.worker_desired_size
ip_pool_moid = local.ip_pools[each.value.ip_pool_moid]
labels = each.value.worker_k8s_labels
max_size = each.value.worker_max_size
name = "${var.organization}_${each.key}_worker"
node_type = "Worker"
tags = each.value.tags != [] ? each.value.tags : local.tags
version_moid = local.k8s_version_policies[each.value.k8s_version_moid]
source = "terraform-cisco-modules/imm/intersight//modules/k8s_node_group_profile"
for_each = local.iks_cluster
action = each.value.action_worker
description = each.value.description != "" ? each.value.description : "${var.organization}_${each.key} Worker Node Profile"
iks_profile_moid = module.iks_cluster[each.key].profile_moid
desired_size = each.value.worker_desired_size
ip_pool_moid = local.ip_pools[each.value.ip_pool_moid]
labels = each.value.worker_k8s_labels
max_size = each.value.worker_max_size
name = "${var.organization}_${each.key}_worker"
node_type = "Worker"
tags = each.value.tags != [] ? each.value.tags : local.tags
version_moid = local.k8s_version_policies[each.value.k8s_version_moid]
}

module "worker_vm_infra_provider" {
Expand Down
7 changes: 6 additions & 1 deletion modules/iks/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,10 @@ output "tags" {

output "iks_cluster" {
description = "moid of the IKS Cluster."
value = { for v in sort(keys(module.iks_cluster)) : v => module.iks_cluster[v].moid }
value = {
for v in sort(keys(module.iks_cluster)) : v => {
cluster_moid = module.iks_cluster[v].cluster_moid
profile_moid = module.iks_cluster[v].profile_moid
}
}
}
24 changes: 23 additions & 1 deletion modules/tfe/terraform.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,29 @@ k8s_vm_instance_type = {

iks_cluster = {
cluster01 = {
action_cluster = "Deploy" # Options are {Delete|Deploy|Ready|No-op|Unassign}.
action_cluster = "No-op" # Options are {Delete|Deploy|Ready|No-op|Unassign}.
control_plane_desired_size = 1
control_plane_max_size = 3
ip_pool_moid = "pool_1"
k8s_addon_policy_moid = ["ccp-monitor", "kubernetes-dashboard"]
k8s_network_cidr_moid = "default"
k8s_nodeos_config_moid = "default"
k8s_registry_moid = "default"
k8s_runtime_moid = ""
k8s_version_moid = "default"
k8s_vm_infra_moid = "default"
k8s_vm_instance_type_ctrl_plane = "small"
k8s_vm_instance_type_worker = "small"
load_balancers = 3
ssh_key = "ssh_key_1"
ssh_user = "iksadmin"
tags = []
wait_for_complete = false
worker_desired_size = 1
worker_max_size = 4
}
cluster02 = {
action_cluster = "No-op" # Options are {Delete|Deploy|Ready|No-op|Unassign}.
control_plane_desired_size = 1
control_plane_max_size = 3
ip_pool_moid = "pool_1"
Expand Down

0 comments on commit 5eaa9a9

Please sign in to comment.