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

Add orchestration resources to Terraform #30

Merged
merged 32 commits into from
Nov 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
816f489
add orchestration chart to terraform deployments
emmastephenson Oct 18, 2023
4e343b6
Merge branch 'main' of https://github.com/CDCgov/phdi-playground into…
emmastephenson Oct 26, 2023
8da39f6
temp change to use 'orchestration' instead of 'orchestration-chart'
emmastephenson Oct 26, 2023
1477ec9
remove orchestration from foreach
emmastephenson Oct 26, 2023
cd66ff3
add release specific to ingress
emmastephenson Oct 27, 2023
022ac4f
change chart name
emmastephenson Oct 27, 2023
6de683e
update ingress release
emmastephenson Oct 27, 2023
7eb7393
change value names for URLS
emmastephenson Oct 30, 2023
3833064
remove quotes around secret values
emmastephenson Oct 30, 2023
7cebbbd
remove trailing slash
emmastephenson Oct 30, 2023
26845c2
add full URL path (https)
emmastephenson Oct 30, 2023
bf682a6
add message parsing block
emmastephenson Oct 30, 2023
0a6d214
update name
emmastephenson Oct 31, 2023
e874ac5
wip
emmastephenson Nov 2, 2023
8f2c341
update services_to_chart map
emmastephenson Nov 2, 2023
60614b7
change release name
emmastephenson Nov 2, 2023
81bf00f
update release name
emmastephenson Nov 2, 2023
dcc0bef
add orchestration chart to main release
emmastephenson Nov 2, 2023
fa54cf2
remove new
emmastephenson Nov 2, 2023
5c64cf4
remove https for hostname
emmastephenson Nov 2, 2023
f818035
update ingress locally - temp
emmastephenson Nov 2, 2023
4cad8eb
update ingress locally
emmastephenson Nov 2, 2023
5fedc60
change ingress name to temp
emmastephenson Nov 2, 2023
554f968
update chart
emmastephenson Nov 2, 2023
e10b6aa
make ingress service names dynamic
emmastephenson Nov 8, 2023
1a136f1
update the right values block
emmastephenson Nov 8, 2023
096fa56
update ingress hostname
emmastephenson Nov 8, 2023
4b521b5
add ingress back to regular chart installation
emmastephenson Nov 9, 2023
02ae93b
temp remove ingress to make deployment happy
emmastephenson Nov 9, 2023
04cb661
ingress is back
emmastephenson Nov 9, 2023
70121c0
temp remove orchestration chart
emmastephenson Nov 9, 2023
05e48b9
add orchestration back
emmastephenson Nov 9, 2023
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
Binary file not shown.
2 changes: 1 addition & 1 deletion terraform/implementation/data.tf
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ data "kubectl_path_documents" "keda_trigger" {
}

data "kubectl_path_documents" "keda_scaled_object" {
for_each = local.services
for_each = var.services_to_chart
pattern = "./manifests/kedaScaledObject.yaml"
vars = {
subscriptionId = "${var.subscription_id}"
Expand Down
Binary file added terraform/implementation/ingress-chart-0.1.10.tgz
Binary file not shown.
86 changes: 70 additions & 16 deletions terraform/implementation/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,21 @@ locals {
resource_group_name = var.resource_group_name,
subscription_id = var.subscription_id,
}))
}

services = toset([
"fhir-converter",
"ingestion",
"ingress",
"message-parser",
"validation",
])
variable "services_to_chart" {
type = map(string)
default = {
fhir-converter = "fhir-converter-chart",
ingestion = "ingestion-chart",
ingress = "ingress-chart",
message-parser = "message-parser-chart",
orchestration = "orchestration",
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

note: orchestration-chart didn't work because the name kept cutting off right at orchestration- and TF would complain that it was an invalid name. The solution here was to rename the chart at the Helm level, and create this mapping to track microservice name <=> chart name.

validation = "validation-chart"
}
}


# Service Principal
resource "azuread_application" "aks" {
display_name = "phdi-playground-${terraform.workspace}-aks"
Expand Down Expand Up @@ -320,19 +325,20 @@ spec:
YAML
}

# Helm Releases

resource "helm_release" "building_blocks" {
for_each = local.services
repository = "https://cdcgov.github.io/phdi-charts/"
name = "phdi-playground-${terraform.workspace}-${each.key}"
chart = "${each.key}-chart"
recreate_pods = true
depends_on = [helm_release.agic]
for_each = var.services_to_chart
repository = "https://cdcgov.github.io/phdi-charts/"
name = "phdi-playground-${terraform.workspace}-${each.key}"
chart = each.value
depends_on = [helm_release.agic]
force_update = true
recreate_pods = true
cleanup_on_fail = true

set {
name = "image.tag"
value = "latest"
value = "v1.1.1"
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The latest version of each Docker image wasn't being picked up by Terraform, so each deployment was at a wildly different image version (whatever had been latest when the service was first deployed). The workflow to make changes is therefore:

  • Make your changes to the Docker container
  • Publish changes as new release version
  • Update this image tag
  • Push these changes and re-deploy to desired env

}

set {
Expand All @@ -349,8 +355,56 @@ resource "helm_release" "building_blocks" {
name = "ingressHostname"
value = "${var.resource_group_name}-${terraform.workspace}.${var.location}.cloudapp.azure.com"
}

# Service names needed for ingress routes
set {
name = "ingestionServiceName"
value = "phdi-playground-${terraform.workspace}-ingestion-ingestion-service"
}

set {
name = "fhirConverterServiceName"
value = "phdi-playground-${terraform.workspace}-fhir-converter-fhir-converter-service"
}

set {
name = "messageParserServiceName"
value = "phdi-playground-${terraform.workspace}-message-parser-message-parser-service"
}

set {
name = "validationServiceName"
value = "phdi-playground-${terraform.workspace}-validation-validation-service"
}

set {
name = "orchestrationServiceName"
value = "phdi-playground-${terraform.workspace}-orchestration-orchestration-service"
}

# Values needed for orchestration service
set {
name = "fhirConverterUrl"
value = "https://${var.resource_group_name}-${terraform.workspace}.${var.location}.cloudapp.azure.com/fhir-converter"
}

set {
name = "ingestionUrl"
value = "https://${var.resource_group_name}-${terraform.workspace}.${var.location}.cloudapp.azure.com/ingestion"
}

set {
name = "messageParserUrl"
value = "https://${var.resource_group_name}-${terraform.workspace}.${var.location}.cloudapp.azure.com/message-parser"
}

set {
name = "validationUrl"
value = "https://${var.resource_group_name}-${terraform.workspace}.${var.location}.cloudapp.azure.com/validation"
}
}


# Metrics Dashboard

resource "azurerm_portal_dashboard" "pipeline_metrics" {
Expand Down Expand Up @@ -388,7 +442,7 @@ resource "kubectl_manifest" "keda_trigger" {
}

resource "kubectl_manifest" "keda_scaled_object" {
for_each = local.services
for_each = var.services_to_chart
depends_on = [kubectl_manifest.keda_trigger]
yaml_body = data.kubectl_path_documents.keda_scaled_object[each.key].documents[0]
}
Loading