Skip to content

Commit 2e8bb1c

Browse files
authored
Merge pull request #5 from junior/zero-six-zero
Zero six zero
2 parents cb730c0 + 44822f8 commit 2e8bb1c

34 files changed

+653
-238
lines changed

.terraform.lock.hcl

Lines changed: 37 additions & 37 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.5.0
1+
0.6.0

module-cluster-tools.tf

Lines changed: 62 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,31 @@ module "cluster-tools" {
66
source = "./modules/cluster-tools"
77

88
# Oracle Cloud Infrastructure Tenancy and Compartment OCID
9-
tenancy_ocid = var.tenancy_ocid
10-
compartment_ocid = var.compartment_ocid
11-
region = var.region
9+
tenancy_ocid = var.tenancy_ocid
10+
# compartment_ocid = var.compartment_ocid
11+
region = var.region
12+
13+
# Deployment Tags + Freeform Tags + Defined Tags
14+
oci_tag_values = local.oci_tag_values
1215

1316
# Cluster Tools
1417
## Namespace
1518
cluster_tools_namespace = "cluster-tools"
1619

17-
## Ingress
20+
## Ingress Controller
1821
ingress_nginx_enabled = var.ingress_nginx_enabled
1922
ingress_load_balancer_shape = var.ingress_load_balancer_shape
2023
ingress_load_balancer_shape_flex_min = var.ingress_load_balancer_shape_flex_min
2124
ingress_load_balancer_shape_flex_max = var.ingress_load_balancer_shape_flex_max
2225

26+
## Ingress
27+
ingress_hosts = var.ingress_hosts
28+
ingress_tls = var.ingress_tls
29+
ingress_cluster_issuer = var.ingress_cluster_issuer
30+
ingress_email_issuer = var.ingress_email_issuer
31+
ingress_hosts_include_nip_io = var.ingress_hosts_include_nip_io
32+
nip_io_domain = var.nip_io_domain
33+
2334
## Cert Manager
2435
cert_manager_enabled = var.cert_manager_enabled
2536

@@ -36,7 +47,7 @@ module "cluster-tools" {
3647
}
3748

3849
# Kubernetes Cluster Tools
39-
## Ingress/LoadBalancer
50+
## IngressController/LoadBalancer
4051
variable "ingress_nginx_enabled" {
4152
default = true
4253
description = "Enable Ingress Nginx for Kubernetes Services (This option provision a Load Balancer)"
@@ -50,13 +61,38 @@ variable "ingress_load_balancer_shape_flex_min" {
5061
description = "Enter the minimum size of the flexible shape."
5162
}
5263
variable "ingress_load_balancer_shape_flex_max" {
53-
default = "100" # From 10 to 8000. Cannot be lower than flex_min
64+
default = "100" # From 10 to 8000. Cannot be lower than ingress_load_balancer_shape_flex_min
5465
description = "Enter the maximum size of the flexible shape (Should be bigger than minimum size). The maximum service limit is set by your tenancy limits."
5566
}
67+
## Ingresses
68+
variable "ingress_hosts" {
69+
default = ""
70+
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"
71+
}
72+
variable "ingress_hosts_include_nip_io" {
73+
default = true
74+
description = "Include app_name.HEXXX.nip.io on the ingress hosts. e.g.: mushop.HEXXX.nip.io"
75+
}
76+
variable "nip_io_domain" {
77+
default = "nip.io"
78+
description = "Dynamic wildcard DNS for the application hostname. Should support hex notation. e.g.: nip.io"
79+
}
80+
variable "ingress_tls" {
81+
default = false
82+
description = "If enabled, will generate SSL certificates to enable HTTPS for the ingress using the Certificate Issuer"
83+
}
84+
variable "ingress_cluster_issuer" {
85+
default = "letsencrypt-prod"
86+
description = "Certificate issuer type. Currently supports the free Let's Encrypt and Self-Signed. Only *letsencrypt-prod* generates valid certificates"
87+
}
88+
variable "ingress_email_issuer" {
89+
default = "no-reply@example.cloud"
90+
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."
91+
}
5692

5793
## Cert Manager
5894
variable "cert_manager_enabled" {
59-
default = false
95+
default = true
6096
description = "Enable x509 Certificate Management"
6197
}
6298

@@ -74,12 +110,29 @@ variable "prometheus_enabled" {
74110

75111
## Grafana
76112
variable "grafana_enabled" {
77-
default = false
113+
default = true
78114
description = "Enable Grafana Dashboards. Includes example dashboards and Prometheus, OCI Logging and OCI Metrics datasources"
79115
}
80116

81117
# Cluster Tools Outputs
118+
## grafana
82119
output "grafana_admin_password" {
83120
value = module.cluster-tools.grafana_admin_password
84121
sensitive = true
85-
}
122+
}
123+
124+
## Ingress Controller
125+
locals {
126+
app_domain = module.cluster-tools.ingress_controller_load_balancer_hostname
127+
url_protocol = module.cluster-tools.url_protocol
128+
}
129+
130+
output "grafana_url" {
131+
value = (var.grafana_enabled && var.ingress_nginx_enabled) ? format("${local.url_protocol}://%s/grafana", local.app_domain) : null
132+
description = "Grafana Dashboards URL"
133+
}
134+
135+
output "app_url" {
136+
value = (var.ingress_nginx_enabled) ? format("${local.url_protocol}://%s", local.app_domain) : null
137+
description = "Application URL"
138+
}

module-oke.tf

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ module "vault" {
1313
# Oracle Cloud Infrastructure Tenancy and Compartment OCID
1414
tenancy_ocid = var.tenancy_ocid
1515

16-
# Deployment Tags + Freeform Tags
17-
freeform_deployment_tags = local.freeform_deployment_tags
16+
# Deployment Tags + Freeform Tags + Defined Tags
17+
oci_tag_values = local.oci_tag_values
1818

1919
# Encryption (OCI Vault/Key Management/KMS)
2020
use_encryption_from_oci_vault = var.use_encryption_from_oci_vault
@@ -43,8 +43,10 @@ module "oke" {
4343
compartment_ocid = local.oke_compartment_ocid
4444
region = var.region
4545

46-
# Deployment Tags + Freeform Tags
47-
freeform_deployment_tags = local.freeform_deployment_tags
46+
# Deployment Tags + Freeform Tags + Defined Tags
47+
cluster_tags = local.oci_tag_values
48+
load_balancers_tags = local.oci_tag_values
49+
block_volumes_tags = local.oci_tag_values
4850

4951
# OKE Cluster
5052
## create_new_oke_cluster
@@ -74,7 +76,8 @@ module "oke_node_pool" {
7476
source = "./modules/oke-node-pool"
7577

7678
# Deployment Tags + Freeform Tags
77-
freeform_deployment_tags = local.freeform_deployment_tags
79+
node_pools_tags = local.oci_tag_values
80+
worker_nodes_tags = local.oci_tag_values
7881

7982
# Oracle Cloud Infrastructure Tenancy and Compartment OCID
8083
tenancy_ocid = var.tenancy_ocid
@@ -135,10 +138,6 @@ module "oke_cluster_autoscaler" {
135138
}
136139

137140
## OKE Cluster Details
138-
variable "app_name" {
139-
default = "K8s App"
140-
description = "Application name. Will be used as prefix to identify resources, such as OKE, VCN, ATP, and others"
141-
}
142141
variable "create_new_oke_cluster" {
143142
default = true
144143
description = "Creates a new OKE cluster, node pool and network resources"
@@ -293,7 +292,7 @@ resource "random_string" "deploy_id" {
293292
resource "oci_identity_compartment" "oke_compartment" {
294293
compartment_id = var.compartment_ocid
295294
name = "${local.app_name_normalized}-${local.deploy_id}"
296-
description = "${var.app_name} ${var.oke_compartment_description} (Deployment ${local.deploy_id})"
295+
description = "${local.app_name} ${var.oke_compartment_description} (Deployment ${local.deploy_id})"
297296
enable_delete = true
298297

299298
count = var.create_new_compartment_for_oke ? 1 : 0
@@ -313,9 +312,15 @@ locals {
313312
"DeploymentID" = local.deploy_id,
314313
"AppName" = var.app_name,
315314
"Quickstart" = "oke_base" }
316-
freeform_deployment_tags = merge(var.tag_values.freeformTags, local.deploy_tags)
317-
workers_public_ssh_key = var.generate_public_ssh_key ? tls_private_key.oke_worker_node_ssh_key.public_key_openssh : var.public_ssh_key
318-
app_name_normalized = substr(replace(lower(var.app_name), " ", "-"), 0, 6)
315+
# freeform_deployment_tags = merge(var.tag_values.freeformTags, local.deploy_tags)
316+
oci_tag_values = {
317+
"freeformTags" = merge(var.tag_values.freeformTags, local.deploy_tags),
318+
"definedTags" = var.tag_values.definedTags
319+
}
320+
workers_public_ssh_key = var.generate_public_ssh_key ? tls_private_key.oke_worker_node_ssh_key.public_key_openssh : var.public_ssh_key
321+
app_name = var.app_name
322+
app_name_normalized = substr(replace(lower(var.app_name), " ", "-"), 0, 6)
323+
app_name_for_dns = substr(lower(replace(var.app_name, "/\\W|_|\\s/", "")), 0, 6)
319324
}
320325

321326
# OKE Outputs

modules/cluster-tools/cert-manager.tf

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,14 @@ variable "cert_manager_enabled" {
88
description = "Enable x509 Certificate Management"
99
}
1010

11-
# Cert Manager Helm chart
12-
## https://github.com/jetstack/cert-manager/blob/master/README.md
13-
## https://artifacthub.io/packages/helm/cert-manager/cert-manager
14-
resource "helm_release" "cert_manager" {
15-
name = "cert-manager"
16-
repository = local.helm_repository.jetstack
17-
chart = "cert-manager"
18-
version = local.helm_repository.jetstack_version
19-
namespace = kubernetes_namespace.cluster_tools.id
20-
wait = true # wait to allow the webhook be properly configured
11+
module "cert-manager" {
12+
source = "./modules/cert-manager"
2113

22-
set {
23-
name = "installCRDs"
24-
value = true
25-
}
26-
27-
set {
28-
name = "webhook.timeoutSeconds"
29-
value = "30"
30-
}
14+
# Helm Release variables
15+
chart_namespace = kubernetes_namespace.cluster_tools.id
16+
chart_repository = local.helm_repository.jetstack
17+
chart_version = local.helm_repository.jetstack_version
18+
ingress_email_issuer = var.ingress_email_issuer
3119

3220
count = var.cert_manager_enabled ? 1 : 0
3321
}

modules/cluster-tools/cluster-tools.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ locals {
1313
# Helm repos
1414
helm_repository = {
1515
ingress_nginx = "https://kubernetes.github.io/ingress-nginx"
16-
ingress_nginx_version = "4.2.3"
16+
ingress_nginx_version = "4.2.5"
1717
jetstack = "https://charts.jetstack.io" # cert-manager
1818
jetstack_version = "1.9.1" # cert-manager
1919
grafana = "https://grafana.github.io/helm-charts"
20-
grafana_version = "6.34.0"
20+
grafana_version = "6.38.0"
2121
prometheus = "https://prometheus-community.github.io/helm-charts"
2222
prometheus_version = "15.12.0"
2323
metrics_server = "https://kubernetes-sigs.github.io/metrics-server"
@@ -27,7 +27,7 @@ locals {
2727

2828
# OCI Provider
2929
variable "tenancy_ocid" {}
30-
variable "compartment_ocid" {}
30+
# variable "compartment_ocid" {}
3131
variable "region" {}
3232

3333
# Namespace

0 commit comments

Comments
 (0)