Skip to content

Commit 038bd7a

Browse files
authored
Merge pull request #2609 from oracle-devrel/oke-rm
oke-rm-1.3.2
2 parents 5d625f4 + 7e85219 commit 038bd7a

16 files changed

Lines changed: 388 additions & 10 deletions

File tree

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ This stack is used to create the initial network infrastructure for OKE. When co
1717
* You can apply this stack even on an existing VCN, so that only the NSGs for OKE will be created
1818
* The default CNI is the VCN Native CNI, and it is the recommended one
1919

20-
[![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.3.1/infra.zip)
20+
[![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.3.2/infra.zip)
2121

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

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

26-
[![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.3.1/oke.zip)
26+
[![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.3.2/oke.zip)
2727

2828
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,
2929
you must add these policies:
126 KB
Loading
1.28 KB
Binary file not shown.

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@ module "network" {
5656
db_subnet_name = var.db_subnet_name
5757
db_service_list = local.db_service_list
5858
separate_db_nsg = var.separate_db_nsg
59+
# MESSAGING
60+
create_msg_subnet = var.create_msg_subnet
61+
msg_subnet_cidr = local.subnets.cidr.msg
62+
msg_subnet_dns_label = local.subnets.dns.msg
63+
msg_subnet_name = var.msg_subnet_name
64+
create_streaming_nsg = var.create_streaming_nsg
5965
# GATEWAYS
6066
create_gateways = var.create_gateways
6167
create_internet_gateway = var.create_internet_gateway

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ resource "oci_core_network_security_group_security_rule" "postgres_db_egress" {
4848
destination_type = "NETWORK_SECURITY_GROUP"
4949
destination = local.create_app_db_nsg ? local.app_nsg.nsg_db[local.postgres_service].id : local.app_nsg.nsg_id
5050
stateless = true
51-
description = "Allow communication from applications to pods"
51+
description = "Allow communication from postgres to applications"
5252
tcp_options {
5353
source_port_range {
5454
max = 5432

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,3 +101,16 @@ resource "oci_core_dhcp_options" "db_dhcp" {
101101
}
102102
count = local.create_db_subnet ? 1 : 0
103103
}
104+
105+
resource "oci_core_dhcp_options" "msg_dhcp" {
106+
compartment_id = var.network_compartment_id
107+
vcn_id = local.vcn_id
108+
display_name = var.msg_subnet_name
109+
freeform_tags = var.tag_value.freeformTags
110+
defined_tags = var.tag_value.definedTags
111+
options {
112+
type = "DomainNameServer"
113+
server_type = "VcnLocalPlusInternet"
114+
}
115+
count = local.create_msg_subnet ? 1 : 0
116+
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,14 @@ locals {
2525
create_db_subnet = var.create_db_subnet && var.create_vcn && length(var.db_service_list) > 0
2626
create_app_db_nsg = length(var.db_service_list) > 0 && var.separate_db_nsg
2727

28+
create_msg_subnet = var.create_msg_subnet && var.create_vcn
2829

2930
tcp_protocol = "6"
3031
icmp_protocol = "1"
3132
udp_protocol = "17"
3233
postgres_service = "postgres"
3334
cache_service = "cache"
3435
oracledb_service = "oracledb"
35-
mysql_service = "mysql"
36+
mysql_service = "mysql"
3637
service_cidr_block = lookup(data.oci_core_services.all_oci_services.services[0], "cidr_block")
3738
}

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

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,3 +404,73 @@ resource "oci_core_network_security_group_security_rule" "mysql_x_pod_ingress" {
404404
}
405405
count = local.is_npn && !var.separate_db_nsg && local.create_db_nsg && contains(var.db_service_list, local.mysql_service) ? 1 : 0
406406
}
407+
408+
# OCI Streaming
409+
410+
resource "oci_core_network_security_group_security_rule" "streaming_kafka_pod_ingress" {
411+
direction = "EGRESS"
412+
network_security_group_id = oci_core_network_security_group.pod_nsg.0.id
413+
protocol = local.tcp_protocol
414+
destination_type = "NETWORK_SECURITY_GROUP"
415+
destination = oci_core_network_security_group.streaming.0.id
416+
stateless = true
417+
description = "Allow communication from pods to OCI Streaming Kafka API"
418+
tcp_options {
419+
destination_port_range {
420+
max = 9092
421+
min = 9092
422+
}
423+
}
424+
count = local.is_npn && var.create_streaming_nsg ? 1 : 0
425+
}
426+
427+
resource "oci_core_network_security_group_security_rule" "streaming_kafka_pod_egress" {
428+
direction = "INGRESS"
429+
network_security_group_id = oci_core_network_security_group.pod_nsg.0.id
430+
protocol = local.tcp_protocol
431+
source_type = "NETWORK_SECURITY_GROUP"
432+
source = oci_core_network_security_group.streaming.0.id
433+
stateless = true
434+
description = "Allow communication from OCI Streaming Kafka API to pods"
435+
tcp_options {
436+
source_port_range {
437+
max = 9092
438+
min = 9092
439+
}
440+
}
441+
count = local.is_npn && var.create_streaming_nsg ? 1 : 0
442+
}
443+
444+
resource "oci_core_network_security_group_security_rule" "streaming_rest_pod_ingress" {
445+
direction = "EGRESS"
446+
network_security_group_id = oci_core_network_security_group.pod_nsg.0.id
447+
protocol = local.tcp_protocol
448+
destination_type = "NETWORK_SECURITY_GROUP"
449+
destination = oci_core_network_security_group.streaming.0.id
450+
stateless = true
451+
description = "Allow communication from pods to OCI Streaming REST API (SDK)"
452+
tcp_options {
453+
destination_port_range {
454+
max = 443
455+
min = 443
456+
}
457+
}
458+
count = local.is_npn && var.create_streaming_nsg ? 1 : 0
459+
}
460+
461+
resource "oci_core_network_security_group_security_rule" "streaming_rest_pod_egress" {
462+
direction = "INGRESS"
463+
network_security_group_id = oci_core_network_security_group.pod_nsg.0.id
464+
protocol = local.tcp_protocol
465+
source_type = "NETWORK_SECURITY_GROUP"
466+
source = oci_core_network_security_group.streaming.0.id
467+
stateless = true
468+
description = "Allow communication from OCI Streaming REST API (SDK) to pods"
469+
tcp_options {
470+
source_port_range {
471+
max = 443
472+
min = 443
473+
}
474+
}
475+
count = local.is_npn && var.create_streaming_nsg ? 1 : 0
476+
}

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,4 +221,19 @@ resource "oci_core_route_table" "db_route_table" {
221221
description = "Route for all internal OCI services in the region"
222222
}
223223
count = local.create_db_subnet ? 1 : 0
224+
}
225+
226+
resource "oci_core_route_table" "msg_route_table" {
227+
compartment_id = var.network_compartment_id
228+
vcn_id = local.vcn_id
229+
display_name = var.msg_subnet_name
230+
freeform_tags = var.tag_value.freeformTags
231+
defined_tags = var.tag_value.definedTags
232+
route_rules {
233+
network_entity_id = local.service_gateway_id
234+
destination_type = "SERVICE_CIDR_BLOCK"
235+
destination = local.service_cidr_block
236+
description = "Route for all internal OCI services in the region"
237+
}
238+
count = local.create_msg_subnet ? 1 : 0
224239
}

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

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,3 +462,60 @@ resource "oci_core_security_list" "db_sl" {
462462

463463
count = local.create_db_subnet ? 1 : 0
464464
}
465+
466+
resource "oci_core_security_list" "msg_sl" {
467+
compartment_id = var.network_compartment_id
468+
vcn_id = local.vcn_id
469+
display_name = var.msg_subnet_name
470+
freeform_tags = var.tag_value.freeformTags
471+
defined_tags = var.tag_value.definedTags
472+
473+
# Ingress rules and their corresponding egress
474+
ingress_security_rules {
475+
description = "Required to enable Path MTU Discovery to work, and non-OCI communication"
476+
icmp_options {
477+
code = "4"
478+
type = "3"
479+
}
480+
protocol = local.icmp_protocol
481+
source = "0.0.0.0/0"
482+
source_type = "CIDR_BLOCK"
483+
stateless = "true"
484+
}
485+
486+
egress_security_rules {
487+
description = "Required to enable Path MTU Discovery responses to work, and non-OCI communication"
488+
icmp_options {
489+
code = "4"
490+
type = "3"
491+
}
492+
protocol = local.icmp_protocol
493+
destination = "0.0.0.0/0"
494+
destination_type = "CIDR_BLOCK"
495+
stateless = "true"
496+
}
497+
498+
ingress_security_rules {
499+
description = "Required to allow application within VCN to fail fast"
500+
icmp_options {
501+
type = "3"
502+
}
503+
protocol = local.icmp_protocol
504+
source = oci_core_vcn.spoke_vcn[0].cidr_block
505+
source_type = "CIDR_BLOCK"
506+
stateless = "true"
507+
}
508+
509+
egress_security_rules {
510+
description = "Required to allow application within VCN responses to fail fast"
511+
icmp_options {
512+
type = "3"
513+
}
514+
protocol = local.icmp_protocol
515+
destination = oci_core_vcn.spoke_vcn[0].cidr_block
516+
destination_type = "CIDR_BLOCK"
517+
stateless = "true"
518+
}
519+
520+
count = local.create_msg_subnet ? 1 : 0
521+
}

0 commit comments

Comments
 (0)