Skip to content

Commit b4338a0

Browse files
committed
updates for app_name
Signed-off-by: junior <junior@users.noreply.github.com>
1 parent 642d3c7 commit b4338a0

File tree

4 files changed

+114
-39
lines changed

4 files changed

+114
-39
lines changed

modules/cluster-tools/ingress-nginx.tf

Lines changed: 78 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,34 @@ variable "ingress_load_balancer_shape_flex_max" {
2222
}
2323

2424
## Resource Ingress examples
25-
# variable "ingress_hosts" {
26-
# default = ""
27-
# description = "Enter a valid full qualified domain name (FQDN). You will need to map the domain name to the EXTERNAL-IP address on your DNS provider (DNS Registry type - A). If you have multiple domain names, include separated by comma. e.g.: mushop.example.com,catshop.com"
28-
# }
29-
# variable "ingress_tls" {
30-
# default = false
31-
# description = "If enabled, will generate SSL certificates to enable HTTPS for the ingress using the Certificate Issuer"
32-
# }
33-
# variable "ingress_cluster_issuer" {
34-
# default = "letsencrypt-prod"
35-
# description = "Certificate issuer type. Currently supports the free Let's Encrypt and Self-Signed. Only *letsencrypt-prod* generates valid certificates"
36-
# }
37-
# variable "ingress_email_issuer" {
38-
# default = "no-reply@example.cloud"
39-
# description = "You must replace this email address with your own. The certificate provider will use this to contact you about expiring certificates, and issues related to your account."
40-
# }
25+
variable "ingress_hosts" {
26+
default = ""
27+
description = "Enter a valid full qualified domain name (FQDN). You will need to map the domain name to the EXTERNAL-IP address on your DNS provider (DNS Registry type - A). If you have multiple domain names, include separated by comma. e.g.: mushop.example.com,catshop.com"
28+
}
29+
variable "ingress_hosts_include_nip_io" {
30+
default = true
31+
description = "Include app_name.HEXXX.nip.io on the ingress hosts. e.g.: mushop.HEXXX.nip.io"
32+
}
33+
variable "nip_io_domain" {
34+
default = "nip.io"
35+
description = "Dynamic wildcard DNS for the application hostname. Should support hex notation. e.g.: nip.io"
36+
}
37+
variable "ingress_tls" {
38+
default = false
39+
description = "If enabled, will generate SSL certificates to enable HTTPS for the ingress using the Certificate Issuer"
40+
}
41+
variable "ingress_cluster_issuer" {
42+
default = "letsencrypt-prod"
43+
description = "Certificate issuer type. Currently supports the free Let's Encrypt and Self-Signed. Only *letsencrypt-prod* generates valid certificates"
44+
}
45+
variable "ingress_email_issuer" {
46+
default = "no-reply@example.cloud"
47+
description = "You must replace this email address with your own. The certificate provider will use this to contact you about expiring certificates, and issues related to your account."
48+
}
49+
# Deployment Details + Freeform Tags
50+
variable "freeform_deployment_tags" {
51+
description = "Tags to be added to the resources"
52+
}
4153

4254
# Ingress-NGINX helm chart
4355
## https://kubernetes.github.io/ingress-nginx/
@@ -48,7 +60,7 @@ resource "helm_release" "ingress_nginx" {
4860
chart = "ingress-nginx"
4961
version = local.helm_repository.ingress_nginx_version
5062
namespace = kubernetes_namespace.cluster_tools.id
51-
wait = false
63+
wait = true
5264

5365
set {
5466
name = "controller.metrics.enabled"
@@ -83,3 +95,52 @@ data "kubernetes_service" "ingress" {
8395

8496
count = var.ingress_nginx_enabled ? 1 : 0
8597
}
98+
99+
locals {
100+
ingress_controller_load_balancer_ip = var.ingress_nginx_enabled ? data.kubernetes_service.ingress.0.status.0.load_balancer.0.ingress.0.ip : "#Ingress_Controller_Not_Deployed"
101+
ingress_controller_load_balancer_ip_hex = var.ingress_nginx_enabled ? join("", formatlist("%02x", split(".", data.kubernetes_service.ingress.0.status.0.load_balancer.0.ingress.0.ip))) : "#Ingress_Controller_Not_Deployed"
102+
# ingress_controller_load_balancer_hostname = var.ingress_nginx_enabled ? (data.kubernetes_service.ingress.0.status.0.load_balancer.0.ingress.0.hostname == "" ?
103+
# (var.ingress_hosts_include_nip_io ? local.app_nip_io_domain : local.ingress_controller_load_balancer_ip) : data.kubernetes_service.ingress.0.status.0.load_balancer.0.ingress.0.hostname) : "#Ingress_Controller_Not_Deployed"
104+
ingress_controller_load_balancer_hostname = var.ingress_nginx_enabled ? (
105+
var.ingress_hosts != "" ? local.ingress_hosts[0] : (var.ingress_hosts_include_nip_io ? local.app_nip_io_domain : local.ingress_controller_load_balancer_ip)) : "#Ingress_Controller_Not_Deployed"
106+
107+
ingress_nginx_annotations_basic = {
108+
"nginx.ingress.kubernetes.io/rewrite-target" = "/$2"
109+
}
110+
ingress_nginx_annotations_tls = {
111+
"nginx.ingress.kubernetes.io/ssl-redirect" = "true"
112+
}
113+
ingress_nginx_annotations_cert_manager = {
114+
"cert-manager.io/cluster-issuer" = var.ingress_cluster_issuer
115+
"cert-manager.io/acme-challenge-type" = "http01"
116+
}
117+
ingress_nginx_annotations = merge(local.ingress_nginx_annotations_basic,
118+
var.ingress_tls ? local.ingress_nginx_annotations_tls : {},
119+
(var.ingress_tls && var.cert_manager_enabled) ? local.ingress_nginx_annotations_cert_manager : {}
120+
)
121+
ingress_hosts = compact(concat(split(",", var.ingress_hosts), [local.app_nip_io_domain]))
122+
app_name = var.freeform_deployment_tags.AppName
123+
app_name_for_dns = substr(lower(replace(local.app_name, "/\\W|_|\\s/", "")), 0, 6)
124+
app_nip_io_domain = (var.ingress_nginx_enabled && var.ingress_hosts_include_nip_io) ? format("${local.app_name_for_dns}.%s.${var.nip_io_domain}", local.ingress_controller_load_balancer_ip_hex) : ""
125+
}
126+
127+
# Outputs
128+
output "ingress_controller_load_balancer_ip" {
129+
value = local.ingress_controller_load_balancer_ip
130+
}
131+
# output "ingress_controller_load_balancer_ip_hex" {
132+
# value = local.ingress_controller_load_balancer_ip_hex
133+
# }
134+
output "ingress_controller_load_balancer_hostname" {
135+
value = local.ingress_controller_load_balancer_hostname
136+
}
137+
138+
output "url_protocol" {
139+
value = var.ingress_tls ? "https" : "http"
140+
}
141+
# output "app_domain" {
142+
# value = (var.ingress_hosts != "") ? local.ingress_controller_load_balancer_hostname : (var.ingress_hosts_include_nip_io ? local.app_nip_io_domain : local.ingress_controller_load_balancer_hostname)
143+
# }
144+
output "ingress_hosts" {
145+
value = local.ingress_hosts
146+
}

modules/oke-node-pool/variables.tf

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,13 @@ variable "tenancy_ocid" {}
8585

8686
# App Name Locals
8787
locals {
88-
app_name_normalized = substr(replace(lower(var.freeform_deployment_tags.AppName), " ", "-"), 0, 6)
88+
app_name_normalized = substr(replace(lower(var.node_pools_freeform_deployment_tags.AppName), " ", "-"), 0, 6)
8989
}
9090

9191
# Deployment Details + Freeform Tags
92-
variable "freeform_deployment_tags" {
93-
description = "Tags to be added to the resources"
92+
variable "node_pools_freeform_deployment_tags" {
93+
description = "Tags to be added to the node pools resources"
94+
}
95+
variable "worker_nodes_freeform_deployment_tags" {
96+
description = "Tags to be added to the worker nodes resources"
9497
}

modules/oke/variables.tf

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@
44

55
# OKE Variables
66
## OKE Cluster Details
7-
variable "app_name" {
8-
default = "OKE App"
9-
description = "Application name. Will be used as prefix to identify resources, such as OKE, VCN, ATP, and others"
10-
}
11-
variable "app_deployment_environment" {
12-
default = "generic" # e.g.: Development, QA, Stage, ...
13-
description = "Deployment environment for the freeform tags"
14-
}
15-
variable "app_deployment_type" {
16-
default = "generic" # e.g.: App Type 1, App Type 2, Red, Purple, ...
17-
description = "Deployment type for the freeform tags"
18-
}
7+
# variable "app_name" {
8+
# default = "OKE App"
9+
# description = "Application name. Will be used as prefix to identify resources, such as OKE, VCN, ATP, and others"
10+
# }
11+
# variable "app_deployment_environment" {
12+
# default = "generic" # e.g.: Development, QA, Stage, ...
13+
# description = "Deployment environment for the freeform tags"
14+
# }
15+
# variable "app_deployment_type" {
16+
# default = "generic" # e.g.: App Type 1, App Type 2, Red, Purple, ...
17+
# description = "Deployment type for the freeform tags"
18+
# }
1919
variable "create_new_oke_cluster" {
2020
default = false
2121
description = "Creates a new OKE cluster and node pool"
@@ -141,10 +141,10 @@ variable "show_advanced" {
141141

142142
# App Name Locals
143143
locals {
144-
app_name = var.freeform_deployment_tags.AppName
145-
deploy_id = var.freeform_deployment_tags.DeploymentID
146-
app_name_normalized = substr(replace(lower(var.freeform_deployment_tags.AppName), " ", "-"), 0, 6)
147-
app_name_for_dns = substr(lower(replace(var.freeform_deployment_tags.AppName, "/\\W|_|\\s/", "")), 0, 6)
144+
app_name = var.cluster_freeform_deployment_tags.AppName
145+
deploy_id = var.cluster_freeform_deployment_tags.DeploymentID
146+
app_name_normalized = substr(replace(lower(var.cluster_freeform_deployment_tags.AppName), " ", "-"), 0, 6)
147+
app_name_for_dns = substr(lower(replace(var.cluster_freeform_deployment_tags.AppName, "/\\W|_|\\s/", "")), 0, 6)
148148
}
149149

150150
# OKE Compartment
@@ -153,6 +153,12 @@ locals {
153153
}
154154

155155
# Deployment Details + Freeform Tags
156-
variable "freeform_deployment_tags" {
157-
description = "Tags to be added to the resources"
156+
variable "cluster_freeform_deployment_tags" {
157+
description = "Tags to be added to the cluster resources"
158+
}
159+
variable "load_balancers_freeform_deployment_tags" {
160+
description = "Tags to be added to the load balancers resources"
158161
}
162+
variable "block_volumes_freeform_deployment_tags" {
163+
description = "Tags to be added to the block volumes resources"
164+
}

variables.tf

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,9 @@ variable "fingerprint" {
1010
}
1111
variable "private_key_path" {
1212
default = ""
13-
}
13+
}
14+
15+
variable "app_name" {
16+
default = "K8s App"
17+
description = "Application name. Will be used as prefix to identify resources, such as OKE, VCN, ATP, and others"
18+
}

0 commit comments

Comments
 (0)