Make node-config accept ec2 type per group.

new-vpc
Curtis Wilson 4 years ago
parent e82098564e
commit ff956b51d2

@ -26,6 +26,10 @@ chpasswd:
hostname: ${hostname} hostname: ${hostname}
fqdn: ${hostname} fqdn: ${hostname}
package_update: true
package_upgrade: true
package_reboot_if_required: true
%{ if install-qemu-agent } %{ if install-qemu-agent }
packages: packages:
# This are only necessary for libvirt. # This are only necessary for libvirt.

@ -19,17 +19,6 @@ node-vcpus = 2
# 12 GiB # 12 GiB
# libvirt-node-disk-size = "${12 * 1073741824}" # libvirt-node-disk-size = "${12 * 1073741824}"
################################################################################
# AWS EC2 instance types
################################################################################
# 1 GiB, 1 vcpu, only one that is free.
# This one won't work with k8s because it requires at least 2 vcpus.
aws-ec2-instance-type = "t2.micro"
# 4 GiB, 2 vcpus
# aws-ec2-instnce-type = "t2.medium"
################################################################################ ################################################################################
# AWS images (AMIs) # AWS images (AMIs)
################################################################################ ################################################################################

@ -1,14 +1,26 @@
locals { locals {
nodes-config = { nodes-config = {
"master" = { "k8s-master" = {
base-image = var.ubuntu-ami base-image = var.ubuntu-ami
num = 1 aws-ec2-type = var.t2-medium-4gib-2vcpu
num = 0
},
"k8s-worker" = {
base-image = var.ubuntu-ami
aws-ec2-type = var.t2-medium-4gib-2vcpu
num = 0
}, },
"worker" = { "ansible-test" = {
base-image = var.ubuntu-ami base-image = var.ubuntu-ami
num = 2 aws-ec2-type = var.t2-micro-1gib-1vcpu
} num = 0
},
"nfs" = {
base-image = var.ubuntu-ami
aws-ec2-type = var.t2-micro-1gib-1vcpu
num = 1
},
} }
install-qemu-agent = false install-qemu-agent = false
} }
@ -80,12 +92,13 @@ module "nodes" {
for_each = local.nodes-config for_each = local.nodes-config
source = "./modules/aws-nodes" source = "./modules/aws-nodes"
ami = each.value.base-image ami = each.value.base-image
ec2-instance-type = var.aws-ec2-instance-type
subnet-id = module.aws-network-existing.k8s-subnets-ids[0] subnet-id = module.aws-network-existing.k8s-subnets-ids[0]
security-group-ids = [module.aws-network-existing.default-sg.id] security-group-ids = [module.aws-network-existing.default-sg.id]
user-datas = lookup(module.cloud-init-config, each.key, null).user-datas user-datas = lookup(module.cloud-init-config, each.key, null).user-datas
num-nodes = each.value.num num-nodes = each.value.num
name-prefix = "${var.vm-name-prefix}-${each.key}" name-prefix = "${var.vm-name-prefix}-${each.key}"
# TODO add a input for the key so that it will show up as the key in the aws
# console.
} }
################################################################################ ################################################################################

@ -4,11 +4,6 @@ variable "admin-ips" {
type = list(string) type = list(string)
} }
variable "aws-ec2-instance-type" {
default = "t2.micro"
description = "The AWS instance type to use for all nodes."
}
variable "aws-existing-sg-name" { variable "aws-existing-sg-name" {
default = "change-me-if-using-aws-network-existing" default = "change-me-if-using-aws-network-existing"
description = "The name of the existing security group when using aws-network-existing." description = "The name of the existing security group when using aws-network-existing."
@ -101,7 +96,7 @@ variable "vm-name-prefix" {
################################################################################ ################################################################################
# AWS AMI vars # AWS AMI vars
# These variables are really mor like constants. Using variables improves # These variables are really more like constants. Using variables improves
# readability. The defaults are manually updated. Use the aws-amis module to get # readability. The defaults are manually updated. Use the aws-amis module to get
# the latest for each distro. # the latest for each distro.
################################################################################ ################################################################################
@ -150,9 +145,35 @@ variable "rhel8-ami" {
description = "The AMI to use for RHEL 8." description = "The AMI to use for RHEL 8."
} }
################################################################################
# AWS EC2 types.
# These variables are really more like constants. Using variables improves
# readability.
################################################################################
variable "t2-micro-1gib-1vcpu" {
description = "t2.micro EC2 instance with 1 GiB mem and 1 vCPU."
default = "t2.micro"
}
variable "t2-medium-4gib-2vcpu" {
description = "t2.medium EC2 instance with 4 GiB mem and 2 vCPUs."
default = "t2.medium"
}
variable "t2-large-8gib-2vcpu" {
description = "t2.large EC2 instance with 8 GiB mem and 2 vCPUs."
default = "t2.large"
}
variable "t2-xlarge-16gib-4vcpu" {
description = "t2.xlarge EC2 instance with 16 GiB mem and 4 vCPUs."
default = "t2.xlarge"
}
################################################################################ ################################################################################
# Libvirt Images # Libvirt Images
# These variables are really mor like constants. Using variables improves # These variables are really more like constants. Using variables improves
# readability. The defaults are manually updated. # readability. The defaults are manually updated.
################################################################################ ################################################################################

Loading…
Cancel
Save