Skip to content

Commit

Permalink
Sizing for nodes storage (#11)
Browse files Browse the repository at this point in the history
* Adjust node groups volumes based on sizing
* Set artifactory cache-fs size based on 80% of node disk size
  • Loading branch information
eldada authored Dec 10, 2024
1 parent bdd5a92 commit 783948c
Show file tree
Hide file tree
Showing 8 changed files with 293 additions and 48 deletions.
12 changes: 12 additions & 0 deletions 6.artifactory-aws-install/artifactory.tf
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ provider "kubernetes" {

# Fetch the Artifactory Helm chart and untar it to the current directory so helm install can use the sizing files
resource "null_resource" "shell" {
provisioner "local-exec" {
command = "rm -rf artifactory-*.tgz"
}
provisioner "local-exec" {
command = "helm fetch artifactory --version ${var.artifactory_chart_version} --repo https://charts.jfrog.io --untar"
}
Expand All @@ -25,11 +28,20 @@ resource "local_file" "empty_license" {
content = "## Empty file to satisfy Helm requirements"
}

# Set the cache-fs-size based on the sizing variable to 80% of the disk size
locals {
cache-fs-size = (var.sizing == "large" ? var.artifactory_disk_size_large * 0.8 :
var.sizing == "xlarge" ? var.artifactory_disk_size_large * 0.8 :
var.sizing == "2xlarge" ? var.artifactory_disk_size_large * 0.8 :
var.artifactory_disk_size_default * 0.8)
}

# Write the artifactory-custom.yaml file with the variables needed
resource "local_file" "artifactory_values" {
content = <<-EOT
artifactory:
persistence:
maxCacheSize: "${local.cache-fs-size}000000000"
awsS3V3:
region: "${var.region}"
bucketName: "artifactory-${var.region}-${var.s3_bucket_name_suffix}"
Expand Down
44 changes: 34 additions & 10 deletions 6.artifactory-aws-install/eks.tf
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,21 @@ module "eks" {
AmazonS3FullAccess = "arn:aws:iam::aws:policy/AmazonS3FullAccess"
AmazonEBSCSIDriverPolicy = "arn:aws:iam::aws:policy/service-role/AmazonEBSCSIDriverPolicy"
}
pre_bootstrap_user_data = <<-EOF
# This script will run on all nodes before the kubelet starts
echo "It works!" > /tmp/pre_bootstrap_user_data.txt
EOF
block_device_mappings = {
xvda = {
device_name = "/dev/xvda"
ebs = {
volume_size = 100
volume_type = "gp3"
iops = 3000
throughput = 200
volume_type = "gp3"
volume_size = 50
throughput = 250
delete_on_termination = true
}
}
}
pre_bootstrap_user_data = <<-EOF
# This script will run on all nodes before the kubelet starts
echo "It works!" > /tmp/pre_bootstrap_user_data.txt
EOF
tags = {
Group = var.common_tag
}
Expand All @@ -71,7 +70,6 @@ module "eks" {
var.sizing == "2xlarge" ? var.artifactory_node_size_large :
var.artifactory_node_size_default
)]

min_size = 1
max_size = 10
desired_size = (
Expand All @@ -81,7 +79,33 @@ module "eks" {
var.sizing == "2xlarge" ? 6 :
1
)

block_device_mappings = {
xvda = {
device_name = "/dev/xvda"
ebs = {
volume_type = "gp3"
volume_size = (
var.sizing == "large" ? var.artifactory_disk_size_large :
var.sizing == "xlarge" ? var.artifactory_disk_size_large :
var.sizing == "2xlarge" ? var.artifactory_disk_size_large :
var.artifactory_disk_size_default
)
iops = (
var.sizing == "large" ? var.artifactory_disk_iops_large :
var.sizing == "xlarge" ? var.artifactory_disk_iops_large :
var.sizing == "2xlarge" ? var.artifactory_disk_iops_large :
var.artifactory_disk_iops_default
)
throughput = (
var.sizing == "large" ? var.artifactory_disk_throughput_large :
var.sizing == "xlarge" ? var.artifactory_disk_throughput_large :
var.sizing == "2xlarge" ? var.artifactory_disk_throughput_large :
var.artifactory_disk_throughput_default
)
delete_on_termination = true
}
}
}
labels = {
"group" = "artifactory"
}
Expand Down
22 changes: 11 additions & 11 deletions 6.artifactory-aws-install/rds.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,23 @@ resource "aws_db_instance" "artifactory_db" {

# Set the instance class based on the sizing variable
instance_class = (
var.sizing == "medium" ? var.artifactory_rds_size_medium :
var.sizing == "large" ? var.artifactory_rds_size_large :
var.sizing == "xlarge" ? var.artifactory_rds_size_xlarge :
var.sizing == "2xlarge" ? var.artifactory_rds_size_2xlarge :
var.artifactory_rds_size_default
var.sizing == "medium" ? var.artifactory_rds_size_medium :
var.sizing == "large" ? var.artifactory_rds_size_large :
var.sizing == "xlarge" ? var.artifactory_rds_size_xlarge :
var.sizing == "2xlarge" ? var.artifactory_rds_size_2xlarge :
var.artifactory_rds_size_default
)

storage_type = "gp3"
allocated_storage = (
var.sizing == "medium" ? "250" :
var.sizing == "large" ? "500" :
var.sizing == "xlarge" ? "1000" :
var.sizing == "2xlarge" ? "1500" :
"100"
var.sizing == "medium" ? var.artifactory_rds_disk_size_medium :
var.sizing == "large" ? var.artifactory_rds_disk_size_large :
var.sizing == "xlarge" ? var.artifactory_rds_disk_size_xlarge :
var.sizing == "2xlarge" ? var.artifactory_rds_disk_size_2xlarge :
var.artifactory_rds_disk_size_default
)

max_allocated_storage = 2000 # Set maximum size for storage autoscaling (optional)
max_allocated_storage = var.artifactory_rds_disk_max_size
storage_encrypted = true

db_name = var.db_name
Expand Down
48 changes: 48 additions & 0 deletions 6.artifactory-aws-install/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,30 @@ variable "artifactory_rds_size_2xlarge" {
default = "db.m7g.16xlarge"
}

variable "artifactory_rds_disk_size_default" {
default = 100
}

variable "artifactory_rds_disk_size_medium" {
default = 250
}

variable "artifactory_rds_disk_size_large" {
default = 500
}

variable "artifactory_rds_disk_size_xlarge" {
default = 1000
}

variable "artifactory_rds_disk_size_2xlarge" {
default = 1500
}

variable "artifactory_rds_disk_max_size" {
default = 2000
}

variable "artifactory_node_size_default" {
default = "m7g.2xlarge"
}
Expand All @@ -76,6 +100,30 @@ variable "artifactory_node_size_large" {
default = "m7g.4xlarge"
}

variable "artifactory_disk_size_default" {
default = 500
}

variable "artifactory_disk_size_large" {
default = 1000
}

variable "artifactory_disk_iops_default" {
default = 3000
}

variable "artifactory_disk_iops_large" {
default = 6000
}

variable "artifactory_disk_throughput_default" {
default = 500
}

variable "artifactory_disk_throughput_large" {
default = 1000
}

variable "nginx_node_size_default" {
default = "c7g.xlarge"
}
Expand Down
83 changes: 69 additions & 14 deletions 7.jfrog-platform-aws-install/eks.tf
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,21 @@ module "eks" {
AmazonS3FullAccess = "arn:aws:iam::aws:policy/AmazonS3FullAccess"
AmazonEBSCSIDriverPolicy = "arn:aws:iam::aws:policy/service-role/AmazonEBSCSIDriverPolicy"
}
pre_bootstrap_user_data = <<-EOF
# This script will run on all nodes before the kubelet starts
echo "It works!" > /tmp/pre_bootstrap_user_data.txt
EOF
block_device_mappings = {
xvda = {
device_name = "/dev/xvda"
ebs = {
volume_size = 100
volume_type = "gp3"
iops = 3000
throughput = 200
volume_type = "gp3"
volume_size = 50
throughput = 250
delete_on_termination = true
}
}
}
pre_bootstrap_user_data = <<-EOF
# This script will run on all nodes before the kubelet starts
echo "It works!" > /tmp/pre_bootstrap_user_data.txt
EOF
tags = {
Group = var.common_tag
}
Expand All @@ -71,7 +70,6 @@ module "eks" {
var.sizing == "2xlarge" ? var.artifactory_node_size_large :
var.artifactory_node_size_default
)]

min_size = 1
max_size = 10
desired_size = (
Expand All @@ -81,7 +79,33 @@ module "eks" {
var.sizing == "2xlarge" ? 6 :
1
)

block_device_mappings = {
xvda = {
device_name = "/dev/xvda"
ebs = {
volume_type = "gp3"
volume_size = (
var.sizing == "large" ? var.artifactory_disk_size_large :
var.sizing == "xlarge" ? var.artifactory_disk_size_large :
var.sizing == "2xlarge" ? var.artifactory_disk_size_large :
var.artifactory_disk_size_default
)
iops = (
var.sizing == "large" ? var.artifactory_disk_iops_large :
var.sizing == "xlarge" ? var.artifactory_disk_iops_large :
var.sizing == "2xlarge" ? var.artifactory_disk_iops_large :
var.artifactory_disk_iops_default
)
throughput = (
var.sizing == "large" ? var.artifactory_disk_throughput_large :
var.sizing == "xlarge" ? var.artifactory_disk_throughput_large :
var.sizing == "2xlarge" ? var.artifactory_disk_throughput_large :
var.artifactory_disk_throughput_default
)
delete_on_termination = true
}
}
}
labels = {
"group" = "artifactory"
}
Expand Down Expand Up @@ -119,11 +143,42 @@ module "eks" {
var.sizing == "2xlarge" ? var.xray_node_size_xlarge :
var.xray_node_size_default
)]

min_size = 1
max_size = 4
desired_size = 1

max_size = 10
desired_size = (
var.sizing == "medium" ? 2 :
var.sizing == "large" ? 3 :
var.sizing == "xlarge" ? 4 :
var.sizing == "2xlarge" ? 6 :
1
)
block_device_mappings = {
xvda = {
device_name = "/dev/xvda"
ebs = {
volume_type = "gp3"
volume_size = (
var.sizing == "large" ? var.xray_disk_size_large :
var.sizing == "xlarge" ? var.xray_disk_size_large :
var.sizing == "2xlarge" ? var.xray_disk_size_large :
var.xray_disk_size_default
)
iops = (
var.sizing == "large" ? var.xray_disk_iops_large :
var.sizing == "xlarge" ? var.xray_disk_iops_large :
var.sizing == "2xlarge" ? var.xray_disk_iops_large :
var.xray_disk_iops_default
)
throughput = (
var.sizing == "large" ? var.xray_disk_throughput_large :
var.sizing == "xlarge" ? var.xray_disk_throughput_large :
var.sizing == "2xlarge" ? var.xray_disk_throughput_large :
var.xray_disk_throughput_default
)
delete_on_termination = true
}
}
}
labels = {
"group" = "xray"
}
Expand Down
9 changes: 9 additions & 0 deletions 7.jfrog-platform-aws-install/jfrog-platform.tf
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,21 @@ resource "local_file" "empty_license" {
content = "## Empty file to satisfy Helm requirements"
}

# Set the cache-fs-size based on the sizing variable to 80% of the disk size
locals {
cache-fs-size = (var.sizing == "large" ? var.artifactory_disk_size_large * 0.8 :
var.sizing == "xlarge" ? var.artifactory_disk_size_large * 0.8 :
var.sizing == "2xlarge" ? var.artifactory_disk_size_large * 0.8 :
var.artifactory_disk_size_default * 0.8)
}

# Write the artifactory-custom.yaml file with the variables needed
resource "local_file" "jfrog_platform_values" {
content = <<-EOT
artifactory:
artifactory:
persistence:
maxCacheSize: "${local.cache-fs-size}000000000"
awsS3V3:
region: "${var.region}"
bucketName: "artifactory-${var.region}-${var.s3_bucket_name_suffix}"
Expand Down
25 changes: 13 additions & 12 deletions 7.jfrog-platform-aws-install/rds.tf
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ resource "aws_db_instance" "artifactory_db" {
identifier = "artifactory-db"
engine = "postgres"
engine_version = var.rds_postgres_version

# Set the instance class based on the sizing variable
instance_class = (
var.sizing == "medium" ? var.artifactory_rds_size_medium :
Expand All @@ -24,14 +25,14 @@ resource "aws_db_instance" "artifactory_db" {

storage_type = "gp3"
allocated_storage = (
var.sizing == "medium" ? "250" :
var.sizing == "large" ? "500" :
var.sizing == "xlarge" ? "1000" :
var.sizing == "2xlarge" ? "1500" :
"100"
var.sizing == "medium" ? var.artifactory_rds_disk_size_medium :
var.sizing == "large" ? var.artifactory_rds_disk_size_large :
var.sizing == "xlarge" ? var.artifactory_rds_disk_size_xlarge :
var.sizing == "2xlarge" ? var.artifactory_rds_disk_size_2xlarge :
var.artifactory_rds_disk_size_default
)

max_allocated_storage = 2000 # Set maximum size for storage autoscaling (optional)
max_allocated_storage = var.artifactory_rds_disk_max_size
storage_encrypted = true

db_name = var.artifactory_db_name
Expand Down Expand Up @@ -62,14 +63,14 @@ resource "aws_db_instance" "xray_db" {

storage_type = "gp3"
allocated_storage = (
var.sizing == "medium" ? "250" :
var.sizing == "large" ? "500" :
var.sizing == "xlarge" ? "1000" :
var.sizing == "2xlarge" ? "1500" :
"100"
var.sizing == "medium" ? var.xray_rds_disk_size_medium :
var.sizing == "large" ? var.xray_rds_disk_size_large :
var.sizing == "xlarge" ? var.xray_rds_disk_size_xlarge :
var.sizing == "2xlarge" ? var.xray_rds_disk_size_2xlarge :
var.xray_rds_disk_size_default
)

max_allocated_storage = 2000 # Set maximum size for storage autoscaling (optional)
max_allocated_storage = var.xray_rds_disk_max_size
storage_encrypted = true

db_name = var.xray_db_name
Expand Down
Loading

0 comments on commit 783948c

Please sign in to comment.