diff --git a/README.md b/README.md index 22feca2..ea1b8ca 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ Full contributing guidelines are covered [here](CONTRIBUTING.md). | Name | Version | |------|---------| -| [helm](#provider\_helm) | 2.4.1 | +| [helm](#provider\_helm) | 2.5.1 | ## Modules @@ -72,12 +72,14 @@ No modules. | [atomic](#input\_atomic) | whether to deploy the entire module as a unit | `bool` | `true` | no | | [build\_dir](#input\_build\_dir) | Path on nodes for caching | `string` | `null` | no | | [build\_job\_default\_container\_image](#input\_build\_job\_default\_container\_image) | Default container image to use for builds when none is specified | `string` | `"ubuntu:18.04"` | no | +| [build\_job\_limits](#input\_build\_job\_limits) | The CPU allocation given to and the requested for build containers | `map(any)` |
{| no | | [build\_job\_mount\_docker\_socket](#input\_build\_job\_mount\_docker\_socket) | Path on nodes for caching | `bool` | `false` | no | | [build\_job\_node\_selectors](#input\_build\_job\_node\_selectors) | A map of node selectors to apply to the pods | `map` | `{}` | no | | [build\_job\_node\_tolerations](#input\_build\_job\_node\_tolerations) | A map of node tolerations to apply to the pods as defined https://docs.gitlab.com/runner/executors/kubernetes.html#other-configtoml-settings | `map` | `{}` | no | | [build\_job\_pod\_annotations](#input\_build\_job\_pod\_annotations) | A map of annotations to be added to each build pod created by the Runner. The value of these can include environment variables for expansion. Pod annotations can be overwritten in each build. | `map` | `{}` | no | | [build\_job\_pod\_labels](#input\_build\_job\_pod\_labels) | A map of labels to be added to each build pod created by the runner. The value of these can include environment variables for expansion. | `map` | `{}` | no | | [build\_job\_privileged](#input\_build\_job\_privileged) | Run all containers with the privileged flag enabled. This will allow the docker:dind image to run if you need to run Docker | `bool` | `false` | no | +| [build\_job\_requests](#input\_build\_job\_requests) | The CPU allocation given to and the requested for build containers | `map(any)` |
"cpu": "2",
"memory": "1Gi"
}
{| no | | [build\_job\_run\_container\_as\_user](#input\_build\_job\_run\_container\_as\_user) | SecurityContext: runAsUser for all running job pods | `string` | `null` | no | | [build\_job\_secret\_volumes](#input\_build\_job\_secret\_volumes) | Secret volume configuration instructs Kubernetes to use a secret that is defined in Kubernetes cluster and mount it inside of the containes as defined https://docs.gitlab.com/runner/executors/kubernetes.html#secret-volumes |
"cpu": "1",
"memory": "512Mi"
}
object({|
name = string
mount_path = string
read_only = string
items = map(string)
})
{| no | | [cache](#input\_cache) | Describes the properties of the cache. type can be either of ['local', 'gcs', 's3', 'azure'], path defines a path to append to the bucket url, shared specifies whether the cache can be shared between runners. you also specify the individual properties of the particular cache type you select. see https://docs.gitlab.com/runner/configuration/advanced-configuration.html#the-runnerscache-section |
"items": {},
"mount_path": null,
"name": null,
"read_only": null
}
object({|
type = string
path = string
shared = bool
gcs = map(any)
s3 = map(any)
azure = map(any)
})
{| no | diff --git a/config.tf b/config.tf index e1f1424..76f1e30 100644 --- a/config.tf +++ b/config.tf @@ -22,6 +22,10 @@ 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}" %{~if var.build_job_default_container_image != null~} image = "${var.build_job_default_container_image}" %{~endif~} diff --git a/examples/main.tf b/examples/main.tf index ce17d47..73b4474 100644 --- a/examples/main.tf +++ b/examples/main.tf @@ -25,21 +25,20 @@ module "gke_cluster" { # NODE POOL # Node pool for running regular workloads #------------------------------------------------------------ -module "gke_node_pool" { - source = "DeimosCloud/gke/google//modules/gke-node-pool" - version = "1.0.0" - - project_id = var.project_id - name = "default-node-pool" - cluster = module.gke_cluster.name - location = var.region - +resource "google_container_node_pool" "gke_node_pool" { + name = "default-node-pool" + cluster = module.gke_cluster.name initial_node_count = "1" - min_node_count = "1" - max_node_count = "5" - machine_type = var.gke_machine_type + autoscaling { + min_node_count = 1 + max_node_count = 3 + } + node_config { + image_type = "COS" + machine_type = var.gke_machine_type + } } @@ -47,30 +46,31 @@ module "gke_node_pool" { # Gitlab Node Pool # Node pool for running gitlab Jobs #------------------------------------------------------------ -module "gke_node_pool_gitlab" { - source = "DeimosCloud/gke/google//modules/gke-node-pool" - version = "1.0.0" +resource "google_container_node_pool" "gitlab_runner_pool" { + name = "gitlab-runner" + cluster = module.gke_cluster.name + initial_node_count = "0" - project_id = var.project_id - name = "gitlab-runner" - cluster = module.gke_cluster.name - location = var.region + autoscaling { + min_node_count = 0 + max_node_count = 3 + } - initial_node_count = "0" - min_node_count = "0" - max_node_count = "3" + node_config { + image_type = "COS" + machine_type = var.runner_machine_type - machine_type = var.runner_machine_type + # Labels will be used in node selectors to ensure pods get scheduled to nodes with the same labels + labels = local.labels - # Only pods that tolerate this taint will be scheduled here - taints = [{ - key = "node.gitlab.ci/dedicated" - value = "true" - effect = "NO_SCHEDULE" - }] + # Only pods that tolerate this taint will be scheduled here + taint = [{ + key = "node.gitlab.ci/dedicated" + value = "true" + effect = "NO_SCHEDULE" + }] + } - # Labels will be used in node selectors to ensure pods get scheduled to nodes with the same labels - labels = local.labels } @@ -102,5 +102,5 @@ module "gitlab-runner" { "node.gitlab.ci/dedicated=true" = "NO_SCHEDULE" } - depends_on = [module.gke_cluster] + depends_on = [google_container_node_pool.gitlab_runner_pool] } diff --git a/local.tf b/local.tf index f9bee04..232f9e7 100644 --- a/local.tf +++ b/local.tf @@ -14,3 +14,4 @@ locals { } cache_secret_name = lookup(local.cache_secret_config, var.cache.type, "") } + diff --git a/variables.tf b/variables.tf index c0a5c97..81f0cdc 100644 --- a/variables.tf +++ b/variables.tf @@ -265,3 +265,22 @@ variable "cache" { azure = {} } } + +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" + } +} +
"azure": {},
"gcs": {},
"path": "",
"s3": {},
"shared": false,
"type": "local"
}