Make node-config accept ec2 type per group.
This commit is contained in:
@@ -26,6 +26,10 @@ chpasswd:
|
||||
hostname: ${hostname}
|
||||
fqdn: ${hostname}
|
||||
|
||||
package_update: true
|
||||
package_upgrade: true
|
||||
package_reboot_if_required: true
|
||||
|
||||
%{ if install-qemu-agent }
|
||||
packages:
|
||||
# This are only necessary for libvirt.
|
||||
|
||||
@@ -19,17 +19,6 @@ node-vcpus = 2
|
||||
# 12 GiB
|
||||
# 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)
|
||||
################################################################################
|
||||
|
||||
@@ -1,14 +1,26 @@
|
||||
|
||||
locals {
|
||||
nodes-config = {
|
||||
"master" = {
|
||||
"k8s-master" = {
|
||||
base-image = var.ubuntu-ami
|
||||
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
|
||||
},
|
||||
"ansible-test" = {
|
||||
base-image = var.ubuntu-ami
|
||||
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
|
||||
},
|
||||
"worker" = {
|
||||
base-image = var.ubuntu-ami
|
||||
num = 2
|
||||
}
|
||||
}
|
||||
install-qemu-agent = false
|
||||
}
|
||||
@@ -80,12 +92,13 @@ module "nodes" {
|
||||
for_each = local.nodes-config
|
||||
source = "./modules/aws-nodes"
|
||||
ami = each.value.base-image
|
||||
ec2-instance-type = var.aws-ec2-instance-type
|
||||
subnet-id = module.aws-network-existing.k8s-subnets-ids[0]
|
||||
security-group-ids = [module.aws-network-existing.default-sg.id]
|
||||
user-datas = lookup(module.cloud-init-config, each.key, null).user-datas
|
||||
num-nodes = each.value.num
|
||||
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.
|
||||
}
|
||||
|
||||
################################################################################
|
||||
|
||||
+28
-7
@@ -4,11 +4,6 @@ variable "admin-ips" {
|
||||
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" {
|
||||
default = "change-me-if-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
|
||||
# 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
|
||||
# the latest for each distro.
|
||||
################################################################################
|
||||
@@ -150,9 +145,35 @@ variable "rhel8-ami" {
|
||||
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
|
||||
# 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.
|
||||
################################################################################
|
||||
|
||||
|
||||
Reference in New Issue
Block a user