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
3 changes: 3 additions & 0 deletions .github/workflows/deploy-infra.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,15 @@ jobs:
make copy-public-builds

- name: Plan infrastructure
env:
GIT_COMMIT_SHA: ${{ inputs.commit_sha }}
run: |
make plan-without-jobs

- name: Apply infrastructure
if: inputs.plan_only == 'false'
env:
AUTO_CONFIRM_DEPLOY: true
GIT_COMMIT_SHA: ${{ inputs.commit_sha }}
run: |
make apply
1 change: 1 addition & 0 deletions .github/workflows/deploy-job.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ jobs:
- name: Deploy jobs
env:
AUTO_CONFIRM_DEPLOY: true
GIT_COMMIT_SHA: ${{ inputs.commit_sha }}
run: |
# Parse semicolon-separated job names
IFS=';' read -ra JOBS <<< "${{ inputs.job_names }}"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
job "clickhouse-backup-restore" {
meta {
git_commit_sha = "${git_commit_sha}"
}
type = "batch"
node_pool = "${node_pool}"

Expand Down
3 changes: 3 additions & 0 deletions iac/modules/job-clickhouse/jobs/clickhouse-backup.hcl
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
job "clickhouse-backup" {
meta {
git_commit_sha = "${git_commit_sha}"
}
type = "batch"
node_pool = "${node_pool}"

Expand Down
3 changes: 3 additions & 0 deletions iac/modules/job-clickhouse/jobs/clickhouse-migrator.hcl
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
job "clickhouse-migrator" {
meta {
git_commit_sha = "${git_commit_sha}"
}
type = "batch"
node_pool = "${node_pool}"

Expand Down
3 changes: 3 additions & 0 deletions iac/modules/job-clickhouse/jobs/clickhouse.hcl
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
job "clickhouse" {
meta {
git_commit_sha = "${git_commit_sha}"
}
type = "service"
node_pool = "${node_pool}"

Expand Down
5 changes: 4 additions & 1 deletion iac/modules/job-clickhouse/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ locals {
})

backup_vars = {
git_commit_sha = var.git_commit_sha
clickhouse_backup_version = var.clickhouse_backup_version

server_count = var.server_count
Expand All @@ -43,6 +44,7 @@ resource "nomad_job" "clickhouse" {
count = var.server_count > 0 ? 1 : 0

jobspec = templatefile("${path.module}/jobs/clickhouse.hcl", {
git_commit_sha = var.git_commit_sha
server_secret = var.server_secret
clickhouse_version = var.clickhouse_version

Expand Down Expand Up @@ -79,7 +81,8 @@ resource "nomad_job" "clickhouse_migrator" {
count = var.server_count > 0 ? 1 : 0

jobspec = templatefile("${path.module}/jobs/clickhouse-migrator.hcl", {
image = var.clickhouse_migrator_image
git_commit_sha = var.git_commit_sha
image = var.clickhouse_migrator_image

server_count = var.server_count
job_constraint_prefix = var.job_constraint_prefix
Expand Down
5 changes: 5 additions & 0 deletions iac/modules/job-clickhouse/variables.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
variable "git_commit_sha" {
description = "Git commit SHA of the deployment"
type = string
}

variable "provider_name" {
type = string
description = "Cloud provider: gcp or aws"
Expand Down
3 changes: 3 additions & 0 deletions iac/modules/job-client-proxy/jobs/client-proxy.hcl
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
job "client-proxy" {
meta {
git_commit_sha = "${git_commit_sha}"
}
node_pool = "${node_pool}"
priority = 80

Expand Down
1 change: 1 addition & 0 deletions iac/modules/job-client-proxy/main.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
resource "nomad_job" "client_proxy" {
jobspec = templatefile("${path.module}/jobs/client-proxy.hcl", {
git_commit_sha = var.git_commit_sha
update_stanza = var.update_stanza
count = var.client_proxy_count
cpu_count = var.client_proxy_cpu_count
Expand Down
5 changes: 5 additions & 0 deletions iac/modules/job-client-proxy/variables.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
variable "git_commit_sha" {
description = "Git commit SHA of the deployment"
type = string
}

variable "update_stanza" {
type = bool
}
Expand Down
3 changes: 3 additions & 0 deletions iac/modules/job-ingress/jobs/ingress.hcl
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
job "ingress" {
meta {
git_commit_sha = "${git_commit_sha}"
}
node_pool = "${node_pool}"
priority = 90

Expand Down
11 changes: 6 additions & 5 deletions iac/modules/job-ingress/main.tf
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
resource "nomad_job" "ingress" {
jobspec = templatefile("${path.module}/jobs/ingress.hcl", {
count = var.ingress_count
node_pool = var.node_pool
update_stanza = var.update_stanza
cpu_count = var.ingress_cpu_count
memory_mb = var.ingress_memory_mb
git_commit_sha = var.git_commit_sha
count = var.ingress_count
node_pool = var.node_pool
update_stanza = var.update_stanza
cpu_count = var.ingress_cpu_count
memory_mb = var.ingress_memory_mb

ingress_port = var.ingress_proxy_port
control_port = var.ingress_control_port
Expand Down
5 changes: 5 additions & 0 deletions iac/modules/job-ingress/variables.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
variable "git_commit_sha" {
description = "Git commit SHA of the deployment"
type = string
}

variable "nomad_token" {
type = string
sensitive = true
Expand Down
3 changes: 3 additions & 0 deletions iac/modules/job-logs-collector/jobs/logs-collector.hcl
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
job "logs-collector" {
meta {
git_commit_sha = "${git_commit_sha}"
}
type = "system"
node_pool = "all"

Expand Down
1 change: 1 addition & 0 deletions iac/modules/job-logs-collector/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ locals {

resource "nomad_job" "logs_collector" {
jobspec = templatefile("${path.module}/jobs/logs-collector.hcl", {
git_commit_sha = var.git_commit_sha
vector_api_port = var.vector_api_port
vector_health_port = var.vector_health_port
vector_config = local.vector_config
Expand Down
5 changes: 5 additions & 0 deletions iac/modules/job-logs-collector/variables.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
variable "git_commit_sha" {
description = "Git commit SHA of the deployment"
type = string
}

variable "vector_api_port" {
type = number
}
Expand Down
3 changes: 3 additions & 0 deletions iac/modules/job-loki/jobs/loki.hcl
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
job "loki" {
meta {
git_commit_sha = "${git_commit_sha}"
}
type = "service"
node_pool = "${node_pool}"
priority = 75
Expand Down
1 change: 1 addition & 0 deletions iac/modules/job-loki/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ locals {

resource "nomad_job" "loki" {
jobspec = templatefile("${path.module}/jobs/loki.hcl", {
git_commit_sha = var.git_commit_sha
node_pool = var.node_pool
prevent_colocation = var.prevent_colocation

Expand Down
5 changes: 5 additions & 0 deletions iac/modules/job-loki/variables.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
variable "git_commit_sha" {
description = "Git commit SHA of the deployment"
type = string
}


variable "provider_name" {
type = string
Expand Down
3 changes: 3 additions & 0 deletions iac/modules/job-orchestrator/jobs/orchestrator.hcl
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
job "orchestrator-${latest_orchestrator_job_id}" {
meta {
git_commit_sha = "${git_commit_sha}"
}
type = "system"
node_pool = "${node_pool}"

Expand Down
7 changes: 4 additions & 3 deletions iac/modules/job-orchestrator/main.tf
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
locals {
orchestrator_vars = {
node_pool = var.node_pool
port = var.port
proxy_port = var.proxy_port
git_commit_sha = var.git_commit_sha
node_pool = var.node_pool
port = var.port
proxy_port = var.proxy_port

environment = var.environment
logs_collector_address = var.logs_collector_address
Expand Down
5 changes: 5 additions & 0 deletions iac/modules/job-orchestrator/variables.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
variable "git_commit_sha" {
description = "Git commit SHA of the deployment"
type = string
}

variable "provider_name" {
type = string
description = "Cloud provider: gcp or aws"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
job "otel-collector-nomad-server" {
meta {
git_commit_sha = "${git_commit_sha}"
}
type = "service"
node_pool = "${node_pool}"

Expand Down
6 changes: 6 additions & 0 deletions iac/modules/job-otel-collector-nomad-server/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,17 @@ locals {

resource "nomad_job" "otel_collector_nomad_server" {
jobspec = templatefile("${path.module}/jobs/otel-collector-nomad-server.hcl", {
git_commit_sha = var.git_commit_sha
node_pool = var.node_pool
otel_collector_config = local.otel_collector_config
})
}

variable "git_commit_sha" {
description = "Git commit SHA of the deployment"
type = string
}

variable "provider_name" {
type = string
description = "Cloud provider: gcp or aws"
Expand Down
3 changes: 3 additions & 0 deletions iac/modules/job-otel-collector/jobs/otel-collector.hcl
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
job "otel-collector" {
meta {
git_commit_sha = "${git_commit_sha}"
}
type = "system"
node_pool = "all"

Expand Down
10 changes: 8 additions & 2 deletions iac/modules/job-otel-collector/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,20 @@ locals {

resource "nomad_job" "otel_collector" {
jobspec = templatefile("${path.module}/jobs/otel-collector.hcl", {
memory_mb = var.memory_mb
cpu_count = var.cpu_count
git_commit_sha = var.git_commit_sha
memory_mb = var.memory_mb
cpu_count = var.cpu_count

otel_collector_grpc_port = var.otel_collector_grpc_port
otel_collector_config = local.otel_collector_config
})
}

variable "git_commit_sha" {
description = "Git commit SHA of the deployment"
type = string
}

variable "provider_name" {
type = string
description = "Cloud provider: gcp or aws"
Expand Down
4 changes: 4 additions & 0 deletions iac/provider-gcp/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ ENV_FILE := ../../.env.${ENV}

-include ${ENV_FILE}

# Default to current git commit SHA if not set via environment
GIT_COMMIT_SHA ?= $(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wouldn't this be annoying for dev where you rebuild just one job, but then run make plan ; make apply?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would it be possible to set up terraform to ignore_changes for this somehow?


TF := $(shell which terraform)
TF_VAR_FILE := ./.terraform.${ENV}.tfvars
TF_VAR_FILE_ARG := $(if $(wildcard $(TF_VAR_FILE)),-var-file=$(TF_VAR_FILE))
Expand All @@ -18,6 +21,7 @@ endef

tf_vars := \
TF_VAR_environment=$(TERRAFORM_ENVIRONMENT) \
$(call tfvar, GIT_COMMIT_SHA) \
$(call tfvar, BUILD_CLUSTERS_CONFIG) \
$(call tfvar, CLIENT_CLUSTERS_CONFIG) \
$(call tfvar, API_MACHINE_TYPE) \
Expand Down
2 changes: 2 additions & 0 deletions iac/provider-gcp/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ module "cluster" {
module "nomad" {
source = "./nomad"

git_commit_sha = var.git_commit_sha

prefix = var.prefix
gcp_project_id = var.gcp_project_id
gcp_region = var.gcp_region
Expand Down
1 change: 1 addition & 0 deletions iac/provider-gcp/nomad/clean-nfs-cache.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ resource "nomad_job" "clean_nfs_cache" {
count = var.shared_chunk_cache_path != "" ? 1 : 0

jobspec = templatefile("${path.module}/jobs/clean-nfs-cache.hcl", {
git_commit_sha = var.git_commit_sha
node_pool = var.builder_node_pool
bucket_name = var.fc_env_pipeline_bucket_name
environment = var.environment
Expand Down
4 changes: 4 additions & 0 deletions iac/provider-gcp/nomad/jobs/api.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ job "api" {
node_pool = "${node_pool}"
priority = 90

meta {
git_commit_sha = "${git_commit_sha}"
}

group "api-service" {
// Try to restart the task indefinitely
// Tries to restart every 5 seconds
Expand Down
4 changes: 4 additions & 0 deletions iac/provider-gcp/nomad/jobs/clean-nfs-cache.hcl
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
job "filestore-cleanup" {
type = "batch"
node_pool = "${node_pool}"
meta {
git_commit_sha = "${git_commit_sha}"
}


datacenters = ["*"]

Expand Down
4 changes: 4 additions & 0 deletions iac/provider-gcp/nomad/jobs/docker-reverse-proxy.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ job "docker-reverse-proxy" {
node_pool = "${node_pool}"
type = "service"
priority = 85
meta {
git_commit_sha = "${git_commit_sha}"
}


group "reverse-proxy" {
// Try to restart the task indefinitely
Expand Down
4 changes: 4 additions & 0 deletions iac/provider-gcp/nomad/jobs/nomad-autoscaler.hcl
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
job "nomad-autoscaler" {
type = "service"
node_pool = "${node_pool}"
meta {
git_commit_sha = "${git_commit_sha}"
}


group "autoscaler" {
count = 1
Expand Down
4 changes: 4 additions & 0 deletions iac/provider-gcp/nomad/jobs/redis.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ job "redis" {
node_pool = "${node_pool}"
type = "service"
priority = 95
meta {
git_commit_sha = "${git_commit_sha}"
}


group "redis" {
// Try to restart the task indefinitely
Expand Down
4 changes: 4 additions & 0 deletions iac/provider-gcp/nomad/jobs/template-manager.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ job "template-manager" {
type = "service"
node_pool = "${node_pool}"
priority = 75
meta {
git_commit_sha = "${git_commit_sha}"
}


group "template-manager" {
# Count is fetched from current Nomad state to preserve autoscaler-managed value
Expand Down
Loading
Loading