Skip to content

Commit

Permalink
fix: ArgoCD Diego changed apps to application sets (#147)
Browse files Browse the repository at this point in the history
* changed apps argo to applications sets

* pre-commit fixs
  • Loading branch information
diegolagospagopa authored Dec 8, 2024
1 parent 08dc682 commit 647ef91
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 53 deletions.
124 changes: 72 additions & 52 deletions src/domains/diego-app/05_argocd.tf
Original file line number Diff line number Diff line change
Expand Up @@ -64,71 +64,91 @@ locals {
name = "two-color"
target_branch = "main"
}
"three-color" = {
name = "three-color"
target_branch = "main"
}
# Puoi aggiungere altre app seguendo lo stesso pattern
}
}

# Creiamo le singole Applications
resource "argocd_application" "diego_apps" {
for_each = local.argocd_applications

# Creiamo l'ApplicationSet
resource "argocd_application_set" "diego_appset" {
metadata {
name = "${local.area}-${each.value.name}"
name = "applicationset-${local.area}"
namespace = "argocd"
labels = {
name = "${local.area}-${each.value.name}"
domain = var.domain
area = local.area
}
}

spec {
project = argocd_project.project.metadata[0].name

destination {
server = "https://kubernetes.default.svc"
namespace = var.domain
generator {
list {
elements = [
for app_key, app in local.argocd_applications : {
name = app.name
targetBranch = app.target_branch
}
]
}
}

source {
repo_url = "https://github.com/pagopa/devopslab-diego-deploy"
target_revision = each.value.target_branch
path = "helm/${var.env}/${each.value.name}"

helm {
values = yamlencode({
microservice-chart : {
azure : {
workloadIdentityClientId : module.workload_identity.workload_identity_client_id
}
template {
metadata {
name = "${local.area}-{{name}}"
namespace = "argocd"
labels = {
name = "${local.area}-{{name}}"
domain = var.domain
}
}

spec {
project = argocd_project.project.metadata[0].name

destination {
server = "https://kubernetes.default.svc"
namespace = var.domain
}

source {
repo_url = "https://github.com/pagopa/devopslab-diego-deploy"
target_revision = "{{targetBranch}}"
path = "helm/${var.env}/{{name}}"

helm {
values = yamlencode({
microservice-chart : {
azure : {
workloadIdentityClientId : module.workload_identity.workload_identity_client_id
}
serviceAccount : {
name : module.workload_identity.workload_identity_service_account_name
}
}
})
ignore_missing_value_files = false
pass_credentials = false
skip_crds = false
value_files = []
}
})
ignore_missing_value_files = false
pass_credentials = false
skip_crds = false
value_files = []
}

# Decommentare e modificare se necessario
# sync_policy {
# automated {
# prune = true
# self_heal = false
# allow_empty = false
# }
# retry {
# backoff {
# duration = "5s"
# factor = "2"
# max_duration = "3m0s"
# }
# limit = "5"
# }
# }
}
}

# Decommentare e modificare se necessario
# sync_policy {
# automated {
# prune = true
# self_heal = false
# allow_empty = false
# }
# retry {
# backoff {
# duration = "5s"
# factor = "2"
# max_duration = "3m0s"
# }
# limit = "5"
# }
# }
}

depends_on = [
argocd_project.project
]
}
2 changes: 1 addition & 1 deletion src/domains/diego-app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

| Name | Type |
|------|------|
| [argocd_application.diego_apps](https://registry.terraform.io/providers/argoproj-labs/argocd/latest/docs/resources/application) | resource |
| [argocd_application_set.diego_appset](https://registry.terraform.io/providers/argoproj-labs/argocd/latest/docs/resources/application_set) | resource |
| [argocd_project.project](https://registry.terraform.io/providers/argoproj-labs/argocd/latest/docs/resources/project) | resource |
| [azurerm_key_vault_secret.aks_apiserver_url](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/key_vault_secret) | resource |
| [azurerm_key_vault_secret.app_insights_connection_string](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/key_vault_secret) | resource |
Expand Down

0 comments on commit 647ef91

Please sign in to comment.