Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9504e3737d | ||
|
|
33f267b163 | ||
|
|
97f358332c | ||
|
|
861641dbd8 | ||
|
|
9a01c09928 | ||
|
|
cf0da0d659 | ||
|
|
a324e68287 | ||
|
|
043ee3b342 | ||
|
|
40613e08b6 | ||
|
|
4d39461101 | ||
|
|
15edee3b60 | ||
|
|
dff900e53a | ||
|
|
5107ec9a5c | ||
|
|
073ace2732 | ||
|
|
dda60c0b63 | ||
|
|
86acf7736d | ||
|
|
7ca4db8737 | ||
|
|
98bb54726d | ||
|
|
c229e1e0bb | ||
|
|
3fd6b034d7 | ||
|
|
f5fb896b9a | ||
|
|
5499a0e9da | ||
|
|
e57963641b | ||
|
|
7de2ba1728 | ||
|
|
6c2d3e3837 | ||
|
|
fee62e0385 | ||
|
|
482e8d1027 | ||
|
|
5ea36d8626 | ||
|
|
10a88425ed | ||
|
|
10d01ff839 | ||
|
|
ce3a5b39f5 | ||
|
|
ad0212a29d | ||
|
|
1787590da2 | ||
|
|
17c60e41bb | ||
|
|
ec6bb824d0 | ||
|
|
852d8cfcf2 | ||
|
|
c9ea3d4489 | ||
|
|
9aa0a68be8 | ||
|
|
3088e2295f | ||
|
|
091b459046 | ||
|
|
b4ac04fbd8 | ||
|
|
8724cede19 | ||
|
|
31a70766ec | ||
|
|
e9df4cd1d6 | ||
|
|
25794c641a | ||
|
|
b0b959f28b | ||
|
|
f357d3dd5b | ||
|
|
cb59a5b2f3 | ||
|
|
f8b894739f | ||
|
|
e3b15f952c | ||
|
|
833352fda8 | ||
|
|
a232bbfd71 | ||
|
|
b2ae84be72 | ||
|
|
4a62875b8e | ||
|
|
3d7bd95f78 | ||
|
|
474f6c746a | ||
|
|
af17823d68 | ||
|
|
b126da8acf | ||
|
|
483c44b695 | ||
|
|
2c0f1ff60e |
@@ -1,53 +1,19 @@
|
||||
A terraform script that will setup VMs via AWS or KVM/QEMU (libvirt).
|
||||
A Terraform script to create k8s nodes. This script has modules for creating the
|
||||
nodes on a KVM/QEMU (libvirt) hypervisor or creating the nodes via AWS.
|
||||
|
||||
The modules allow you create N VMs of a specific type. So you could create 1
|
||||
master node and 3 worker nodes or you could create 3 Ubuntu VMs and 5 CentOS
|
||||
VMs, or whatever fits your needs.
|
||||
|
||||
This script creates the VMs and then uses Cloud-init for initial configuration
|
||||
of the VMs.
|
||||
|
||||
libvirt vs. AWS
|
||||
----------------------------------------
|
||||
|
||||
This script allows VMs to be created libvirt or AWS. You can choose either one,
|
||||
however, running both at the same time has not been tested. Therefore, when
|
||||
using one, you should comment out all code pertaining to the other provider.
|
||||
|
||||
Cloud-Init
|
||||
----------------------------------------
|
||||
|
||||
Both the libvirt and aws modules use cloud-init for initial configuration of the
|
||||
VMs. Cloud-init is used to create the admin user and add the mss-admin keys.
|
||||
Cloud-init is also used to install some initial packages. The goal is to get
|
||||
these VMs setup enough so that they can be configured via Ansible.
|
||||
|
||||
Environment Setup
|
||||
----------------------------------------
|
||||
|
||||
1. From within the nodes-terraform directory run `terraform init`. You will a
|
||||
see bunch if output as terraform grabs the dependencies it needs.
|
||||
|
||||
2. Copy the shared `terraform.tfvars` from S3.
|
||||
```shell
|
||||
aws s3 cp s3://mss-terraform-state/global/s3/terraform.tfvars .
|
||||
```
|
||||
For instructions on getting AWS CLI to work correctly see `aws-api-setup.md`
|
||||
in the `doc-ops` repo.
|
||||
|
||||
Take care to copy your `terraform.tfvars` back to the S3 bucket whenever you
|
||||
make a change to it.
|
||||
|
||||
3. Verify that you branch and variables match whats deployed by running
|
||||
`terraform plan`. If everything is in sync you should see `No changes. Your
|
||||
infrastructure matches the configuration.` _IF_ you do not see this message
|
||||
make sure to sync with the other admins before continuing.
|
||||
|
||||
VMs.
|
||||
|
||||
Dependencies
|
||||
----------------------------------------
|
||||
|
||||
_UNFINISHED_
|
||||
TODO REM add libvirt provider
|
||||
libvirt provider depends on mkisofs
|
||||
|
||||
|
||||
@@ -1,181 +1,54 @@
|
||||
|
||||
locals {
|
||||
old-k8s-subnets-ids = [
|
||||
k8s-subnets-ids = [
|
||||
# module.aws-network-from-scratch.subnet.id,
|
||||
module.aws-network-existing-managed.subnet-by-name["subnet_1"].id,
|
||||
module.aws-network-existing-managed.subnet-by-name["subnet_3"].id,
|
||||
]
|
||||
new-k8s-subnets-ids = [
|
||||
module.aws-network-existing-mss-dev.subnet-by-name["mssdev Subnet 1"].id,
|
||||
module.aws-network-existing-mss-dev.subnet-by-name["mssdev Subnet 3"].id,
|
||||
module.aws-network-existing.subnet-by-name["subnet_1"].id,
|
||||
module.aws-network-existing.subnet-by-name["subnet_3"].id,
|
||||
]
|
||||
nfs-subnets = [
|
||||
# module.aws-network-from-scratch.subnet,
|
||||
module.aws-network-existing-managed.subnet-by-name["subnet_4"],
|
||||
module.aws-network-existing.subnet-by-name["subnet_4"],
|
||||
]
|
||||
aws-managed-security-group-id = module.aws-network-existing-managed.default-sg.id
|
||||
aws-mss-dev-security-group-id = module.aws-network-existing-mss-dev.default-sg.id
|
||||
# aws-managed-security-group-id = module.aws-network-from-scratch.default-security-group.id
|
||||
|
||||
# The names of these nodes is created by:
|
||||
# "{var.vm-name-prefix}-{name from nodes-config}-{number}"
|
||||
# The length of this full name must be < 16 characters. This is a limitaion of
|
||||
# Active Directory? The "realm join" command failed when the name was too
|
||||
# long, although it did not give the reason for the failure, the reason was
|
||||
# surmised because it looked like it was truncating the name when attempting
|
||||
# to join.
|
||||
#
|
||||
# NOTE: This naming restriction is only important if you plan on joining these
|
||||
# VMs to Active Directory.
|
||||
aws-security-group-id = module.aws-network-existing.default-sg.id
|
||||
# aws-security-group-id = module.aws-network-from-scratch.default-security-group.id
|
||||
nodes-config = {
|
||||
# TODO if the above comment about the name length is true, then this name is
|
||||
# too long. IMPORTANT! If you change this then you need to change the k8s
|
||||
# ansible role that assigns roles based on wether or not 'master' is in the
|
||||
# name.
|
||||
"k8s-master" = {
|
||||
base-image = module.aws-ami-constants.ubuntu-ami
|
||||
aws-ec2-type = module.ec2-types.t2-medium-4gib-2vcpu
|
||||
subnet-ids = local.old-k8s-subnets-ids
|
||||
security-groups = [local.aws-managed-security-group-id]
|
||||
num = 1
|
||||
},
|
||||
"k8s-wrkr" = {
|
||||
base-image = module.aws-ami-constants.ubuntu-ami
|
||||
aws-ec2-type = module.ec2-types.c5a-xlarge-amd-8gib-4vcpu
|
||||
subnet-ids = local.old-k8s-subnets-ids
|
||||
security-groups = [local.aws-managed-security-group-id]
|
||||
disk-size = 32
|
||||
base-image = var.ubuntu-ami
|
||||
aws-ec2-type = var.t2-medium-4gib-2vcpu
|
||||
subnet-ids = local.k8s-subnets-ids
|
||||
num = 0
|
||||
},
|
||||
"worker" = {
|
||||
base-image = module.aws-ami-constants.ubuntu-ami
|
||||
aws-ec2-type = module.ec2-types.c5a-xlarge-amd-8gib-4vcpu
|
||||
subnet-ids = local.old-k8s-subnets-ids
|
||||
security-groups = [local.aws-managed-security-group-id]
|
||||
disk-size = 64
|
||||
num = 4
|
||||
},
|
||||
"tst-master" = {
|
||||
base-image = module.aws-ami-constants.ubuntu-ami
|
||||
aws-ec2-type = module.ec2-types.t2-medium-4gib-2vcpu
|
||||
subnet-ids = local.old-k8s-subnets-ids
|
||||
security-groups = [local.aws-managed-security-group-id]
|
||||
"k8s-worker" = {
|
||||
base-image = var.ubuntu-ami
|
||||
aws-ec2-type = var.t2-medium-4gib-2vcpu
|
||||
subnet-ids = local.k8s-subnets-ids
|
||||
num = 0
|
||||
},
|
||||
"tst-wrkr" = {
|
||||
base-image = module.aws-ami-constants.ubuntu-ami
|
||||
aws-ec2-type = module.ec2-types.c5a-xlarge-amd-8gib-4vcpu
|
||||
subnet-ids = local.old-k8s-subnets-ids
|
||||
security-groups = [local.aws-managed-security-group-id]
|
||||
disk-size = 32
|
||||
num = 0
|
||||
},
|
||||
"rancher-master" = {
|
||||
base-image = module.aws-ami-constants.ubuntu-ami
|
||||
aws-ec2-type = module.ec2-types.c5a-xlarge-amd-8gib-4vcpu
|
||||
subnet-ids = local.new-k8s-subnets-ids
|
||||
security-groups = [local.aws-mss-dev-security-group-id]
|
||||
disk-size = 64
|
||||
num = 3
|
||||
},
|
||||
"rancher-worker" = {
|
||||
base-image = module.aws-ami-constants.ubuntu-ami
|
||||
aws-ec2-type = module.ec2-types.c5a-xlarge-amd-8gib-4vcpu
|
||||
subnet-ids = local.new-k8s-subnets-ids
|
||||
security-groups = [local.aws-mss-dev-security-group-id]
|
||||
disk-size = 64
|
||||
num = 4
|
||||
},
|
||||
"dev" = {
|
||||
base-image = module.aws-ami-constants.ubuntu-ami
|
||||
aws-ec2-type = module.ec2-types.c5a-xlarge-amd-8gib-4vcpu
|
||||
"ansible-test" = {
|
||||
base-image = var.ubuntu-ami
|
||||
aws-ec2-type = var.t2-micro-1gib-1vcpu
|
||||
# subnet-ids = [module.aws-network-from-scratch.subnet.id]
|
||||
subnet-ids = [module.aws-network-existing-managed.subnet-by-name["subnet_4"].id]
|
||||
security-groups = [local.aws-managed-security-group-id]
|
||||
disk-size = 32
|
||||
num = 2
|
||||
subnet-ids = [module.aws-network-existing.subnet-by-name["subnet_2"].id]
|
||||
num = 0
|
||||
},
|
||||
"nfs" = {
|
||||
base-image = module.aws-ami-constants.ubuntu-ami
|
||||
aws-ec2-type = module.ec2-types.t3a-medium-amd-4gib-2vcpu
|
||||
base-image = var.ubuntu-ami
|
||||
aws-ec2-type = var.t2-micro-1gib-1vcpu
|
||||
# subnet-ids = [module.aws-network-from-scratch.subnet.id]
|
||||
subnet-ids = [module.aws-network-existing-managed.subnet-by-name["subnet_4"].id]
|
||||
security-groups = [local.aws-managed-security-group-id]
|
||||
subnet-ids = [module.aws-network-existing.subnet-by-name["subnet_4"].id]
|
||||
num = 1
|
||||
num-disks = 1
|
||||
# TODO Remove this, prefferred method is to use 'disks' and 'disk-mounts'
|
||||
# like shown below.
|
||||
zfs-disk-size = 10
|
||||
disk-size = 10
|
||||
},
|
||||
"proxy" = {
|
||||
base-image = module.aws-ami-constants.ubuntu-ami
|
||||
aws-ec2-type = module.ec2-types.t2-micro-1gib-1vcpu
|
||||
base-image = var.ubuntu-ami
|
||||
aws-ec2-type = var.t2-micro-1gib-1vcpu
|
||||
# subnet-ids = [module.aws-network-from-scratch.subnet.id]
|
||||
subnet-ids = [module.aws-network-existing-managed.subnet-by-name["subnet_4"].id]
|
||||
security-groups = [local.aws-managed-security-group-id]
|
||||
subnet-ids = [module.aws-network-existing.subnet-by-name["subnet_4"].id]
|
||||
private-ips = [var.aws-proxy-private-ip]
|
||||
num = 1
|
||||
},
|
||||
"oracle-db" = {
|
||||
base-image = module.aws-ami-constants.rhel8-ami
|
||||
aws-ec2-type = module.ec2-types.c5a-xlarge-amd-8gib-4vcpu
|
||||
# subnet-ids = [module.aws-network-from-scratch.subnet.id]
|
||||
subnet-ids = [module.aws-network-existing-mss-dev.subnet-by-name["mssdev Subnet 2"].id]
|
||||
security-groups = [local.aws-mss-dev-security-group-id]
|
||||
disk-size = 128
|
||||
num = 1
|
||||
},
|
||||
}
|
||||
|
||||
disks = {
|
||||
"zfs-64g" = {
|
||||
num = 1,
|
||||
size = 64
|
||||
availability_zone = local.nfs-subnets[0].availability_zone
|
||||
},
|
||||
"zfs-256g" = {
|
||||
num = 1,
|
||||
size = 256
|
||||
availability_zone = local.nfs-subnets[0].availability_zone
|
||||
},
|
||||
}
|
||||
|
||||
disk-mounts = [
|
||||
{
|
||||
# TODO make this attach field work.
|
||||
attach = false
|
||||
ec2-id = module.nodes["nfs"].nodes[0].id,
|
||||
disk-group = "zfs-64g"
|
||||
# TODO also make sure that get drive letters or whetever still works. did
|
||||
# it ever work?
|
||||
# TODO We need to have a map of drive letters to device path in linux.
|
||||
# This gets a little more complicated becuase the t2 instances map to
|
||||
# /dev/xvdg while the t3a instance types map to /dev/nvme0n1 where 0 is
|
||||
# the nth drive connected. The nth drive does not seem to map to a drive
|
||||
# letter, ie. drive letter "f" does not map to 6, the nth drive simply
|
||||
# increments by 1 for each drive attached regardless of the drive letter
|
||||
# set.
|
||||
drive-letters = ["g", "h", "i"]
|
||||
},
|
||||
{
|
||||
# TODO make this attach field work.
|
||||
attach = false
|
||||
ec2-id = module.nodes["nfs"].nodes[0].id,
|
||||
disk-group = "zfs-256g"
|
||||
# TODO also make sure that get drive letters or whetever still works. did
|
||||
# it ever work?
|
||||
# TODO We need to have a map of drive letters to device path in linux.
|
||||
# This gets a little more complicated becuase the t2 instances map to
|
||||
# /dev/xvdg while the t3a instance types map to /dev/nvme0n1 where 0 is
|
||||
# the nth drive connected. The nth drive does not seem to map to a drive
|
||||
# letter, ie. drive letter "f" does not map to 6, the nth drive simply
|
||||
# increments by 1 for each drive attached regardless of the drive letter
|
||||
# set.
|
||||
drive-letters = ["j", "k", "l"]
|
||||
},
|
||||
]
|
||||
|
||||
# This is only needed for libvirt.
|
||||
install-qemu-agent = false
|
||||
}
|
||||
|
||||
@@ -200,16 +73,6 @@ module "cloud-init-config" {
|
||||
# libvirt modules/resources.
|
||||
################################################################################
|
||||
|
||||
# This module sets the ec2-types constants.
|
||||
module "ec2-types" {
|
||||
source = "./modules/ec2-types"
|
||||
}
|
||||
|
||||
# This module sets the AWS AMI constants.
|
||||
module "aws-ami-constants" {
|
||||
source = "./modules/aws-ami-constants"
|
||||
}
|
||||
|
||||
# This module will grab the latest ami for a variety of distros. Uncomment to
|
||||
# get a list of the latest AMIs for our supported distros.
|
||||
# module "aws-amis" {
|
||||
@@ -221,7 +84,7 @@ module "aws-ami-constants" {
|
||||
|
||||
################################################################################
|
||||
# AWS Networking
|
||||
# Use the 2 modules below to create resources for the AWS network.
|
||||
# Use of the 2 modules below to create resources for the AWS network.
|
||||
# aws-network-from-scratch will build the AWS network from scratch.
|
||||
# aws-network-existing will query AWS for an existing VPC.
|
||||
################################################################################
|
||||
@@ -234,18 +97,11 @@ module "aws-ami-constants" {
|
||||
# admin-ips = var.admin-ips
|
||||
# }
|
||||
|
||||
module "aws-network-existing-managed" {
|
||||
module "aws-network-existing" {
|
||||
source = "./modules/aws-network-existing"
|
||||
default-vpc-name = var.aws-existing-managed-vpc-name
|
||||
default-security-group-name = var.aws-existing-managed-sg-name
|
||||
existing-subnet-names = var.aws-existing-managed-subnet-names
|
||||
}
|
||||
|
||||
module "aws-network-existing-mss-dev" {
|
||||
source = "./modules/aws-network-existing"
|
||||
default-vpc-name = var.aws-existing-mss-dev-vpc-name
|
||||
default-security-group-name = var.aws-existing-mss-dev-sg-name
|
||||
existing-subnet-names = var.aws-existing-mss-dev-subnet-names
|
||||
default-vpc-name = var.aws-existing-vpc-name
|
||||
default-security-group-name = var.aws-existing-sg-name
|
||||
existing-subnet-names = var.aws-existing-subnet-names
|
||||
}
|
||||
|
||||
################################################################################
|
||||
@@ -260,28 +116,10 @@ resource "aws_key_pair" "key" {
|
||||
}
|
||||
}
|
||||
|
||||
module "disks" {
|
||||
for_each = local.disks
|
||||
source = "./modules/aws-disks"
|
||||
availability_zone = each.value.availability_zone
|
||||
size = each.value.size
|
||||
num = each.value.num
|
||||
prefix = each.key
|
||||
}
|
||||
|
||||
module "disk-mounts" {
|
||||
source = "./modules/aws-disk-mounts"
|
||||
disks = module.disks[element(local.disk-mounts, count.index).disk-group].disks
|
||||
ec2-id = element(local.disk-mounts, count.index).ec2-id
|
||||
drive-letters = try(element(local.disk-mounts, count.index).drive-letters, null)
|
||||
count = length(local.disk-mounts)
|
||||
}
|
||||
|
||||
# TODO REM remove if unuesed.
|
||||
resource "aws_ebs_volume" "zfs" {
|
||||
# TODO REM look at types.
|
||||
availability_zone = local.nfs-subnets[0].availability_zone
|
||||
size = local.nodes-config["nfs"].zfs-disk-size
|
||||
size = local.nodes-config["nfs"].disk-size
|
||||
encrypted = true
|
||||
count = local.nodes-config["nfs"].num-disks
|
||||
tags = {
|
||||
@@ -307,29 +145,14 @@ module "nodes" {
|
||||
ami = each.value.base-image
|
||||
subnet-ids = each.value.subnet-ids
|
||||
private-ips = try(each.value.private-ips, [])
|
||||
security-group-ids = each.value.security-groups
|
||||
security-group-ids = [local.aws-security-group-id]
|
||||
user-datas = lookup(module.cloud-init-config, each.key, null).user-datas
|
||||
disk-size = try(each.value.disk-size, null)
|
||||
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.
|
||||
}
|
||||
|
||||
# TODO an attempt to create a windows machine.
|
||||
# module "nodes-win" {
|
||||
# source = "./modules/aws-nodes"
|
||||
# ec2-instance-type = module.ec2-types.t2-small-2gib-1vcpu
|
||||
# ami = module.aws-ami-constants.win-srv-2019-ami
|
||||
# subnet-ids = [module.aws-network-existing-managed.subnet-by-name["subnet_2"].id]
|
||||
# private-ips = []
|
||||
# security-group-ids = [local.aws-managed-security-group-id]
|
||||
# # TODO REM need to figure out how to not pass a user data.
|
||||
# user-datas = [null]
|
||||
# num-nodes = 1
|
||||
# name-prefix = "${var.vm-name-prefix}-win-test"
|
||||
# }
|
||||
|
||||
################################################################################
|
||||
# end aws
|
||||
################################################################################
|
||||
@@ -344,10 +167,6 @@ module "nodes" {
|
||||
# uri = var.libvirt-connection-url
|
||||
# }
|
||||
#
|
||||
# module "libvirt-images" {
|
||||
# source = "./modules/libvirt-images"
|
||||
# }
|
||||
#
|
||||
# module "nodes" {
|
||||
# for_each = local.nodes-config
|
||||
# source = "./modules/libvirt-nodes"
|
||||
|
||||
@@ -1,58 +0,0 @@
|
||||
################################################################################
|
||||
# AWS AMI vars
|
||||
# These outputs are really more like constants. Using outputs improves
|
||||
# readability. The values are manually updated. Use the aws-amis module to get
|
||||
# the latest for each distro. Keep in mind that AMIs are region specific this is
|
||||
# why you may see values and other regions commented out.
|
||||
################################################################################
|
||||
|
||||
output "amzn2-ami" {
|
||||
# us-east-2
|
||||
# default = "ami-0dd0ccab7e2801812"
|
||||
# us-gov-west-1
|
||||
value = "ami-0281624483c624b77"
|
||||
description = "The AMI to use for Amazon Linux 2."
|
||||
}
|
||||
output "ubuntu-ami" {
|
||||
# us-east-2
|
||||
# value = "ami-06c7d6c0987eaa46c"
|
||||
# us-gov-west-1
|
||||
value = "ami-066189aeb91baa0ab"
|
||||
description = "The AMI to use for Ubuntu."
|
||||
}
|
||||
output "centos7-ami" {
|
||||
# us-east-2
|
||||
value = "ami-00f8e2c955f7ffa9b"
|
||||
description = "The AMI to use for CentOS 7."
|
||||
}
|
||||
output "centos8-ami" {
|
||||
# us-east-2
|
||||
value = "ami-057cacbfbbb471bb3"
|
||||
description = "The AMI to use for CentOS 8."
|
||||
}
|
||||
output "arch-ami" {
|
||||
# us-east-2
|
||||
value = "ami-02653f06de985e3ba"
|
||||
description = "The AMI to use for Arch Linux."
|
||||
}
|
||||
output "rhel7-ami" {
|
||||
# us-east-2
|
||||
# value = "ami-0a509b3c2a4d05b3f"
|
||||
# us-gov-west-1
|
||||
value = "ami-0783f30dbf99aa05d"
|
||||
description = "The AMI to use for RHEL 7."
|
||||
}
|
||||
output "rhel8-ami" {
|
||||
# us-east-2
|
||||
# value = "ami-0d871ca8a77af2948"
|
||||
# us-gov-west-1
|
||||
value = "ami-04482d061459e6c32"
|
||||
description = "The AMI to use for RHEL 8."
|
||||
}
|
||||
output "win-srv-2019-ami" {
|
||||
# us-east-2
|
||||
# value = ???
|
||||
# us-gov-west-1
|
||||
value = "ami-070f960754631d355"
|
||||
description = "The AMI to use for Windows Server 2019."
|
||||
}
|
||||
@@ -48,14 +48,7 @@ locals {
|
||||
# us-gov-west-1
|
||||
owner-id = "219670896067"
|
||||
name = "RHEL-8.*HVM*x86_64*GP2"
|
||||
},
|
||||
win-srv-2019 = {
|
||||
# us-east-2
|
||||
# owner-id = "???"
|
||||
# us-gov-west-1
|
||||
owner-id = "077303321853"
|
||||
name = "Windows_Server-2019-English-Full-Base*"
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
resource "aws_volume_attachment" "mount-volume" {
|
||||
device_name = "/dev/sd${element(var.drive-letters, count.index)}"
|
||||
instance_id = var.ec2-id
|
||||
count = length(var.disks)
|
||||
volume_id = element(var.disks, count.index).id
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
variable "drive-letters" {
|
||||
default = ["f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]
|
||||
description = "These drive letters will be used when arraching disks to EC2 instance with `ec2-id'"
|
||||
type = list(string)
|
||||
nullable = false
|
||||
}
|
||||
|
||||
variable "disks" {
|
||||
description = "An array of disks to attach to the EC2 isntance with `ec2-id`"
|
||||
type = list
|
||||
}
|
||||
|
||||
variable "ec2-id" {
|
||||
description = "The ID of the EC@ instance to attach the drives to."
|
||||
type = string
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
|
||||
resource "aws_ebs_volume" "disks" {
|
||||
availability_zone = var.availability_zone
|
||||
size = var.size
|
||||
count = var.num
|
||||
encrypted = true
|
||||
tags = {
|
||||
Name = "${var.prefix}-${count.index}"
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
output "disks" {
|
||||
value = aws_ebs_volume.disks
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
variable "availability_zone" {
|
||||
description = "The availability zone this disk will reside in. This AZ is applied to all 'num' disks."
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "num" {
|
||||
description = "The number of disks to be created with this config."
|
||||
type = number
|
||||
}
|
||||
|
||||
variable "prefix" {
|
||||
description = "This prefix will be used in the name of each disk created with this module. If the prefix is 'zfs', then it will create disks with names, zfs-0 and zfs-1."
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "size" {
|
||||
description = "The size of the disk in GB."
|
||||
type = number
|
||||
}
|
||||
@@ -9,10 +9,6 @@ resource "aws_instance" "nodes" {
|
||||
private_ip = length(var.private-ips) == 0 ? null : element(var.private-ips, count.index)
|
||||
vpc_security_group_ids = var.security-group-ids
|
||||
user_data = element(var.user-datas.*.rendered, count.index)
|
||||
root_block_device {
|
||||
volume_size = var.disk-size
|
||||
delete_on_termination = true
|
||||
}
|
||||
count = var.num-nodes
|
||||
|
||||
tags = {
|
||||
|
||||
@@ -3,12 +3,6 @@ variable "ami" {
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "disk-size" {
|
||||
default = 8
|
||||
description = "The size of the root FS disk in GB."
|
||||
type = number
|
||||
}
|
||||
|
||||
variable "ec2-instance-type" {
|
||||
default = "t2.micro"
|
||||
description = "The AWS instance type to use for all nodes."
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
################################################################################
|
||||
# AWS EC2 types.
|
||||
# Thesee are only here to help readability. Using these outputs allows the user
|
||||
# to be able to see the resources of each type without having to look them up.
|
||||
################################################################################
|
||||
|
||||
output "t2-micro-1gib-1vcpu" {
|
||||
description = "t2.micro EC2 instance with 1 GiB mem and 1 vCPU."
|
||||
value = "t2.micro"
|
||||
}
|
||||
|
||||
output "t2-small-2gib-1vcpu" {
|
||||
description = "t2.small EC2 instance with 2 GiB mem and 1 vCPUs."
|
||||
value = "t2.small"
|
||||
}
|
||||
|
||||
output "t2-medium-4gib-2vcpu" {
|
||||
description = "t2.medium EC2 instance with 4 GiB mem and 2 vCPUs."
|
||||
value = "t2.medium"
|
||||
}
|
||||
|
||||
output "t2-large-8gib-2vcpu" {
|
||||
description = "t2.large EC2 instance with 8 GiB mem and 2 vCPUs."
|
||||
value = "t2.large"
|
||||
}
|
||||
|
||||
output "t2-xlarge-16gib-4vcpu" {
|
||||
description = "t2.xlarge EC2 instance with 16 GiB mem and 4 vCPUs."
|
||||
value = "t2.xlarge"
|
||||
}
|
||||
|
||||
output "t3a-medium-amd-4gib-2vcpu" {
|
||||
description = "t3a.medium EC2 instance on AMD with GiB mem and 2 vCPUs."
|
||||
value = "t3a.medium"
|
||||
}
|
||||
|
||||
output "t3a-large-amd-8gib-2vcpu" {
|
||||
description = "t3a.large EC2 instance on AMD with 8 GiB mem and 2 vCPUs."
|
||||
value = "t3a.large"
|
||||
}
|
||||
|
||||
output "c5a-xlarge-amd-8gib-4vcpu" {
|
||||
description = "c5a.xlarge EC2 instance on AMD with 8 GiB mem and 4 vCPUs."
|
||||
value = "c5a.xlarge"
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
################################################################################
|
||||
# Libvirt Images
|
||||
# These outputs are really more like constants. Using outputs improves
|
||||
# readability. The values are manually updated.
|
||||
################################################################################
|
||||
|
||||
output "ubuntu-img" {
|
||||
value = "https://cloud-images.ubuntu.com/releases/focal/release/ubuntu-20.04-server-cloudimg-amd64-disk-kvm.img"
|
||||
description = "The libvirt image to use for Ubuntu."
|
||||
}
|
||||
|
||||
output "centos7-img" {
|
||||
# Latest as of 2021-12-06.
|
||||
value = "https://cloud.centos.org/centos/7/images/CentOS-7-x86_64-GenericCloud-2111.qcow2"
|
||||
description = "The libvirt image to use for CentOS 7."
|
||||
}
|
||||
|
||||
output "centos8-img" {
|
||||
value = "https://cloud.centos.org/centos/8/x86_64/images/CentOS-8-GenericCloud-8.4.2105-20210603.0.x86_64.qcow2"
|
||||
description = "The libvirt image to use for CentOS 8."
|
||||
}
|
||||
|
||||
+116
-35
@@ -1,6 +1,6 @@
|
||||
variable "admin-ips" {
|
||||
default = ["0.0.0.0/0"]
|
||||
description = "A list of ips or cidr blocks that are allowed to connect to the nodes. This variable is only used when using the aws-network-from-scratch module."
|
||||
description = "A list of ips or cidr blocks that are allowed to connect to the nodes."
|
||||
type = list(string)
|
||||
}
|
||||
|
||||
@@ -10,52 +10,22 @@ variable "aws-zfs-drive-letters" {
|
||||
type = list(string)
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# Query existing infrastructure.
|
||||
# Variables used to grab existing resources from AWS.
|
||||
#
|
||||
# We have 2 sets of three variables in this section. 1 section has 'managed' in
|
||||
# the name and the other has 'mss-dev' in the name. There are not restrictions
|
||||
# as to what we can put into these VPCs. The names of the variable simply match
|
||||
# the names of the VPCs and have no meaning for what resources are allowed.
|
||||
################################################################################
|
||||
|
||||
variable "aws-existing-managed-sg-name" {
|
||||
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."
|
||||
}
|
||||
|
||||
variable "aws-existing-managed-vpc-name" {
|
||||
variable "aws-existing-vpc-name" {
|
||||
default = "change-me-if-using-aws-network-existing"
|
||||
description = "The name of the existing VPC when using aws-network-existing."
|
||||
}
|
||||
|
||||
variable "aws-existing-managed-subnet-names" {
|
||||
description = "A list of subnet names that already exist in aws-existing-managed-vpc-name"
|
||||
variable "aws-existing-subnet-names" {
|
||||
description = "A list of subnet names that already exist in aws-existing-vpc-name"
|
||||
default = []
|
||||
type = list(string)
|
||||
}
|
||||
|
||||
variable "aws-existing-mss-dev-sg-name" {
|
||||
default = "change-me-if-using-aws-network-existing"
|
||||
description = "The name of the existing security group when using aws-network-existing with the mss-dev VPC."
|
||||
}
|
||||
|
||||
variable "aws-existing-mss-dev-vpc-name" {
|
||||
default = "change-me-if-using-aws-network-existing"
|
||||
description = "The name of the existing VPC when using aws-network-existing with the mss-dev VPC."
|
||||
}
|
||||
|
||||
variable "aws-existing-mss-dev-subnet-names" {
|
||||
description = "A list of subnet names that already exist in aws-existing-mss-dev-vpc-name"
|
||||
default = []
|
||||
type = list(string)
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# End query existing infrastructure.
|
||||
################################################################################
|
||||
|
||||
variable "aws-proxy-private-ip" {
|
||||
description = "The private IP to request for the proxy instance."
|
||||
type = string
|
||||
@@ -120,6 +90,18 @@ variable "root-admin-pub-key" {
|
||||
description = "The public key to be added to authorized_keys for the root and admin accounts."
|
||||
}
|
||||
|
||||
variable "master-nodes" {
|
||||
default = 1
|
||||
description = "The number of master nodes to create."
|
||||
type = number
|
||||
}
|
||||
|
||||
variable "worker-nodes" {
|
||||
default = 2
|
||||
description = "The number of worker nodes to create."
|
||||
type = number
|
||||
}
|
||||
|
||||
variable "base-image" {
|
||||
default = "https://cloud-images.ubuntu.com/releases/focal/release/ubuntu-20.04-server-cloudimg-amd64-disk-kvm.img"
|
||||
}
|
||||
@@ -128,3 +110,102 @@ variable "vm-name-prefix" {
|
||||
default = "k8s-tf"
|
||||
description = "This prefix will appear before all VM names and hostnames, ie. k8s-tf-master-0."
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# AWS AMI vars
|
||||
# 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.
|
||||
################################################################################
|
||||
|
||||
variable "amzn2-ami" {
|
||||
# us-east-2
|
||||
# default = "ami-0dd0ccab7e2801812"
|
||||
# us-gov-west-1
|
||||
default = "ami-098bf51d9a35299f0"
|
||||
description = "The AMI to use for Amazon Linux 2."
|
||||
}
|
||||
variable "ubuntu-ami" {
|
||||
# us-east-2
|
||||
# default = "ami-06c7d6c0987eaa46c"
|
||||
# us-gov-west-1
|
||||
default = "ami-087ee83c8de303181"
|
||||
description = "The AMI to use for Ubuntu."
|
||||
}
|
||||
variable "centos7-ami" {
|
||||
# us-east-2
|
||||
default = "ami-00f8e2c955f7ffa9b"
|
||||
description = "The AMI to use for CentOS 7."
|
||||
}
|
||||
variable "centos8-ami" {
|
||||
# us-east-2
|
||||
default = "ami-057cacbfbbb471bb3"
|
||||
description = "The AMI to use for CentOS 8."
|
||||
}
|
||||
variable "arch-ami" {
|
||||
# us-east-2
|
||||
default = "ami-02653f06de985e3ba"
|
||||
description = "The AMI to use for Arch Linux."
|
||||
}
|
||||
variable "rhel7-ami" {
|
||||
# us-east-2
|
||||
# default = "ami-0a509b3c2a4d05b3f"
|
||||
# us-gov-west-1
|
||||
default = "ami-04ccdf5793086ea95"
|
||||
description = "The AMI to use for RHEL 7."
|
||||
}
|
||||
variable "rhel8-ami" {
|
||||
# us-east-2
|
||||
# default = "ami-0d871ca8a77af2948"
|
||||
# us-gov-west-1
|
||||
default = "ami-0b1f10cd1cd107dd2"
|
||||
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 more like constants. Using variables improves
|
||||
# readability. The defaults are manually updated.
|
||||
################################################################################
|
||||
|
||||
variable "ubuntu-img" {
|
||||
default = "https://cloud-images.ubuntu.com/releases/focal/release/ubuntu-20.04-server-cloudimg-amd64-disk-kvm.img"
|
||||
description = "The libvirt image tp use for Ubuntu."
|
||||
}
|
||||
|
||||
variable "centos7-img" {
|
||||
# Latest as of 2021-12-06.
|
||||
default = "https://cloud.centos.org/centos/7/images/CentOS-7-x86_64-GenericCloud-2111.qcow2"
|
||||
description = "The libvirt image tp use for CentOS 7."
|
||||
}
|
||||
|
||||
variable "centos8-img" {
|
||||
default = "https://cloud.centos.org/centos/8/x86_64/images/CentOS-8-GenericCloud-8.4.2105-20210603.0.x86_64.qcow2"
|
||||
description = "The libvirt image tp use for CentOS 8."
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user