Skip to content

Commit f2cfcb1

Browse files
committed
basic-cluster-with-existent-networking-example
Signed-off-by: junior <junior@users.noreply.github.com>
1 parent 58a22f4 commit f2cfcb1

File tree

12 files changed

+180
-77
lines changed

12 files changed

+180
-77
lines changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.8.12
1+
0.8.15

defaults.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
1+
# Copyright (c) 2022-2023 Oracle and/or its affiliates. All rights reserved.
22
# Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
33
#
44

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -301,8 +301,8 @@ resource "oci_core_vnic_attachment" "vnic_attachment_5gc_signalling" {
301301
defined_tags = {}
302302
freeform_tags = { "Network" : "5GC-Signalling" }
303303
}
304-
display_name = "5GC-Signalling vnic Attachment"
305-
instance_id = data.oci_containerengine_node_pool.node_pool_1.nodes[count.index].id
304+
display_name = "5GC-Signalling vnic Attachment"
305+
instance_id = data.oci_containerengine_node_pool.node_pool_1.nodes[count.index].id
306306
}
307307
resource "oci_core_vnic_attachment" "vnic_attachment_5gc_oam" {
308308
count = var.node_pool_initial_num_worker_nodes_1
@@ -313,8 +313,8 @@ resource "oci_core_vnic_attachment" "vnic_attachment_5gc_oam" {
313313
defined_tags = {}
314314
freeform_tags = { "Network" : "5GC-OAM" }
315315
}
316-
display_name = "5GC-OAM vnic Attachment"
317-
instance_id = data.oci_containerengine_node_pool.node_pool_1.nodes[count.index].id
316+
display_name = "5GC-OAM vnic Attachment"
317+
instance_id = data.oci_containerengine_node_pool.node_pool_1.nodes[count.index].id
318318

319319
depends_on = [oci_core_vnic_attachment.vnic_attachment_5gc_signalling]
320320
}
@@ -327,8 +327,8 @@ resource "oci_core_vnic_attachment" "vnic_attachment_5g_ran" {
327327
defined_tags = {}
328328
freeform_tags = { "Network" : "5G RAN" }
329329
}
330-
display_name = "5G RAN vnic Attachment"
331-
instance_id = data.oci_containerengine_node_pool.node_pool_1.nodes[count.index].id
330+
display_name = "5G RAN vnic Attachment"
331+
instance_id = data.oci_containerengine_node_pool.node_pool_1.nodes[count.index].id
332332

333333
depends_on = [oci_core_vnic_attachment.vnic_attachment_5gc_oam]
334334
}
@@ -341,8 +341,8 @@ resource "oci_core_vnic_attachment" "vnic_attachment_5g_legal_intercept" {
341341
defined_tags = {}
342342
freeform_tags = { "Network" : "5G Legal Intercept" }
343343
}
344-
display_name = "5G Legal Intercept vnic Attachment"
345-
instance_id = data.oci_containerengine_node_pool.node_pool_1.nodes[count.index].id
344+
display_name = "5G Legal Intercept vnic Attachment"
345+
instance_id = data.oci_containerengine_node_pool.node_pool_1.nodes[count.index].id
346346

347347
depends_on = [oci_core_vnic_attachment.vnic_attachment_5g_ran]
348348
}
@@ -355,8 +355,8 @@ resource "oci_core_vnic_attachment" "vnic_attachment_5g_epc" {
355355
defined_tags = {}
356356
freeform_tags = { "Network" : "5G-EPC" }
357357
}
358-
display_name = "5G-EPC vnic Attachment"
359-
instance_id = data.oci_containerengine_node_pool.node_pool_1.nodes[count.index].id
358+
display_name = "5G-EPC vnic Attachment"
359+
instance_id = data.oci_containerengine_node_pool.node_pool_1.nodes[count.index].id
360360

361361
depends_on = [oci_core_vnic_attachment.vnic_attachment_5g_legal_intercept]
362362
}

examples/basic-cluster/oke.tf

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1+
# Copyright (c) 2023 Oracle and/or its affiliates. All rights reserved.
2+
# Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
3+
#
4+
15
module "oke-quickstart" {
2-
source = "github.com/oracle-quickstart/terraform-oci-oke-quickstart?ref=0.8.3"
6+
source = "github.com/oracle-quickstart/terraform-oci-oke-quickstart?ref=0.8.15"
37

48
# Oracle Cloud Infrastructure Tenancy and Compartment OCID
59
tenancy_ocid = var.tenancy_ocid
@@ -22,4 +26,4 @@ module "oke-quickstart" {
2226

2327
# VCN for OKE arguments
2428
vcn_cidr_blocks = "10.22.0.0/16"
25-
}
29+
}

examples/basic-cluster/providers.tf

Lines changed: 0 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ terraform {
99
source = "oracle/oci"
1010
version = "~> 4, < 5"
1111
# https://registry.terraform.io/providers/oracle/oci/
12-
configuration_aliases = [oci.home_region, oci.current_region]
1312
}
1413
kubernetes = {
1514
source = "hashicorp/kubernetes"
@@ -38,65 +37,3 @@ terraform {
3837
}
3938
}
4039
}
41-
42-
# provider "oci" {
43-
# tenancy_ocid = var.tenancy_ocid
44-
# region = var.region
45-
# }
46-
47-
# provider "oci" {
48-
# alias = "home_region"
49-
# tenancy_ocid = var.tenancy_ocid
50-
# region = lookup(data.oci_identity_regions.home_region.regions[0], "name")
51-
52-
# user_ocid = var.user_ocid
53-
# fingerprint = var.fingerprint
54-
# private_key_path = var.private_key_path
55-
# }
56-
57-
# provider "oci" {
58-
# alias = "current_region"
59-
# tenancy_ocid = var.tenancy_ocid
60-
# region = var.region
61-
62-
# user_ocid = var.user_ocid
63-
# fingerprint = var.fingerprint
64-
# private_key_path = var.private_key_path
65-
# }
66-
67-
# New configuration to avoid Terraform Kubernetes provider interpolation. https://registry.terraform.io/providers/hashicorp/kubernetes/2.2.0/docs#stacking-with-managed-kubernetes-cluster-resources
68-
# Currently need to uncheck to refresh (--refresh=false) when destroying or else the terraform destroy will fail
69-
70-
# # https://docs.cloud.oracle.com/en-us/iaas/Content/ContEng/Tasks/contengdownloadkubeconfigfile.htm#notes
71-
# provider "kubernetes" {
72-
# host = local.cluster_endpoint
73-
# cluster_ca_certificate = local.cluster_ca_certificate
74-
# exec {
75-
# api_version = "client.authentication.k8s.io/v1beta1"
76-
# args = ["ce", "cluster", "generate-token", "--cluster-id", local.cluster_id, "--region", local.cluster_region]
77-
# command = "oci"
78-
# }
79-
# }
80-
81-
# # https://docs.cloud.oracle.com/en-us/iaas/Content/ContEng/Tasks/contengdownloadkubeconfigfile.htm#notes
82-
# provider "helm" {
83-
# kubernetes {
84-
# host = local.cluster_endpoint
85-
# cluster_ca_certificate = local.cluster_ca_certificate
86-
# exec {
87-
# api_version = "client.authentication.k8s.io/v1beta1"
88-
# args = ["ce", "cluster", "generate-token", "--cluster-id", local.cluster_id, "--region", local.cluster_region]
89-
# command = "oci"
90-
# }
91-
# }
92-
# }
93-
94-
# locals {
95-
# # cluster_endpoint = (var.cluster_endpoint_visibility == "Private") ? (
96-
# # "https://${module.oke.orm_private_endpoint_oke_api_ip_address}:6443") : (
97-
# # yamldecode(module.oke.kubeconfig)["clusters"][0]["cluster"]["server"])
98-
# cluster_endpoint = yamldecode(module.oke.kubeconfig)["clusters"][0]["cluster"]["server"]
99-
# cluster_ca_certificate = base64decode(yamldecode(module.oke.kubeconfig)["clusters"][0]["cluster"]["certificate-authority-data"])
100-
# cluster_id = yamldecode(module.oke.kubeconfig)["users"][0]["user"]["exec"]["args"][4]
101-
# cluster_region = yamldecode(module.oke.kubeconfig)["users"][0]["user"]["exec"]["args"][6]
102-
# }
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Copyright (c) 2023 Oracle and/or its affiliates. All rights reserved.
2+
# Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
3+
#
4+
5+
# OCI authentication
6+
tenancy_ocid = "ocid1.tenancy....."
7+
fingerprint = "" # e.g.: "5f:53:..." or leave blank if using CloudShell
8+
user_ocid = "" # e.g.: "ocid1.user..." or leave blank if using CloudShell
9+
private_key_path = "" # e.g.: "/users/user/.oci/oci_api_key.pem" or leave blank if using CloudShell
10+
11+
# Deployment compartment
12+
compartment_ocid = "ocid1.compartment...."
13+
14+
# region
15+
region = "us-ashburn-1"

examples/basic-cluster/variables.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# Copyright (c) 2023 Oracle and/or its affiliates. All rights reserved.
2+
# Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
3+
#
4+
15
# OCI Provider
26
variable "tenancy_ocid" {}
37
variable "compartment_ocid" {}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Copyright (c) 2023 Oracle and/or its affiliates. All rights reserved.
2+
# Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
3+
#
4+
5+
module "oke-quickstart" {
6+
source = "github.com/oracle-quickstart/terraform-oci-oke-quickstart?ref=0.8.15"
7+
8+
# Oracle Cloud Infrastructure Tenancy and Compartment OCID
9+
tenancy_ocid = var.tenancy_ocid
10+
compartment_ocid = var.compartment_ocid
11+
region = var.region
12+
13+
# Note: Just few arguments are showing here to simplify the basic example. All other arguments are using default values.
14+
# App Name to identify deployment. Used for naming resources.
15+
app_name = "Basic with Existent Network"
16+
17+
# Freeform Tags + Defined Tags. Tags are applied to all resources.
18+
tag_values = { "freeformTags" = { "Environment" = "Development", "DeploymentType" = "basic", "QuickstartExample" = "basic-with-existing-network" }, "definedTags" = {} }
19+
20+
# OKE Node Pool 1 arguments
21+
node_pool_cni_type_1 = "FLANNEL_OVERLAY" # Use "OCI_VCN_IP_NATIVE" for VCN Native PODs Network. If the node pool 1 uses the OCI_VCN_IP_NATIVE, the cluster will also be configured with same cni
22+
cluster_autoscaler_enabled = true
23+
node_pool_initial_num_worker_nodes_1 = 3 # Minimum number of nodes in the node pool
24+
node_pool_max_num_worker_nodes_1 = 10 # Maximum number of nodes in the node pool
25+
node_pool_instance_shape_1 = { "instanceShape" = "VM.Standard.E4.Flex", "ocpus" = 2, "memory" = 64 } # If not using a Flex shape, ocpus and memory are ignored
26+
27+
# VCN for OKE arguments
28+
create_new_vcn = false
29+
existent_vcn_ocid = "ocid1.vcn.oc1.iad.amaaaaaadoggtjaat6nl5pla7kw52nbxpu73erej3nbd4shjhjczn2tfeadq"
30+
existent_vcn_compartment_ocid = "" # Optional. Specify if want to create terraform to create the subnets and the VCN is in a different compartment than the OKE cluster
31+
32+
# Subnet for OKE arguments
33+
create_subnets = false
34+
existent_oke_k8s_endpoint_subnet_ocid = "ocid1.subnet.oc1.iad.aaaaaaaakwyp2rkytg3yepvx7qzytff7estok277lda7gjjso3k4wnz6dpoa"
35+
existent_oke_nodes_subnet_ocid = "ocid1.subnet.oc1.iad.aaaaaaaack6edaxj6vxdxvbgw4ae232to3ou7rpfmv6lyscpbzcetjkeifiq"
36+
existent_oke_load_balancer_subnet_ocid = "ocid1.subnet.oc1.iad.aaaaaaaao6j4ixl23bcp6367he7l5qytuvmm74hrmg4ajiqyfzxowrbrx3pa"
37+
existent_oke_vcn_native_pod_networking_subnet_ocid = ""
38+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Copyright (c) 2023 Oracle and/or its affiliates. All rights reserved.
2+
# Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
3+
#
4+
5+
# Deployment outputs
6+
output "deploy_id" {
7+
value = module.oke-quickstart.deploy_id
8+
}
9+
10+
# OKE Outputs
11+
output "comments" {
12+
value = module.oke-quickstart.comments
13+
}
14+
output "deployed_oke_kubernetes_version" {
15+
value = module.oke-quickstart.deployed_oke_kubernetes_version
16+
}
17+
output "deployed_to_region" {
18+
value = module.oke-quickstart.deployed_to_region
19+
}
20+
output "kubeconfig" {
21+
value = module.oke-quickstart.kubeconfig
22+
sensitive = true
23+
}
24+
output "kubeconfig_for_kubectl" {
25+
value = module.oke-quickstart.kubeconfig_for_kubectl
26+
description = "If using Terraform locally, this command set KUBECONFIG environment variable to run kubectl locally"
27+
}
28+
output "dev" {
29+
value = module.oke-quickstart.dev
30+
}
31+
### Important Security Notice ###
32+
# The private key generated by this resource will be stored unencrypted in your Terraform state file.
33+
# Use of this resource for production deployments is not recommended.
34+
# Instead, generate a private key file outside of Terraform and distribute it securely to the system where Terraform will be run.
35+
output "generated_private_key_pem" {
36+
value = module.oke-quickstart.generated_private_key_pem
37+
sensitive = true
38+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Copyright (c) 2023 Oracle and/or its affiliates. All rights reserved.
2+
# Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
3+
#
4+
5+
terraform {
6+
required_version = ">= 1.1"
7+
required_providers {
8+
oci = {
9+
source = "oracle/oci"
10+
version = "~> 4, < 5"
11+
# https://registry.terraform.io/providers/oracle/oci/
12+
}
13+
kubernetes = {
14+
source = "hashicorp/kubernetes"
15+
version = "~> 2"
16+
# https://registry.terraform.io/providers/hashicorp/kubernetes/
17+
}
18+
helm = {
19+
source = "hashicorp/helm"
20+
version = "~> 2"
21+
# https://registry.terraform.io/providers/hashicorp/helm/
22+
}
23+
tls = {
24+
source = "hashicorp/tls"
25+
version = "~> 4"
26+
# https://registry.terraform.io/providers/hashicorp/tls/
27+
}
28+
local = {
29+
source = "hashicorp/local"
30+
version = "~> 2"
31+
# https://registry.terraform.io/providers/hashicorp/local/
32+
}
33+
random = {
34+
source = "hashicorp/random"
35+
version = "~> 3"
36+
# https://registry.terraform.io/providers/hashicorp/random/
37+
}
38+
}
39+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Copyright (c) 2023 Oracle and/or its affiliates. All rights reserved.
2+
# Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
3+
#
4+
5+
# OCI authentication
6+
tenancy_ocid = "ocid1.tenancy....."
7+
fingerprint = "" # e.g.: "5f:53:..." or leave blank if using CloudShell
8+
user_ocid = "" # e.g.: "ocid1.user..." or leave blank if using CloudShell
9+
private_key_path = "" # e.g.: "/users/user/.oci/oci_api_key.pem" or leave blank if using CloudShell
10+
11+
# Deployment compartment
12+
compartment_ocid = "ocid1.compartment...."
13+
14+
# region
15+
region = "us-ashburn-1"
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# OCI Provider
2+
variable "tenancy_ocid" {}
3+
variable "compartment_ocid" {}
4+
variable "region" {}
5+
variable "user_ocid" {
6+
default = ""
7+
}
8+
variable "fingerprint" {
9+
default = ""
10+
}
11+
variable "private_key_path" {
12+
default = ""
13+
}

0 commit comments

Comments
 (0)