Skip to content

Commit

Permalink
fix: address review suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
caroldelwing committed Jun 14, 2024
1 parent 5a0f96d commit e32acb7
Show file tree
Hide file tree
Showing 8 changed files with 172 additions and 141 deletions.
107 changes: 59 additions & 48 deletions terraform/getting-started-deployment-tf/README.md

Large diffs are not rendered by default.

48 changes: 24 additions & 24 deletions terraform/getting-started-deployment-tf/cluster_profiles.tf
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,17 @@ resource "spectrocloud_cluster_profile" "aws-profile" {
namespace = var.app_namespace,
port = var.app_port,
replicas = var.replicas_number
db_password = var.db_password,
auth_token = var.auth_token
db_password = base64encode(var.db_password),
auth_token = base64encode(var.auth_token)
})
}
}

############################
# AWS Cluster Profile v1.1.0
############################
resource "spectrocloud_cluster_profile" "aws-profile-new" {
count = var.deploy-aws-new ? 1 : 0
resource "spectrocloud_cluster_profile" "aws-profile-kubecost" {
count = var.deploy-aws-kubecost ? 1 : 0

name = "tf-aws-profile"
description = "A basic cluster profile for AWS with Kubecost"
Expand Down Expand Up @@ -105,8 +105,8 @@ resource "spectrocloud_cluster_profile" "aws-profile-new" {
namespace = var.app_namespace,
port = var.app_port,
replicas = var.replicas_number
db_password = var.db_password,
auth_token = var.auth_token
db_password = base64encode(var.db_password),
auth_token = base64encode(var.auth_token)
})
}

Expand Down Expand Up @@ -167,17 +167,17 @@ resource "spectrocloud_cluster_profile" "azure-profile" {
namespace = var.app_namespace,
port = var.app_port,
replicas = var.replicas_number
db_password = var.db_password,
auth_token = var.auth_token
db_password = base64encode(var.db_password),
auth_token = base64encode(var.auth_token)
})
}
}

##############################
# Azure Cluster Profile v1.1.0
##############################
resource "spectrocloud_cluster_profile" "azure-profile-new" {
count = var.deploy-azure-new ? 1 : 0
resource "spectrocloud_cluster_profile" "azure-profile-kubecost" {
count = var.deploy-azure-kubecost ? 1 : 0

name = "tf-azure-profile"
description = "A basic cluster profile for Azure with Kubecost"
Expand Down Expand Up @@ -222,8 +222,8 @@ resource "spectrocloud_cluster_profile" "azure-profile-new" {
namespace = var.app_namespace,
port = var.app_port,
replicas = var.replicas_number
db_password = var.db_password,
auth_token = var.auth_token
db_password = base64encode(var.db_password),
auth_token = base64encode(var.auth_token)
})
}

Expand Down Expand Up @@ -285,17 +285,17 @@ resource "spectrocloud_cluster_profile" "gcp-profile" {
namespace = var.app_namespace,
port = var.app_port,
replicas = var.replicas_number
db_password = var.db_password,
auth_token = var.auth_token
db_password = base64encode(var.db_password),
auth_token = base64encode(var.auth_token)
})
}
}

############################
# GCP Cluster Profile v1.1.0
############################
resource "spectrocloud_cluster_profile" "gcp-profile-new" {
count = var.deploy-gcp-new ? 1 : 0
resource "spectrocloud_cluster_profile" "gcp-profile-kubecost" {
count = var.deploy-gcp-kubecost ? 1 : 0

name = "tf-gcp-profile"
description = "A basic cluster profile for GCP with Kubecost"
Expand Down Expand Up @@ -340,8 +340,8 @@ resource "spectrocloud_cluster_profile" "gcp-profile-new" {
namespace = var.app_namespace,
port = var.app_port,
replicas = var.replicas_number,
db_password = var.db_password,
auth_token = var.auth_token
db_password = base64encode(var.db_password),
auth_token = base64encode(var.auth_token)
})
}

Expand Down Expand Up @@ -409,17 +409,17 @@ resource "spectrocloud_cluster_profile" "vmware-profile" {
namespace = var.app_namespace,
port = var.app_port,
replicas = var.replicas_number,
db_password = var.db_password,
auth_token = var.auth_token
db_password = base64encode(var.db_password),
auth_token = base64encode(var.auth_token)
})
}
}

###############################
# VMware Cluster Profile v1.1.0
###############################
resource "spectrocloud_cluster_profile" "vmware-profile-new" {
count = var.deploy-vmware-new ? 1 : 0
resource "spectrocloud_cluster_profile" "vmware-profile-kubecost" {
count = var.deploy-vmware-kubecost ? 1 : 0

name = "tf-vmware-profile"
description = "A basic cluster profile for VMware with Kubecost"
Expand Down Expand Up @@ -471,8 +471,8 @@ resource "spectrocloud_cluster_profile" "vmware-profile-new" {
namespace = var.app_namespace,
port = var.app_port,
replicas = var.replicas_number,
db_password = var.db_password,
auth_token = var.auth_token
db_password = base64encode(var.db_password),
auth_token = base64encode(var.auth_token)
})
}

Expand Down
18 changes: 7 additions & 11 deletions terraform/getting-started-deployment-tf/clusters.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ resource "spectrocloud_cluster_aws" "aws-cluster" {
}

cluster_profile {
id = spectrocloud_cluster_profile.aws-profile[0].id
#id = spectrocloud_cluster_profile.aws-profile-new[0].id
id = var.deploy-aws && var.deploy-aws-kubecost ? spectrocloud_cluster_profile.aws-profile-kubecost[0].id : spectrocloud_cluster_profile.aws-profile[0].id
}

machine_pool {
Expand Down Expand Up @@ -62,8 +61,7 @@ resource "spectrocloud_cluster_azure" "azure-cluster" {
}

cluster_profile {
#id = spectrocloud_cluster_profile.azure-profile[0].id
id = spectrocloud_cluster_profile.azure-profile-new[0].id
id = var.deploy-azure && var.deploy-azure-kubecost ? spectrocloud_cluster_profile.azure-profile-kubecost[0].id : spectrocloud_cluster_profile.azure-profile[0].id
}

machine_pool {
Expand Down Expand Up @@ -110,8 +108,7 @@ resource "spectrocloud_cluster_gcp" "gcp-cluster" {
}

cluster_profile {
id = spectrocloud_cluster_profile.gcp-profile[0].id
#id = spectrocloud_cluster_profile.gcp-profile-new[0].id
id = var.deploy-gcp && var.deploy-gcp-kubecost ? spectrocloud_cluster_profile.gcp-profile-kubecost[0].id : spectrocloud_cluster_profile.gcp-profile[0].id
}

machine_pool {
Expand Down Expand Up @@ -153,13 +150,12 @@ resource "spectrocloud_cluster_vsphere" "vmware-cluster" {
ssh_key = local.ssh_public_key
datacenter = var.datacenter_name
folder = var.folder_name
static_ip = false # If true, the cluster will use static IP placement. If false, the cluster will use DDNS.
static_ip = var.deploy-vmware-static # If true, the cluster will use static IP placement. If false, the cluster will use DDNS.
network_search_domain = var.search_domain
}

cluster_profile {
id = spectrocloud_cluster_profile.vmware-profile[0].id
#id = spectrocloud_cluster_profile.vmware-profile-new[0].id
id = var.deploy-vmware && var.deploy-vmware-kubecost ? spectrocloud_cluster_profile.vmware-profile-kubecost[0].id : spectrocloud_cluster_profile.vmware-profile[0].id
}

scan_policy {
Expand All @@ -186,7 +182,7 @@ resource "spectrocloud_cluster_vsphere" "vmware-cluster" {
network = var.network_name
resource_pool = var.resource_pool_name
# Required for static IP placement.
#static_ip_pool_id = resource.spectrocloud_privatecloudgateway_ippool.ippool.id
static_ip_pool_id = var.deploy-vmware-static ? resource.spectrocloud_privatecloudgateway_ippool.ippool[0].id : null
}

}
Expand All @@ -208,7 +204,7 @@ resource "spectrocloud_cluster_vsphere" "vmware-cluster" {
network = var.network_name
resource_pool = var.resource_pool_name
# Required for static IP placement.
#static_ip_pool_id = resource.spectrocloud_privatecloudgateway_ippool.ippool.id
static_ip_pool_id = var.deploy-vmware-static ? resource.spectrocloud_privatecloudgateway_ippool.ippool[0].id : null
}
}

Expand Down
7 changes: 4 additions & 3 deletions terraform/getting-started-deployment-tf/data.tf
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,10 @@ data "spectrocloud_pack" "vmware_metallb" {
}

# Required for static IP placement
# data "spectrocloud_private_cloud_gateway" "pcg" {
# name = var.pcg_name
# }
data "spectrocloud_private_cloud_gateway" "pcg" {
count = var.deploy-vmware-static ? 1 : 0
name = var.pcg_name
}

#####################
# Hello Universe Pack
Expand Down
67 changes: 42 additions & 25 deletions terraform/getting-started-deployment-tf/inputs.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
# Copyright (c) Spectro Cloud
# SPDX-License-Identifier: Apache-2.0

#########
# Palette
#########

variable "palette-project" {
type = string
description = "The name of your project in Palette."
default = ""
}

#######
# AWS
#######
Expand All @@ -15,7 +25,7 @@ variable "deploy-aws" {
description = "A flag for enabling a deployment on AWS."
}

variable "deploy-aws-new" {
variable "deploy-aws-kubecost" {
type = bool
description = "A flag for enabling a deployment on AWS with Kubecost."
}
Expand Down Expand Up @@ -81,7 +91,7 @@ variable "deploy-azure" {
description = "A flag for enabling a deployment on Azure."
}

variable "deploy-azure-new" {
variable "deploy-azure-kubecost" {
type = bool
description = "A flag for enabling a deployment on Azure with Kubecost."
}
Expand Down Expand Up @@ -167,7 +177,7 @@ variable "deploy-gcp" {
description = "A flag for enabling a deployment on GCP."
}

variable "deploy-gcp-new" {
variable "deploy-gcp-kubecost" {
type = bool
description = "A flag for enabling a deployment on GCP with Kubecost."
}
Expand Down Expand Up @@ -234,7 +244,7 @@ variable "deploy-vmware" {
description = "A flag for enabling a deployment on VMware."
}

variable "deploy-vmware-new" {
variable "deploy-vmware-kubecost" {
type = bool
description = "A flag for enabling a deployment on VMware with Kubecost."
}
Expand Down Expand Up @@ -305,31 +315,36 @@ variable "pcg_name" {
description = "The name of the PCG that will be used to deploy the cluster."
}

# Input resources for the Static IP Pool (required for static IP placement)
# variable "network_gateway" {
# type = string
# description = "The IP address of the vSphere network gateway."
# }
# Input resources for the Static IP Pool (required for static IP placement only)
variable "deploy-vmware-static" {
type = bool
description = "A flag for enabling a deployment on VMware using static IP placement."
}

# variable "network_prefix" {
# type = number
# description = "The prefix of your vSphere network. Valid values are network CIDR subnet masks from the range 0-32. Example: 18."
# }
variable "network_gateway" {
type = string
description = "The IP address of the vSphere network gateway."
}

# variable "ip_range_start" {
# type = string
# description = "The first IP address of your PCG IP pool range."
# }
variable "network_prefix" {
type = number
description = "The prefix of your vSphere network. Valid values are network CIDR subnet masks from the range 0-32. Example: 18."
}

variable "ip_range_start" {
type = string
description = "The first IP address of your PCG IP pool range."
}

# variable "ip_range_end" {
# type = string
# description = "The last IP address of your PCG IP pool range."
# }
variable "ip_range_end" {
type = string
description = "The last IP address of your PCG IP pool range."
}

# variable "nameserver_addr" {
# type = set(string)
# description = "A comma-separated list of DNS nameserver IP addresses of your network."
# }
variable "nameserver_addr" {
type = set(string)
description = "A comma-separated list of DNS nameserver IP addresses of your network."
}


##############################
Expand All @@ -353,9 +368,11 @@ variable "replicas_number" {
variable "db_password" {
type = string
description = "The base64 encoded database password to connect to the API database."
sensitive = true
}

variable "auth_token" {
type = string
description = "The base64 encoded auth token for the API connection."
sensitive = true
}
21 changes: 11 additions & 10 deletions terraform/getting-started-deployment-tf/ippool.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
# SPDX-License-Identifier: Apache-2.0

# Required for static IP placement.
# resource "spectrocloud_privatecloudgateway_ippool" "ippool" {
# gateway = var.network_gateway
# name = "${var.cluster_name}-ippool"
# network_type = "range"
# prefix = var.network_prefix
# private_cloud_gateway_id = data.spectrocloud_private_cloud_gateway.pcg.id
# ip_start_range = var.ip_range_start
# ip_end_range = var.ip_range_end
# nameserver_addresses = var.nameserver_addr
# }
resource "spectrocloud_privatecloudgateway_ippool" "ippool" {
count = var.deploy-vmware-static ? 1 : 0
gateway = var.network_gateway
name = "vsphere-vmware-ippool"
network_type = "range"
prefix = var.network_prefix
private_cloud_gateway_id = data.spectrocloud_private_cloud_gateway.pcg[0].id
ip_start_range = var.ip_range_start
ip_end_range = var.ip_range_end
nameserver_addresses = var.nameserver_addr
}
2 changes: 1 addition & 1 deletion terraform/getting-started-deployment-tf/provider.tf
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ terraform {

provider "spectrocloud" {
# API key set through the environment variable SPECTROCLOUD_APIKEY
project_name = "Default"
project_name = var.palette-project
}
Loading

0 comments on commit e32acb7

Please sign in to comment.