Skip to content

Commit 43eb2aa

Browse files
committed
added nginx and cert-manager
1 parent 9b1aa10 commit 43eb2aa

8 files changed

+191
-1
lines changed

datasources.tf

+16
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,19 @@ data "oci_identity_availability_domains" "ads" {
1919
compartment_id = var.tenancy_ocid
2020
}
2121

22+
data "oci_load_balancer_load_balancers" "lbs" {
23+
24+
compartment_id = coalesce(var.compartment_id, var.compartment_ocid)
25+
26+
filter {
27+
name = "freeform_tags.state_id"
28+
values = [local.state_id]
29+
}
30+
31+
filter {
32+
name = "freeform_tags.application"
33+
values = ["nginx"]
34+
}
35+
36+
depends_on = [module.nginx]
37+
}

helm-deployments.tf

+89
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,92 @@ module "argo-workflows" {
5050
depends_on = [module.oke]
5151
}
5252

53+
module "nginx" {
54+
count = var.deploy_nginx ? 1 : 0
55+
source = "./helm-module"
56+
57+
bastion_host = module.oke.bastion_public_ip
58+
bastion_user = var.bastion_user
59+
operator_host = module.oke.operator_private_ip
60+
operator_user = var.bastion_user
61+
ssh_private_key = tls_private_key.stack_key.private_key_openssh
62+
63+
deploy_from_operator = local.deploy_from_operator
64+
deploy_from_local = local.deploy_from_local
65+
66+
deployment_name = "ingress-nginx"
67+
helm_chart_name = "ingress-nginx"
68+
namespace = "nginx"
69+
helm_repository_url = "https://kubernetes.github.io/ingress-nginx"
70+
71+
pre_deployment_commands = []
72+
post_deployment_commands = []
73+
74+
helm_template_values_override = templatefile(
75+
"${path.root}/helm-values-templates/nginx-values.yaml.tpl",
76+
{
77+
min_bw = 100,
78+
max_bw = 100,
79+
pub_lb_nsg_id = module.oke.pub_lb_nsg_id
80+
state_id = local.state_id
81+
}
82+
)
83+
helm_user_values_override = try(base64decode(var.nginx_user_values_override), var.nginx_user_values_override)
84+
85+
kube_config = one(data.oci_containerengine_cluster_kube_config.kube_config.*.content)
86+
depends_on = [module.oke]
87+
}
88+
89+
module "cert-manager" {
90+
count = var.deploy_cert_manager ? 1 : 0
91+
source = "./helm-module"
92+
93+
bastion_host = module.oke.bastion_public_ip
94+
bastion_user = var.bastion_user
95+
operator_host = module.oke.operator_private_ip
96+
operator_user = var.bastion_user
97+
ssh_private_key = tls_private_key.stack_key.private_key_openssh
98+
99+
deploy_from_operator = local.deploy_from_operator
100+
deploy_from_local = local.deploy_from_local
101+
102+
deployment_name = "cert-manager"
103+
helm_chart_name = "cert-manager"
104+
namespace = "cert-manager"
105+
helm_repository_url = "https://charts.jetstack.io"
106+
107+
pre_deployment_commands = []
108+
post_deployment_commands = [
109+
"cat <<'EOF' | kubectl apply -f -",
110+
"apiVersion: cert-manager.io/v1",
111+
"kind: ClusterIssuer",
112+
"metadata:",
113+
" name: le-clusterissuer",
114+
"spec:",
115+
" acme:",
116+
" # You must replace this email address with your own.",
117+
" # Let's Encrypt will use this to contact you about expiring",
118+
" # certificates, and issues related to your account.",
119+
" email: [email protected]",
120+
" server: https://acme-staging-v02.api.letsencrypt.org/directory",
121+
" privateKeySecretRef:",
122+
" # Secret resource that will be used to store the account's private key.",
123+
" name: le-clusterissuer-secret",
124+
" # Add a single challenge solver, HTTP01 using nginx",
125+
" solvers:",
126+
" - http01:",
127+
" ingress:",
128+
" ingressClassName: nginx",
129+
"EOF"
130+
]
131+
132+
helm_template_values_override = templatefile(
133+
"${path.root}/helm-values-templates/cert-manager-values.yaml.tpl",
134+
{}
135+
)
136+
helm_user_values_override = try(base64decode(var.cert_manager_user_values_override), var.cert_manager_user_values_override)
137+
138+
kube_config = one(data.oci_containerengine_cluster_kube_config.kube_config.*.content)
139+
140+
depends_on = [module.oke]
141+
}
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
11
# List of all argo-workflow helm values https://github.com/argoproj/argo-helm/blob/main/charts/argo-workflows/values.yaml
22
crds:
3-
install: true
3+
install: true
4+
5+
server:
6+
ingress:
7+
enabled: true
8+
ingressClassName: nginx
9+
annotations:
10+
cert-manager.io/cluster-issuer: "le-clusterissuer"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
crds:
2+
enabled: true
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
controller:
2+
service:
3+
targetPorts:
4+
http: http
5+
https: https
6+
annotations:
7+
oci.oraclecloud.com/load-balancer-type: "lb"
8+
service.beta.kubernetes.io/oci-load-balancer-shape: "flexible"
9+
service.beta.kubernetes.io/oci-load-balancer-shape-flex-min: "${min_bw}"
10+
service.beta.kubernetes.io/oci-load-balancer-shape-flex-max: "${max_bw}"
11+
service.beta.kubernetes.io/oci-load-balancer-security-list-management-mode: "None"
12+
oci.oraclecloud.com/oci-network-security-groups: "${pub_lb_nsg_id}"
13+
oci.oraclecloud.com/initial-freeform-tags-override: '{"state_id": "${state_id}", "application": "nginx", "role": "service_lb"}'

main.tf

+7
Original file line numberDiff line numberDiff line change
@@ -137,3 +137,10 @@ output "operator" {
137137
output "ssh_to_operator" {
138138
value = "%{if var.create_operator_and_bastion}${module.oke.ssh_to_operator}%{else}bastion and operator hosts not created.%{endif}"
139139
}
140+
141+
output "argo_url" {
142+
value = (var.deploy_nginx && var.deploy_argo_workflows && length(coalesce(data.oci_load_balancer_load_balancers.lbs.load_balancers, [])) > 0 ?
143+
"https://argo.${data.oci_load_balancer_load_balancers.lbs.load_balancers[0].ip_addresses[0]}.io" :
144+
""
145+
)
146+
}

schema.yaml

+31
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,11 @@ variableGroups:
101101
visible: true
102102
variables:
103103
- deploy_argo_workflows
104+
- argo_workflows_values_override
105+
- deploy_nginx
106+
- nginx_user_values_override
107+
- deploy_cert_manager
108+
- cert_manager_user_values_override
104109

105110
variables:
106111
create_iam_resources:
@@ -344,6 +349,32 @@ variables:
344349
title: Helm | Argo Workflows helm chart values override
345350
description: Override the values for the <a href="https://github.com/argoproj/argo-helm/blob/main/charts/argo-workflows/values.yaml">Argo Workflows Helm chart</a> .
346351
visible: ${deploy_argo_workflows}
352+
353+
deploy_nginx:
354+
type: boolean
355+
default: true
356+
title: Helm | Deploy Nginx ingress controller
357+
description: Nginx ingress controller is used to expose the OKE services to the user.
358+
visible: true
359+
360+
nginx_user_values_override:
361+
type: file
362+
title: Helm | Nginx Ingress Controller helm chart values override
363+
description: Override the values for the <a href="https://github.com/kubernetes/ingress-nginx/blob/main/charts/ingress-nginx/README.md">Nginx Ingress Controller Helm chart</a> .
364+
visible: ${deploy_nginx}
365+
366+
deploy_cert_manager:
367+
type: boolean
368+
default: true
369+
title: Helm | Deploy Cert-Manager
370+
description: Cert-manager is used to generate TLS certificates for the ingress resources.
371+
visible: true
372+
373+
cert_manager_user_values_override:
374+
type: file
375+
title: Helm | Cert-Manager helm chart values override
376+
description: Override the values for the <a href="https://artifacthub.io/packages/helm/cert-manager/cert-manager">Cert-Manager chart</a> .
377+
visible: ${deploy_cert_manager}
347378

348379
outputs:
349380
bastion:

variables.tf

+25
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,7 @@ variable "simple_np_boot_volume_size" {
440440
description = "The boot volume size for the nodes in the non-GPU kubernetes nodepool."
441441
}
442442

443+
### Helm chart deployments
443444
variable "deploy_argo_workflows" {
444445
type = bool
445446
default = true
@@ -450,4 +451,28 @@ variable "argo_workflows_user_values_override" {
450451
type = string
451452
default = ""
452453
description = "User provided values to override the Argo Workflows helm chart defaults and those generated by Terraform using the templates."
454+
}
455+
456+
variable "deploy_nginx" {
457+
type = bool
458+
default = true
459+
description = "Controls the deployment of the nginx helm chart."
460+
}
461+
462+
variable "nginx_user_values_override" {
463+
type = string
464+
default = ""
465+
description = "User provided values to override the Nginx helm chart defaults and those generated by Terraform using the templates."
466+
}
467+
468+
variable "deploy_cert_manager" {
469+
type = bool
470+
default = true
471+
description = "Controls the deployment of the cert-manager helm chart."
472+
}
473+
474+
variable "cert_manager_user_values_override" {
475+
type = string
476+
default = ""
477+
description = "User provided values to override the Cert-Manager helm chart defaults and those generated by Terraform using the templates."
453478
}

0 commit comments

Comments
 (0)