Skip to content

Commit 7e83caa

Browse files
authored
Merge pull request #2320 from oracle-devrel/oke-rm
oke-rm-1.1.9
2 parents af152cb + 66eca3a commit 7e83caa

File tree

15 files changed

+113
-115
lines changed

15 files changed

+113
-115
lines changed

app-dev/devops-and-containers/oke/oke-rm/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ This stack is used to create the initial network infrastructure for OKE. When co
1616
* By default, everything is private, but there is the possibility to create public subnets
1717
* Be careful when modifying the default values, as inputs are not validated
1818

19-
[![Deploy to Oracle Cloud](https://oci-resourcemanager-plugin.plugins.oci.oraclecloud.com/latest/deploy-to-oracle-cloud.svg)](https://cloud.oracle.com/resourcemanager/stacks/create?zipUrl=https://github.com/oracle-devrel/technology-engineering/releases/download/oke-rm-1.1.8/infra.zip)
19+
[![Deploy to Oracle Cloud](https://oci-resourcemanager-plugin.plugins.oci.oraclecloud.com/latest/deploy-to-oracle-cloud.svg)](https://cloud.oracle.com/resourcemanager/stacks/create?zipUrl=https://github.com/oracle-devrel/technology-engineering/releases/download/oke-rm-1.1.9/infra.zip)
2020

2121
## Step 2: Create the OKE control plane
2222

2323
This stack is used to create the OKE control plane ONLY.
2424

25-
[![Deploy to Oracle Cloud](https://oci-resourcemanager-plugin.plugins.oci.oraclecloud.com/latest/deploy-to-oracle-cloud.svg)](https://cloud.oracle.com/resourcemanager/stacks/create?zipUrl=https://github.com/oracle-devrel/technology-engineering/releases/download/oke-rm-1.1.8/oke.zip)
25+
[![Deploy to Oracle Cloud](https://oci-resourcemanager-plugin.plugins.oci.oraclecloud.com/latest/deploy-to-oracle-cloud.svg)](https://cloud.oracle.com/resourcemanager/stacks/create?zipUrl=https://github.com/oracle-devrel/technology-engineering/releases/download/oke-rm-1.1.9/oke.zip)
2626

2727
Also note that if the network infrastructure is located in a different compartment than the OKE cluster AND you are planning to use the OCI_VCN_NATIVE CNI,
2828
you must add these policies:
-89 Bytes
Binary file not shown.

app-dev/devops-and-containers/oke/oke-rm/infra/local.tf

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ locals {
44
vcn_cidr_blocks = [var.vcn_cidr_block]
55
subnets = {
66
cidr = {
7-
pod = cidrsubnet(var.vcn_cidr_block, 1, 0) # e.g., "10.1.0.0/17"
8-
worker = cidrsubnet(var.vcn_cidr_block, 3, 4) # e.g., "10.1.128.0/19"
9-
lb_external = cidrsubnet(var.vcn_cidr_block, 8, 160) # e.g., "10.1.160.0/24"
10-
lb_internal = cidrsubnet(var.vcn_cidr_block, 8, 161) # e.g., "10.1.161.0/24"
11-
fss = cidrsubnet(var.vcn_cidr_block, 8, 162) # e.g., "10.1.162.0/24"
12-
bastion = cidrsubnet(var.vcn_cidr_block, 13, 5216) # e.g., "10.1.163.0/29"
13-
cp = cidrsubnet(var.vcn_cidr_block, 13, 5217) # e.g., "10.1.163.8/29"
7+
pod = var.create_vcn ? cidrsubnet(var.vcn_cidr_block, 1, 0) : null # e.g., "10.1.0.0/17"
8+
worker = var.create_vcn ? cidrsubnet(var.vcn_cidr_block, 3, 4) : null # e.g., "10.1.128.0/19"
9+
lb_external = var.create_vcn ? cidrsubnet(var.vcn_cidr_block, 8, 160) : null # e.g., "10.1.160.0/24"
10+
lb_internal = var.create_vcn ? cidrsubnet(var.vcn_cidr_block, 8, 161) : null # e.g., "10.1.161.0/24"
11+
fss = var.create_vcn ? cidrsubnet(var.vcn_cidr_block, 8, 162) : null # e.g., "10.1.162.0/24"
12+
bastion = var.create_vcn ? cidrsubnet(var.vcn_cidr_block, 13, 5216) : null # e.g., "10.1.163.0/29"
13+
cp = var.create_vcn ? cidrsubnet(var.vcn_cidr_block, 13, 5217) : null # e.g., "10.1.163.8/29"
1414
}
1515
dns = {
1616
pod = "pod"

app-dev/devops-and-containers/oke/oke-rm/infra/main.tf

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@ module "network" {
4949
fss_subnet_name = var.fss_subnet_name
5050
# GATEWAYS
5151
create_gateways = var.create_gateways
52-
nat_gateway_id = var.nat_gateway_id
53-
service_gateway_id = var.service_gateway_id
5452
create_internet_gateway = var.create_internet_gateway
5553
# CONTROL PLANE EXTERNAL CONNECTION
5654
cp_external_nat = var.cp_external_nat

app-dev/devops-and-containers/oke/oke-rm/infra/modules/network/cp-nsg.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ resource "oci_core_network_security_group_security_rule" "oke_cp_nsg_bastion_api
8585
min = 6443
8686
}
8787
}
88-
count = var.create_bastion_subnet ? 1 : 0
88+
count = local.create_bastion_subnet ? 1 : 0
8989
}
9090

9191
resource "oci_core_network_security_group_security_rule" "oke_cp_nsg_bastion_apiserver_egress" {
@@ -102,7 +102,7 @@ resource "oci_core_network_security_group_security_rule" "oke_cp_nsg_bastion_api
102102
min = 6443
103103
}
104104
}
105-
count = var.create_bastion_subnet ? 1 : 0
105+
count = local.create_bastion_subnet ? 1 : 0
106106
}
107107

108108
# Pods to control plane - Kubelet communication (port 12250)

app-dev/devops-and-containers/oke/oke-rm/infra/modules/network/gateways.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,19 @@ resource "oci_core_service_gateway" "service_gateway" {
55
services {
66
service_id = lookup(data.oci_core_services.all_oci_services.services[0], "id")
77
}
8-
count = var.create_gateways ? 1 : 0
8+
count = local.create_gateways ? 1 : 0
99
}
1010

1111
resource "oci_core_nat_gateway" "nat_gateway" {
1212
compartment_id = var.network_compartment_id
1313
vcn_id = local.vcn_id
1414
display_name = "NAT"
15-
count = var.create_gateways ? 1 : 0
15+
count = local.create_gateways ? 1 : 0
1616
}
1717

1818
resource "oci_core_internet_gateway" "internet_gateway" {
1919
compartment_id = var.network_compartment_id
2020
vcn_id = local.vcn_id
2121
display_name = "IG"
22-
count = local.all_subnet_private && ! local.create_internet_gateway ? 0 : 1
22+
count = local.create_internet_gateway ? 1 : 0
2323
}

app-dev/devops-and-containers/oke/oke-rm/infra/modules/network/local.tf

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,24 @@
11
locals {
22
is_npn = var.cni_type == "npn"
3-
create_pod_subnet = var.create_pod_subnet && local.is_npn
4-
create_cp_subnet = var.create_cp_subnet
5-
create_bastion_subnet = var.create_bastion_subnet
6-
create_fss_subnet = var.create_fss
7-
create_worker_subnet = var.create_worker_subnet
8-
create_external_lb_subnet = var.create_external_lb_subnet
9-
create_internal_lb_subnet = var.create_internal_lb_subnet
3+
create_pod_subnet = var.create_pod_subnet && local.is_npn && var.create_vcn
4+
create_cp_subnet = var.create_cp_subnet && var.create_vcn
5+
create_bastion_subnet = var.create_bastion_subnet && var.create_vcn
6+
create_fss_subnet = var.create_fss && var.create_vcn
7+
create_worker_subnet = var.create_worker_subnet && var.create_vcn
8+
create_external_lb_subnet = var.create_external_lb_subnet && var.create_vcn
9+
create_internal_lb_subnet = var.create_internal_lb_subnet && var.create_vcn
1010
all_subnet_private = (var.cp_subnet_private || ! local.create_cp_subnet) && (! local.create_external_lb_subnet) && (var.bastion_subnet_private || ! var.create_bastion_subnet)
1111
vcn_id = var.create_vcn ? oci_core_vcn.spoke_vcn.0.id : var.vcn_id
12-
service_gateway_id = var.create_gateways ? oci_core_service_gateway.service_gateway.0.id : var.service_gateway_id
13-
nat_gateway_id = var.create_gateways ? oci_core_nat_gateway.nat_gateway.0.id : var.nat_gateway_id
12+
service_gateway_id = var.create_gateways ? oci_core_service_gateway.service_gateway.0.id : null
13+
nat_gateway_id = var.create_gateways ? oci_core_nat_gateway.nat_gateway.0.id : null
1414
cp_nat_mode = local.create_cp_subnet && var.cp_subnet_private && var.cp_external_nat
1515
create_cp_external_traffic_rule = var.allow_external_cp_traffic && (! var.create_cp_subnet || (! var.cp_subnet_private || var.cp_external_nat))
1616

17-
create_internet_gateway = (! var.create_vcn) && var.create_gateways && var.create_internet_gateway
17+
create_gateways = (var.create_gateways && ! var.create_vcn) || var.create_vcn
18+
create_internet_gateway = (local.create_gateways && ! var.create_vcn && var.create_internet_gateway) || (var.create_vcn && ! local.all_subnet_private)
1819

1920
create_drg = var.enable_drg && var.create_drg
20-
create_drg_attachment = var.enable_drg && var.create_drg_attachment
21+
create_drg_attachment = var.enable_drg && var.create_drg_attachment && var.create_vcn
2122
drg_id = var.create_drg ? try(oci_core_drg.vcn_drg.0.id, null) : var.drg_id
2223

2324

app-dev/devops-and-containers/oke/oke-rm/infra/modules/network/output.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ output "internal_lb_subnet_id" {
2525
}
2626

2727
output "bastion_subnet_id" {
28-
value = var.create_bastion_subnet ? oci_core_subnet.bastion_subnet[0].id : null
28+
value = local.create_bastion_subnet ? oci_core_subnet.bastion_subnet[0].id : null
2929
}
3030

3131
# NSG

app-dev/devops-and-containers/oke/oke-rm/infra/modules/network/variable.tf

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,10 +151,6 @@ variable "create_gateways" {
151151
type = bool
152152
}
153153

154-
variable "service_gateway_id" {}
155-
156-
variable "nat_gateway_id" {}
157-
158154
variable "create_internet_gateway" {
159155
type = bool
160156
}

app-dev/devops-and-containers/oke/oke-rm/infra/modules/network/worker-nsg.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ resource "oci_core_network_security_group_security_rule" "oke_worker_nsg_bastion
183183
min = 22
184184
}
185185
}
186-
count = var.create_bastion_subnet ? 1 : 0
186+
count = local.create_bastion_subnet ? 1 : 0
187187
}
188188

189189
resource "oci_core_network_security_group_security_rule" "oke_worker_nsg_bastion_ssh_egress" {
@@ -200,7 +200,7 @@ resource "oci_core_network_security_group_security_rule" "oke_worker_nsg_bastion
200200
min = 22
201201
}
202202
}
203-
count = var.create_bastion_subnet ? 1 : 0
203+
count = local.create_bastion_subnet ? 1 : 0
204204
}
205205

206206
# Internet - ALL protocols

0 commit comments

Comments
 (0)