1
1
locals {
2
2
cluster_k8s_latest_version = reverse (sort (data. oci_containerengine_cluster_option . oke . kubernetes_versions ))[0 ]
3
+ lb_subnet_cidr = " 10.22.128.0/27"
4
+ workers_subnet_cidr = " 10.22.144.0/20"
5
+ cp_subnet_cidr = " 10.22.0.8/29"
6
+ vcn_cidr = " 10.22.0.0/16"
7
+ }
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
+ destination_port_range {
26
+ max = 80
27
+ min = 80
28
+ }
29
+ }
30
+ }
31
+ egress_security_rules {
32
+ destination = local. workers_subnet_cidr
33
+ protocol = " 6"
34
+ destination_type = " CIDR_BLOCK"
35
+ description = " Allow OCI load balancer or network load balancer to communicate with kube-proxy on worker nodes."
36
+ tcp_options {
37
+ destination_port_range {
38
+ max = 10256
39
+ min = 10256
40
+ }
41
+ }
42
+ }
43
+ }
44
+
45
+ resource "oci_core_subnet" "pub_lb_subnet" {
46
+ cidr_block = local. lb_subnet_cidr
47
+ compartment_id = var. compartment_ocid
48
+ vcn_id = oci_core_vcn. oke_vcn . id
49
+ prohibit_public_ip_on_vnic = false
50
+ dns_label = " plb"
51
+ display_name = " pub_lb"
52
+ security_list_ids = [oci_core_security_list . pub_lb_sl . id ]
3
53
}
4
54
5
55
module "oke" {
@@ -22,15 +72,14 @@ module "oke" {
22
72
}
23
73
cp = {
24
74
create = " always" ,
25
- cidr = " 10.22.0.8/29 "
75
+ cidr = local.cp_subnet_cidr
26
76
}
27
77
pub_lb = {
28
- create = " always" ,
29
- cidr = " 10.22.128.0/27"
78
+ create = " never"
30
79
}
31
80
workers = {
32
81
create = " always" ,
33
- cidr = " 10.22.144.0/20 "
82
+ cidr = local.workers_subnet_cidr
34
83
}
35
84
int_lb = {
36
85
create = " never"
@@ -44,21 +93,12 @@ module "oke" {
44
93
operator = { create = " never" }
45
94
cp = { create = " always" }
46
95
int_lb = { create = " never" }
47
- pub_lb = { create = " always " }
96
+ pub_lb = { create = " never " }
48
97
workers = { create = " always" }
49
98
pods = { create = " never" }
50
99
}
51
- assign_dns = true
52
- create_vcn = true
53
- vcn_cidrs = [" 10.22.0.0/16" ]
54
- vcn_dns_label = " oke"
55
- vcn_name = " oke-${ random_string . deploy_id . result } -vcn"
56
- lockdown_default_seclist = true
57
- allow_rules_public_lb = {
58
- " Allow TCP ingress to public load balancers for SSL traffic from anywhere" : { protocol = 6 , port = 443 , source= " 0.0.0.0/0" , source_type= " CIDR_BLOCK" },
59
- " 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" },
60
- " Allow TCP egress from public load balancers to worker nodes for health checks" : {protocol = 6 , port= - 1 , source = " 10.22.144.0/20" , source_type= " CIDR_BLOCK" }
61
- }
100
+ create_vcn = false
101
+ vcn_id = oci_core_vcn. oke_vcn . id
62
102
# Network module - security
63
103
allow_node_port_access = true
64
104
allow_worker_internet_access = true
0 commit comments