@@ -6,48 +6,6 @@ locals {
6
6
vcn_cidr = " 10.22.0.0/16"
7
7
}
8
8
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
-
51
9
module "oke" {
52
10
source = " oracle-terraform-modules/oke/oci"
53
11
version = " 5.1.3"
@@ -71,8 +29,8 @@ module "oke" {
71
29
cidr = local.cp_subnet_cidr
72
30
}
73
31
pub_lb = {
74
- create = " never " ,
75
- id = oci_core_subnet.pub_lb_subnet.id
32
+ create = " always " ,
33
+ cidr = local.lb_subnet_cidr
76
34
}
77
35
workers = {
78
36
create = " always" ,
@@ -94,8 +52,16 @@ module "oke" {
94
52
workers = { create = " always" }
95
53
pods = { create = " never" }
96
54
}
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
+ }
99
65
# Network module - security
100
66
allow_node_port_access = true
101
67
allow_worker_internet_access = true
@@ -143,3 +109,17 @@ module "oke" {
143
109
}
144
110
}
145
111
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
+
0 commit comments