Skip to content

Commit 97f780d

Browse files
authored
Merge pull request #23 from junior/5G-example
5G example initial infra
2 parents 087634c + 112b9c7 commit 97f780d

File tree

10 files changed

+103
-49
lines changed

10 files changed

+103
-49
lines changed

.terraform.lock.hcl

Lines changed: 17 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.8.9
1+
0.8.10

cluster-tools.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ module "cluster-tools" {
4646
## Grafana
4747
grafana_enabled = var.grafana_enabled
4848

49-
depends_on = [module.oke, module.oke_node_pool, module.oke_cluster_autoscaler]
49+
depends_on = [module.oke, module.oke_node_pools, module.oke_cluster_autoscaler]
5050
}
5151

5252
# Kubernetes Cluster Tools

datasources.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ data "oci_core_services" "all_services_network" {
2525
values = ["All .* Services In Oracle Services Network"]
2626
regex = true
2727
}
28-
}
28+
}

examples/5G-NF-Infra/networking.tf

Lines changed: 66 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ locals {
77
vcn_cidr_blocks = split(",", var.vcn_cidr_blocks)
88
network_cidrs = {
99
VCN-MAIN-CIDR = local.vcn_cidr_blocks[0] # e.g.: "10.75.0.0/16" = 65536 usable IPs
10-
VCN-NATIVE-POD-NETWORKING-REGIONAL-SUBNET-CIDR = cidrsubnet(local.vcn_cidr_blocks[0], 1, 1) # e.g.: "10.20.128.0/17" = 32766 usable IPs (10.20.128.0 - 10.20.255.255)
10+
VCN-NATIVE-POD-NETWORKING-REGIONAL-SUBNET-CIDR = cidrsubnet(local.vcn_cidr_blocks[0], 1, 1) # e.g.: "10.75.128.0/17" = 32766 usable IPs (10.20.128.0 - 10.20.255.255)
1111
SUBNET-5GC-OAM-CIDR = cidrsubnet(local.vcn_cidr_blocks[0], 9, 128) # e.g.: "10.75.64.0/25" = 128 usable IPs
1212
SUBNET-5GC-SIGNALLING-CIDR = cidrsubnet(local.vcn_cidr_blocks[0], 9, 129) # e.g.: "10.75.64.128/25" = 128 usable IPs
1313
SUBNET-5G-RAN-CIDR = cidrsubnet(local.vcn_cidr_blocks[0], 11, 520) # e.g.: "10.75.65.0/27" = 32 usable IPs
@@ -247,4 +247,68 @@ locals {
247247
ipv6cidr_block = null
248248
},
249249
]
250-
}
250+
}
251+
252+
# Node Pool 1 info for 5G VNICs attachments
253+
data "oci_containerengine_node_pool" "node_pool_1" {
254+
node_pool_id = module.oke-quickstart.oke_node_pools["pool1"].node_pool_id
255+
}
256+
locals {
257+
node_pool_nodes = data.oci_containerengine_node_pool.node_pool_1.nodes
258+
node_pool_nodes_ids = data.oci_containerengine_node_pool.node_pool_1.nodes.*.id
259+
}
260+
resource "oci_core_vnic_attachment" "vnic_attachment_5gc_oam" {
261+
for_each = { for map in local.node_pool_nodes : map.id => map }
262+
create_vnic_details {
263+
display_name = "5GC-OAM vnic"
264+
private_ip = [for hostnum in range(4, 15) : cidrhost(lookup(local.network_cidrs, "SUBNET-5GC-OAM-CIDR"), hostnum)][index(local.node_pool_nodes_ids, each.key)]
265+
subnet_id = module.oke-quickstart.subnets["5GC_OAM_subnet"].subnet_id
266+
defined_tags = {}
267+
freeform_tags = { "Network" : "5GC-OAM" }
268+
}
269+
instance_id = each.value.id
270+
}
271+
resource "oci_core_vnic_attachment" "vnic_attachment_5gc_signalling" {
272+
for_each = { for map in local.node_pool_nodes : map.id => map }
273+
create_vnic_details {
274+
display_name = "5GC-Signalling vnic"
275+
private_ip = [for hostnum in range(4, 15) : cidrhost(lookup(local.network_cidrs, "SUBNET-5GC-SIGNALLING-CIDR"), hostnum)][index(local.node_pool_nodes_ids, each.key)]
276+
subnet_id = module.oke-quickstart.subnets["5GC_Signalling_subnet"].subnet_id
277+
defined_tags = {}
278+
freeform_tags = { "Network" : "5GC-Signalling" }
279+
}
280+
instance_id = each.value.id
281+
}
282+
resource "oci_core_vnic_attachment" "vnic_attachment_5g_ran" {
283+
for_each = { for map in local.node_pool_nodes : map.id => map }
284+
create_vnic_details {
285+
display_name = "5G RAN vnic"
286+
private_ip = [for hostnum in range(4, 15) : cidrhost(lookup(local.network_cidrs, "SUBNET-5G-RAN-CIDR"), hostnum)][index(local.node_pool_nodes_ids, each.key)]
287+
subnet_id = module.oke-quickstart.subnets["5G_RAN_subnet"].subnet_id
288+
defined_tags = {}
289+
freeform_tags = { "Network" : "5G RAN" }
290+
}
291+
instance_id = each.value.id
292+
}
293+
resource "oci_core_vnic_attachment" "vnic_attachment_5g_legal_intercept" {
294+
for_each = { for map in local.node_pool_nodes : map.id => map }
295+
create_vnic_details {
296+
display_name = "5G Legal Intercept vnic"
297+
private_ip = [for hostnum in range(4, 15) : cidrhost(lookup(local.network_cidrs, "SUBNET-LEGAL-INTERCEPT-CIDR"), hostnum)][index(local.node_pool_nodes_ids, each.key)]
298+
subnet_id = module.oke-quickstart.subnets["Legal_Intercept_subnet"].subnet_id
299+
defined_tags = {}
300+
freeform_tags = { "Network" : "5G Legal Intercept" }
301+
}
302+
instance_id = each.value.id
303+
}
304+
resource "oci_core_vnic_attachment" "vnic_attachment_5g_epc" {
305+
for_each = { for map in local.node_pool_nodes : map.id => map }
306+
create_vnic_details {
307+
display_name = "5G-EPC vnic"
308+
private_ip = [for hostnum in range(4, 15) : cidrhost(lookup(local.network_cidrs, "SUBNET-5G-EPC-CIDR"), hostnum)][index(local.node_pool_nodes_ids, each.key)]
309+
subnet_id = module.oke-quickstart.subnets["5G_EPC_subnet"].subnet_id
310+
defined_tags = {}
311+
freeform_tags = { "Network" : "5G-EPC" }
312+
}
313+
instance_id = each.value.id
314+
}

examples/5G-NF-Infra/oke.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# OKE Cluster
77
################################################################################
88
module "oke-quickstart" {
9-
source = "github.com/oracle-quickstart/terraform-oci-oke-quickstart?ref=0.8.9"
9+
source = "github.com/oracle-quickstart/terraform-oci-oke-quickstart?ref=0.8.10"
1010

1111
# Oracle Cloud Infrastructure Tenancy and Compartment OCID
1212
tenancy_ocid = var.tenancy_ocid

examples/5G-NF-Infra/variables.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ variable "node_pool_instance_shape_1" {
3535
type = map(any)
3636
default = {
3737
"instanceShape" = "VM.Standard3.Flex"
38-
"ocpus" = 6
38+
"ocpus" = 8
3939
"memory" = 96
4040
}
41-
description = "Pooll: A shape is a template that determines the number of OCPUs, amount of memory, and other resources allocated to a newly created instance for the Worker Node. Select at least 2 OCPUs and 16GB of memory if using Flex shapes"
41+
description = "Pooll: A shape is a template that determines the number of OCPUs, amount of memory, and other resources allocated to a newly created instance for the Worker Node. Select at least 2 OCPUs and 16GB of memory if using Flex shapes."
4242
}

main.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ module "oke" {
9393
################################################################################
9494
# Module: OKE Node Pool
9595
################################################################################
96-
module "oke_node_pool" {
96+
module "oke_node_pools" {
9797
for_each = { for map in local.node_pools : map.node_pool_name => map }
9898
source = "./modules/oke-node-pool"
9999

@@ -176,9 +176,9 @@ module "oke_cluster_autoscaler" {
176176

177177
## Enable Cluster Autoscaler
178178
cluster_autoscaler_enabled = var.cluster_autoscaler_enabled
179-
oke_node_pools = values(module.oke_node_pool)
179+
oke_node_pools = values(module.oke_node_pools)
180180

181-
depends_on = [module.oke, module.oke_node_pool]
181+
depends_on = [module.oke, module.oke_node_pools]
182182
}
183183

184184
resource "oci_identity_compartment" "oke_compartment" {

modules/oke/outputs.tf

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -39,24 +39,3 @@ output "oke_cluster_compartment_ocid" {
3939
value = local.oke_compartment_ocid
4040
description = "Compartment OCID used by the OKE Cluster"
4141
}
42-
43-
# ### Important Security Notice ###
44-
# # The private key generated by this resource will be stored unencrypted in your Terraform state file.
45-
# # Use of this resource for production deployments is not recommended.
46-
# # Instead, generate a private key file outside of Terraform and distribute it securely to the system where Terraform will be run.
47-
# output "generated_private_key_pem" {
48-
# value = var.generate_public_ssh_key ? tls_private_key.oke_worker_node_ssh_key.private_key_pem : "No Keys Auto Generated"
49-
# sensitive = true
50-
# }
51-
52-
# output "oke_debug_oke_private_endpoint" {
53-
# value = oci_containerengine_cluster.oke_cluster[0].endpoints.0.private_endpoint
54-
# }
55-
56-
# output "oke_debug_orm_private_endpoint_reachable_ip" {
57-
# value = data.oci_resourcemanager_private_endpoint_reachable_ip.private_kubernetes_endpoint.0.ip_address
58-
# }
59-
60-
# output "oke_debug_oke_endpoints" {
61-
# value = oci_containerengine_cluster.oke_cluster.0.endpoints
62-
# }

outputs.tf

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,16 @@ output "kubeconfig_for_kubectl" {
2828
value = module.oke.kubeconfig_for_kubectl
2929
description = "If using Terraform locally, this command set KUBECONFIG environment variable to run kubectl locally"
3030
}
31+
output "oke_cluster_ocid" {
32+
value = module.oke.oke_cluster_ocid
33+
}
34+
output "oke_node_pools" {
35+
value = module.oke_node_pools
36+
}
37+
output "subnets" {
38+
value = module.subnets
39+
}
40+
3141
output "dev" {
3242
value = module.oke.dev
3343
}
@@ -39,3 +49,4 @@ output "generated_private_key_pem" {
3949
value = var.generate_public_ssh_key ? tls_private_key.oke_worker_node_ssh_key.private_key_pem : "No Keys Auto Generated"
4050
sensitive = true
4151
}
52+

0 commit comments

Comments
 (0)