Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add support for session server #432

Draft
wants to merge 13 commits into
base: develop
Choose a base branch
from
10 changes: 10 additions & 0 deletions locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@ locals {
# Ensure max builds is optional
runners_max_builds_string = var.runners_max_builds == 0 ? "" : format("MaxBuilds = %d", var.runners_max_builds)

# convert the options for the session server
session_server_string = var.session_server == null ? "" : join("",
formatlist("%s", [
format(" listen_address = \"[::]:%d\"\n", var.session_server.port),
format(" advertise_address = \"%s:%d\"\n", aws_eip.gitlab_runner[0].public_ip, var.session_server.port),
format(" session_timeout = %s\n", var.session_server.timeout)
]
)
)

# Define key for runner token for SSM
secure_parameter_store_runner_token_key = "${var.environment}-${var.secure_parameter_store_runner_token_key}"
secure_parameter_store_runner_sentry_dsn = "${var.environment}-${var.secure_parameter_store_runner_sentry_dsn}"
Expand Down
1 change: 1 addition & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ locals {
bucket_name = local.bucket_name
shared_cache = var.cache_shared
sentry_dsn = var.sentry_dsn
session_server_string = var.session_server == null ? "" : local.session_server_string
prometheus_listen_address = var.prometheus_listen_address
auth_type = var.auth_type_cache_sr
}
Expand Down
13 changes: 13 additions & 0 deletions security_groups.tf
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,19 @@ resource "aws_security_group" "runner" {
)
}

# Allow incoming traffic from Gitlab for the session server to Gitlab Runner
resource "aws_security_group_rule" "runner_session_server" {
count = var.session_server == null ? 0 : 1

type = "ingress"
from_port = var.session_server["port"]
to_port = var.session_server["port"]
protocol = "tcp"

cidr_blocks = var.session_server["gitlab_cidr_block"]
security_group_id = aws_security_group.runner.id
}

########################################
## Security group IDs to runner agent ##
########################################
Expand Down
3 changes: 3 additions & 0 deletions template/runner-config.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ sentry_dsn = "${sentry_dsn}"
log_format = "json"
listen_address = "${prometheus_listen_address}"

[session_server]
${session_server_string}

[[runners]]
name = "${runners_name}"
url = "${gitlab_url}"
Expand Down
12 changes: 12 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -829,6 +829,18 @@ variable "docker_machine_egress_rules" {
}]
}

variable "session_server" {
description = "Enables the session server support. Requires enable_eip = true!"
type = object({
timeout = number # Time in seconds how long the session stays active after the job completes. (1800)
port = number # Port which is used to connect to the session server. (8093)
gitlab_cidr_block = list(string) # CIDR block of the Gitlab server which connects to the Gitlab Runner
}
)

default = null
}

variable "subnet_id_runners" {
description = "Deprecated! Use subnet_id instead. List of subnets used for hosting the gitlab-runners."
type = string
Expand Down