Skip to content

Commit

Permalink
[MM-61281] allow customizable public ip allocation (#868)
Browse files Browse the repository at this point in the history
* feat: allow customizable public ip allocation

* chore: update sample files with new field
  • Loading branch information
fmartingr authored Dec 12, 2024
1 parent 7f6b71e commit cacf82f
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 8 deletions.
2 changes: 2 additions & 0 deletions config/deployer.sample.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"MetricsInstanceType": "t3.xlarge",
"AgentInstanceCount": 2,
"AgentInstanceType": "c7i.xlarge",
"AgentAllocatePublicIPAddress": true,
"ElasticSearchSettings": {
"InstanceCount": 0,
"InstanceType": "r6g.large.search",
Expand All @@ -48,6 +49,7 @@
"EnableAgentFullLogs": true,
"ProxyInstanceCount": 1,
"ProxyInstanceType": "c7i.xlarge",
"ProxyAllocatePublicIPAddress": true,
"SSHPublicKey": "~/.ssh/id_rsa.pub",
"TerraformStateDir" : "/var/lib/mattermost-load-test-ng",
"S3BucketDumpURI" : "",
Expand Down
2 changes: 2 additions & 0 deletions config/deployer.sample.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ EnableNetPeekMetrics = false
AgentInstanceCount = 2
AgentInstanceType = 'c5.xlarge'
EnableAgentFullLogs = true
AgentAllocatePublicIPAddress = true

# App servers configuration
AppInstanceCount = 1
Expand All @@ -43,6 +44,7 @@ TerraformStateDir = '/var/lib/mattermost-load-test-ng'
# Proxy server configuration
ProxyInstanceType = 'c5.xlarge'
ProxyInstanceCount = 1
ProxyAllocatePublicIPAddress = true

[ClusterSubnetIDs]
App = []
Expand Down
4 changes: 4 additions & 0 deletions deployment/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,14 @@ type Config struct {
AgentInstanceType string `default:"c7i.xlarge" validate:"notempty"`
// Logs the command output (stdout & stderr) to home directory.
EnableAgentFullLogs bool `default:"true"`
// Should a pubic IP be allocated for the agent instance.
AgentAllocatePublicIPAddress bool `default:"true"`
// Number of proxy instances.
ProxyInstanceCount int `default:"1" validate:"range:[0,5]"`
// Type of the EC2 instance for proxy.
ProxyInstanceType string `default:"m4.xlarge" validate:"notempty"`
// Should a pubic IP be allocated for the proxy instance.
ProxyAllocatePublicIPAddress bool `default:"true"`
// Path to the SSH public key.
SSHPublicKey string `default:"~/.ssh/id_rsa.pub" validate:"notempty"`
// Terraform database connection and provision settings.
Expand Down
12 changes: 6 additions & 6 deletions deployment/terraform/assets/bindata.go

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions deployment/terraform/assets/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ resource "aws_instance" "proxy_server" {
ami = var.aws_ami
instance_type = var.proxy_instance_type
count = var.proxy_instance_count
associate_public_ip_address = true
associate_public_ip_address = var.proxy_allocate_public_ip_address
availability_zone = var.aws_az
subnet_id = (length(var.cluster_subnet_ids.proxy) > 0) ? element(tolist(var.cluster_subnet_ids.proxy), count.index) : null

Expand Down Expand Up @@ -370,7 +370,7 @@ resource "aws_instance" "loadtest_agent" {
count = var.agent_instance_count
subnet_id = (length(var.cluster_subnet_ids.agent) > 0) ? element(tolist(var.cluster_subnet_ids.agent), count.index) : null

associate_public_ip_address = true
associate_public_ip_address = var.agent_allocate_public_ip_address
availability_zone = var.aws_az

vpc_security_group_ids = [aws_security_group.agent.id]
Expand Down
8 changes: 8 additions & 0 deletions deployment/terraform/assets/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,17 @@ variable "app_instance_count" {
variable "app_instance_type" {
}

# Agent variables

variable "agent_instance_count" {
}

variable "agent_instance_type" {
}

variable "agent_allocate_public_ip_address" {
}

# Elasticsearch variables

variable "es_instance_count" {
Expand Down Expand Up @@ -82,6 +87,9 @@ variable "redis_engine_version" {
variable "proxy_instance_type" {
}

variable "proxy_allocate_public_ip_address" {
}

variable "db_instance_count" {
}

Expand Down
2 changes: 2 additions & 0 deletions deployment/terraform/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ func (t *Terraform) getParams() []string {
"-var", fmt.Sprintf("app_attach_iam_profile=%s", t.config.AppAttachIAMProfile),
"-var", fmt.Sprintf("agent_instance_count=%d", t.config.AgentInstanceCount),
"-var", fmt.Sprintf("agent_instance_type=%s", t.config.AgentInstanceType),
"-var", fmt.Sprintf("agent_allocate_public_ip_address=%t", t.config.AgentAllocatePublicIPAddress),
"-var", fmt.Sprintf("es_instance_count=%d", t.config.ElasticSearchSettings.InstanceCount),
"-var", fmt.Sprintf("es_instance_type=%s", t.config.ElasticSearchSettings.InstanceType),
"-var", fmt.Sprintf("es_version=%s", t.config.ElasticSearchSettings.Version),
Expand All @@ -269,6 +270,7 @@ func (t *Terraform) getParams() []string {
"-var", fmt.Sprintf("es_enable_cloudwatch_logs=%t", t.config.ElasticSearchSettings.EnableCloudwatchLogs),
"-var", fmt.Sprintf("proxy_instance_count=%d", t.config.ProxyInstanceCount),
"-var", fmt.Sprintf("proxy_instance_type=%s", t.config.ProxyInstanceType),
"-var", fmt.Sprintf("proxy_allocate_public_ip_address=%t", t.config.ProxyAllocatePublicIPAddress),
"-var", fmt.Sprintf("ssh_public_key=%s", t.config.SSHPublicKey),
"-var", fmt.Sprintf("db_instance_count=%d", t.config.TerraformDBSettings.InstanceCount),
"-var", fmt.Sprintf("db_instance_engine=%s", t.config.TerraformDBSettings.InstanceEngine),
Expand Down
12 changes: 12 additions & 0 deletions docs/config/deployer.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,12 @@ The number of load-test agent instances. The first instance will also host the [

The type of the EC2 instance of the loadtest agent. See type [here](https://aws.amazon.com/ec2/instance-types/).

## AgentAllocatePublicIPAddress

*bool*

Whether to allocate a public IP address to the agent instances.

## ClusterSubnetIDs

### App
Expand Down Expand Up @@ -251,6 +257,12 @@ Number of proxy instances to run. Right now, only values `0` and `1` are allowed

The type of the EC2 instance of the proxy server. See type [here](https://aws.amazon.com/ec2/instance-types/).

## ProxyAllocatePublicIPAddress

*bool*

Whether to allocate a public IP address to the proxy instances.

## SSHPublicKey

*string*
Expand Down

0 comments on commit cacf82f

Please sign in to comment.