Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions config.tf
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ locals {
%{~endfor~}
%{~endif}
[runners.kubernetes]
cpu_limit = "${var.build_job_limits.cpu}"
cpu_request = "${var.build_job_requests.cpu}"
memory_limit = "${var.build_job_limits.memory}"
memory_request = "${var.build_job_requests.memory}"
%{~for key, value in var.job_resources~}
%{~if value != null~}
${key} = "${value}"
%{~endif~}
%{~endfor~}
%{~if var.build_job_default_container_image != null~}
image = "${var.build_job_default_container_image}"
%{~endif~}
Expand All @@ -35,7 +36,8 @@ locals {
service_account = "${var.service_account}"
%{~endif~}
image_pull_secrets = ${jsonencode(var.image_pull_secrets)}
privileged = ${var.build_job_privileged}
privileged = ${var.build_job_privileged}
pull_policy = ${jsonencode(var.pull_policy)}
[runners.kubernetes.affinity]
[runners.kubernetes.node_selector]
%{~for key, value in var.build_job_node_selectors~}
Expand All @@ -58,7 +60,7 @@ locals {
fs_group = ${var.docker_fs_group}
%{~endif~}
%{~if var.build_job_run_container_as_user != null~}
run_as_user: ${var.build_job_run_container_as_user}
run_as_user = ${var.build_job_run_container_as_user}
%{~endif~}
[runners.kubernetes.volumes]
%{~if var.build_job_mount_docker_socket~}
Expand Down
1 change: 1 addition & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ resource "helm_release" "gitlab_runner" {
version = var.chart_version
create_namespace = var.create_namespace
atomic = var.atomic
max_history = 10

values = [
yamlencode({
Expand Down
63 changes: 45 additions & 18 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@ variable "runner_image" {
type = string
}

variable "pull_policy" {
description = "Specify the job images pull policy: never, if-not-present, always."
type = set(string)
default = ["if-not-present"]
validation {
condition = length(setsubtract(var.pull_policy, ["never", "if-not-present", "always"])) == 0
error_message = "Must be of values: \"never\", \"if-not-present\", \"always\"."
}
}

variable "create_namespace" {
type = bool
default = true
Expand Down Expand Up @@ -88,7 +98,7 @@ variable "values_file" {
variable "values" {
description = "Additional values to be passed to the gitlab-runner helm chart"
default = {}
type = map(any)
type = any
}

variable "gitlab_url" {
Expand Down Expand Up @@ -285,21 +295,38 @@ variable "cache" {
}
}

variable "build_job_limits" {
description = "The CPU allocation given to and the requested for build containers"
type = map(any)
default = {
cpu = "2"
memory = "1Gi"
}
}

variable "build_job_requests" {
description = "The CPU allocation given to and the requested for build containers"
type = map(any)
default = {
cpu = "1"
memory = "512Mi"
}
variable "job_resources" {
description = "The CPU and memory resources given to service containers."
type = object({
// builder containers
cpu_limit : optional(string)
cpu_limit_overwrite_max_allowed : optional(string)
cpu_request : optional(string)
cpu_request_overwrite_max_allowed : optional(string)
memory_limit : optional(string)
memory_limit_overwrite_max_allowed : optional(string)
memory_request : optional(string)
memory_request_overwrite_max_allowed : optional(string)

// helper containers
helper_cpu_limit : optional(string)
helper_cpu_limit_overwrite_max_allowed : optional(string)
helper_cpu_request : optional(string)
helper_cpu_request_overwrite_max_allowed : optional(string)
helper_memory_limit : optional(string)
helper_memory_limit_overwrite_max_allowed : optional(string)
helper_memory_request : optional(string)
helper_memory_request_overwrite_max_allowed : optional(string)

// service containers
service_cpu_limit : optional(string)
service_cpu_limit_overwrite_max_allowed : optional(string)
service_cpu_request : optional(string)
service_cpu_request_overwrite_max_allowed : optional(string)
service_memory_limit : optional(string)
service_memory_limit_overwrite_max_allowed : optional(string)
service_memory_request : optional(string)
service_memory_request_overwrite_max_allowed : optional(string)
})
default = {}
}