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

fix(DMVP-3677): Runner job to deployment #11

Merged
merged 6 commits into from
Mar 11, 2024
Merged
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
3 changes: 2 additions & 1 deletion modules/runner/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ No modules.

| Name | Type |
|------|------|
| [kubernetes_job.runner](https://registry.terraform.io/providers/hashicorp/kubernetes/2.23.0/docs/resources/job) | resource |
| [kubernetes_deployment.runner](https://registry.terraform.io/providers/hashicorp/kubernetes/2.23.0/docs/resources/deployment) | resource |
| [kubernetes_namespace_v1.runner](https://registry.terraform.io/providers/hashicorp/kubernetes/2.23.0/docs/resources/namespace_v1) | resource |
| [kubernetes_secret.runner](https://registry.terraform.io/providers/hashicorp/kubernetes/2.23.0/docs/resources/secret) | resource |

Expand All @@ -34,6 +34,7 @@ No modules.
| <a name="input_namespace"></a> [namespace](#input\_namespace) | Namespace name | `string` | `"runner"` | no |
| <a name="input_oauthClientId"></a> [oauthClientId](#input\_oauthClientId) | Oauth Client | `string` | n/a | yes |
| <a name="input_oauthClientSecret"></a> [oauthClientSecret](#input\_oauthClientSecret) | Oauth Client Secret | `string` | n/a | yes |
| <a name="input_replica_count"></a> [replica\_count](#input\_replica\_count) | Deployment replica count | `number` | `2` | no |
| <a name="input_runnerUuid"></a> [runnerUuid](#input\_runnerUuid) | Runner Uuid | `string` | n/a | yes |

## Outputs
Expand Down
22 changes: 13 additions & 9 deletions modules/runner/job.tf → modules/runner/deployment.tf
Original file line number Diff line number Diff line change
@@ -1,18 +1,28 @@

resource "kubernetes_job" "runner" {
resource "kubernetes_deployment" "runner" {
metadata {
name = "runner"
namespace = var.namespace
}

spec {
replicas = var.replica_count

selector {
match_labels = {
accountUuid = var.accountUuid
runnerUuid = var.runnerUuid
}
}


template {
metadata {
labels = {
accountUuid = var.accountUuid
runnerUuid = var.runnerUuid
}
}

spec {
container {
name = "bitbucket-k8s-runner"
Expand Down Expand Up @@ -92,7 +102,7 @@ resource "kubernetes_job" "runner" {
mount_path = "/var/run"
}
}
restart_policy = "OnFailure"
restart_policy = "Always"
volume {
name = "tmp"
}
Expand All @@ -106,14 +116,8 @@ resource "kubernetes_job" "runner" {
}
}
}

backoff_limit = 6
completions = 1
parallelism = 1
}

wait_for_completion = false

depends_on = [
kubernetes_secret.runner
]
Expand Down
6 changes: 6 additions & 0 deletions modules/runner/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,9 @@ variable "create_namespace" {
description = "Create namespace or use existing one"
default = true
}

variable "replica_count" {
type = number
default = 2
description = "Deployment replica count"
}
Loading