Skip to content

Commit 9ae85de

Browse files
committed
Fix missing LB rule
1 parent 17dfbe2 commit 9ae85de

File tree

2 files changed

+28
-46
lines changed

2 files changed

+28
-46
lines changed

deploy/devops/tf-env/oke.tf

Lines changed: 26 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -6,48 +6,6 @@ locals {
66
vcn_cidr = "10.22.0.0/16"
77
}
88

9-
resource "oci_core_vcn" "oke_vcn" {
10-
compartment_id = var.compartment_ocid
11-
cidr_blocks = [local.vcn_cidr]
12-
display_name = "oke-${random_string.deploy_id.result}-vcn"
13-
dns_label = "oke"
14-
}
15-
16-
resource "oci_core_security_list" "pub_lb_sl" {
17-
compartment_id = var.compartment_ocid
18-
vcn_id = oci_core_vcn.oke_vcn.id
19-
ingress_security_rules {
20-
protocol = "6"
21-
source = "0.0.0.0/0"
22-
source_type = "CIDR_BLOCK"
23-
description = "Allow HTTP for all load balancers"
24-
tcp_options {
25-
max = 80
26-
min = 80
27-
}
28-
}
29-
egress_security_rules {
30-
destination = local.workers_subnet_cidr
31-
protocol = "6"
32-
destination_type = "CIDR_BLOCK"
33-
description = "Allow OCI load balancer or network load balancer to communicate with kube-proxy on worker nodes."
34-
tcp_options {
35-
max = 10256
36-
min = 10256
37-
}
38-
}
39-
}
40-
41-
resource "oci_core_subnet" "pub_lb_subnet" {
42-
cidr_block = local.lb_subnet_cidr
43-
compartment_id = var.compartment_ocid
44-
vcn_id = oci_core_vcn.oke_vcn.id
45-
prohibit_public_ip_on_vnic = false
46-
dns_label = "plb"
47-
display_name = "pub_lb"
48-
security_list_ids = [oci_core_security_list.pub_lb_sl.id]
49-
}
50-
519
module "oke" {
5210
source = "oracle-terraform-modules/oke/oci"
5311
version = "5.1.3"
@@ -71,8 +29,8 @@ module "oke" {
7129
cidr = local.cp_subnet_cidr
7230
}
7331
pub_lb = {
74-
create = "never",
75-
id = oci_core_subnet.pub_lb_subnet.id
32+
create = "always",
33+
cidr = local.lb_subnet_cidr
7634
}
7735
workers = {
7836
create = "always",
@@ -94,8 +52,16 @@ module "oke" {
9452
workers = { create = "always"}
9553
pods = { create = "never" }
9654
}
97-
create_vcn = false
98-
vcn_id = oci_core_vcn.oke_vcn.id
55+
assign_dns = true
56+
create_vcn = true
57+
vcn_cidrs = [local.vcn_cidr]
58+
vcn_dns_label = "oke"
59+
vcn_name = "oke-${random_string.deploy_id.result}-vcn"
60+
lockdown_default_seclist = true
61+
allow_rules_public_lb ={
62+
"Allow TCP ingress to public load balancers for HTTPS traffic from anywhere" : { protocol = 6, port = 443, source="0.0.0.0/0", source_type="CIDR_BLOCK"},
63+
"Allow TCP ingress to public load balancers for HTTP traffic from anywhere" : { protocol = 6, port = 80, source="0.0.0.0/0", source_type="CIDR_BLOCK"}
64+
}
9965
# Network module - security
10066
allow_node_port_access = true
10167
allow_worker_internet_access = true
@@ -143,3 +109,17 @@ module "oke" {
143109
}
144110
}
145111

112+
resource "null_resource" "add_sec_rules_lb" {
113+
114+
provisioner "local-exec" {
115+
command = "chmod +x ./pub_lb_sec.sh && ./pub_lb_sec.sh"
116+
environment = {
117+
PUB_LB_SUBNET_ID = module.oke.pub_lb_subnet_id
118+
}
119+
working_dir = path.module
120+
}
121+
122+
depends_on = [module.oke]
123+
count = 0
124+
}
125+

deploy/devops/tf-env/pub_lb_sec.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/bash
2+

0 commit comments

Comments
 (0)