Skip to content

Indirect vs direct #5

Merged
merged 20 commits into from
Apr 22, 2025
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
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@ Common issues and solutions:

| Name | Version |
|------|---------|
| <a name="provider_aws"></a> [aws](#provider\_aws) | ~> 5.14 |
| <a name="provider_aws.eecr"></a> [aws.eecr](#provider\_aws.eecr) | ~> 5.14 |
| <a name="provider_helm"></a> [helm](#provider\_helm) | ~> 2.11 |
| <a name="provider_kubernetes"></a> [kubernetes](#provider\_kubernetes) | ~> 2.23 |
| <a name="provider_null"></a> [null](#provider\_null) | ~> 3.2 |
| <a name="provider_random"></a> [random](#provider\_random) | ~> 3.6 |
| <a name="provider_aws"></a> [aws](#provider\_aws) | 5.95.0 |
| <a name="provider_aws.eecr"></a> [aws.eecr](#provider\_aws.eecr) | 5.95.0 |
| <a name="provider_helm"></a> [helm](#provider\_helm) | 2.17.0 |
| <a name="provider_kubernetes"></a> [kubernetes](#provider\_kubernetes) | 2.36.0 |
| <a name="provider_null"></a> [null](#provider\_null) | 3.2.4 |
| <a name="provider_random"></a> [random](#provider\_random) | 3.7.2 |

## Modules

Expand Down Expand Up @@ -128,7 +128,7 @@ Common issues and solutions:
| <a name="input_profile"></a> [profile](#input\_profile) | AWS config profile used to upload images into ECR | `string` | `""` | no |
| <a name="input_region"></a> [region](#input\_region) | AWS region | `string` | n/a | yes |
| <a name="input_service_name"></a> [service\_name](#input\_service\_name) | The name of the service to be deployed in the EKS cluster. | `string` | `"service"` | no |
| <a name="input_utilities_tag"></a> [utilities\_tag](#input\_utilities\_tag) | Version tag for the docker image to use to execute kubectl commands. | `string` | `"1.0.3"` | no |
| <a name="input_utilities_tag"></a> [utilities\_tag](#input\_utilities\_tag) | Used for chown and curl. | `string` | `"1.0.3"` | no |

## Outputs

Expand Down
4 changes: 2 additions & 2 deletions copy_images.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ locals {
keycloak_key = format("%v#%v", local.keycloak_name, var.keycloak_tag)
postgresql_key = format("%v#%v", "bitnami/postgresql", var.postgresql_tag)
postgres_exporter_key = format("%v#%v", "bitnami/postgres-exporter", var.postgres_exporter_tag)
kubectl_key = format("%v#%v", "bitnami/kubectl-debian", var.utilities_tag)
utilities_key = format("%v#%v", "utilities", var.utilities_tag)
ent_ecr_source = format("%v.%v.%v.%v", var.eecr_info.account_id, "dkr.ecr", var.region, "amazonaws.com/ent-images")

image_config = [
Expand Down Expand Up @@ -37,7 +37,7 @@ locals {
{
enabled = true
dest_path = null
name = "bitnami/kubectl-debian"
name = "utilities"
source_image = "big-bang/utilities"
source_registry = format("%v/%v", local.ent_ecr_source, "ironbank")
source_tag = var.utilities_tag
Expand Down
31 changes: 11 additions & 20 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -70,24 +70,20 @@ resource "kubernetes_namespace" "keycloak" {
module "service_account" {
# tflint-ignore: terraform_module_pinned_source
source = "git::https://github.e.it.census.gov/SCT-Engineering/tfmod-config-job.git//service-account"
# source = "git@github.e.it.census.gov:SCT-Engineering/tfmod-config-job.git//service-account"

namespace = kubernetes_namespace.keycloak.metadata[0].name
}

module "pre_install" {
# tflint-ignore: terraform_module_pinned_source
source = "git::https://github.e.it.census.gov/SCT-Engineering/tfmod-config-job.git//config-job"
# source = "git@github.e.it.census.gov:SCT-Engineering/tfmod-config-job.git//config-job"

namespace = kubernetes_namespace.keycloak.metadata[0].name
service_account_name = module.service_account.service_account_name
job_name = "keycloak-config-secret-job"
config_script = local.secrets_job_script
kubectl_img = module.images.images[local.kubectl_key].dest_full_path
init_img = module.images.images[local.kubectl_key].dest_full_path

timeout = "5m"
utilities_image_path = module.images.images[local.utilities_key].dest_full_path
timeout = "5m"
}

resource "helm_release" "keycloak-db" {
Expand All @@ -102,7 +98,9 @@ resource "helm_release" "keycloak-db" {

depends_on = [
data.kubernetes_secret.db-secrets,
module.images
module.images,
module.service_account,
module.pre_install
]

set {
Expand Down Expand Up @@ -142,16 +140,12 @@ data "kubernetes_secret" "db-secrets" {
module "keycloak_db_config" {
# tflint-ignore: terraform_module_pinned_source
source = "git::https://github.e.it.census.gov/SCT-Engineering/tfmod-config-job.git//config-job"
# source = "git@github.e.it.census.gov:SCT-Engineering/tfmod-config-job.git//config-job"

depends_on = [helm_release.keycloak-db]

namespace = kubernetes_namespace.keycloak.metadata[0].name
namespace = helm_release.keycloak-db.namespace
service_account_name = module.service_account.service_account_name
job_name = "keycloak-db-config-job"
config_script = local.db_config_job_script
kubectl_img = module.images.images[local.kubectl_key].dest_full_path
init_img = module.images.images[local.kubectl_key].dest_full_path
utilities_image_path = module.images.images[local.utilities_key].dest_full_path

timeout = "3m"
}
Expand All @@ -164,7 +158,7 @@ resource "helm_release" "keycloak" {
repository = "${path.module}/charts"
timeout = 600
wait = true
depends_on = [helm_release.keycloak-db]
depends_on = [helm_release.keycloak-db, module.keycloak_db_config]

values = [templatefile("${path.module}/keycloak-server-values.yaml", {
hostname = format("https://%v.%v", var.keycloak_hostname, var.cluster_domain)
Expand Down Expand Up @@ -195,22 +189,19 @@ module "ingress_resources" {
public_hostname = var.service_name
public_domain = var.cluster_domain
service_name = "keycloak-keycloakx-http"
service_namespace = var.keycloak_namespace
service_namespace = kubernetes_namespace.keycloak.metadata[0].name
service_port = local.public_port_number
}

module "post_install" {
depends_on = [helm_release.keycloak]
# tflint-ignore: terraform_module_pinned_source
source = "git::https://github.e.it.census.gov/SCT-Engineering/tfmod-config-job.git//config-job"
# source = "git@github.e.it.census.gov:SCT-Engineering/tfmod-config-job.git//config-job"

namespace = kubernetes_namespace.keycloak.metadata[0].name
namespace = helm_release.keycloak.namespace
service_account_name = module.service_account.service_account_name
job_name = "keycloak-config-job"
config_script = local.config_job_script
kubectl_img = module.images.images[local.kubectl_key].dest_full_path
init_img = module.images.images[local.kubectl_key].dest_full_path
utilities_image_path = module.images.images[local.utilities_key].dest_full_path

timeout = "10m"
}
4 changes: 3 additions & 1 deletion variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,10 @@ variable "service_name" {
type = string
default = "service"
}

# From bigbang utilities
variable "utilities_tag" {
description = "Version tag for the docker image to use to execute kubectl commands."
description = "Used for chown and curl."
type = string
default = "1.0.3"
}