|
1 |
| -module "oke-quickstart" { |
2 |
| - source = "github.com/oracle-quickstart/terraform-oci-oke-quickstart?ref=0.9.2" |
3 |
| - |
| 1 | +locals { |
| 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 | +} |
4 | 8 |
|
5 |
| - providers = { |
6 |
| - oci = oci |
7 |
| - oci.home_region = oci.home_region |
| 9 | +module "oke" { |
| 10 | + source = "oracle-terraform-modules/oke/oci" |
| 11 | + version = "5.1.3" |
| 12 | + region = var.region |
| 13 | + compartment_id = var.compartment_ocid |
| 14 | + # IAM - Policies |
| 15 | + create_iam_autoscaler_policy = "never" |
| 16 | + create_iam_kms_policy = "never" |
| 17 | + create_iam_operator_policy = "never" |
| 18 | + create_iam_worker_policy = "never" |
| 19 | + # Network module - VCN |
| 20 | + subnets = { |
| 21 | + bastion = { |
| 22 | + create = "never" |
| 23 | + } |
| 24 | + operator = { |
| 25 | + create = "never" |
| 26 | + } |
| 27 | + cp = { |
| 28 | + create = "always", |
| 29 | + cidr = local.cp_subnet_cidr |
| 30 | + } |
| 31 | + pub_lb = { |
| 32 | + create = "always", |
| 33 | + cidr = local.lb_subnet_cidr |
| 34 | + } |
| 35 | + workers = { |
| 36 | + create = "always", |
| 37 | + cidr = local.workers_subnet_cidr |
| 38 | + } |
| 39 | + int_lb = { |
| 40 | + create = "never" |
| 41 | + } |
| 42 | + pods = { |
| 43 | + create = "never" |
| 44 | + } |
| 45 | + } |
| 46 | + nsgs = { |
| 47 | + bastion = {create = "never"} |
| 48 | + operator = { create = "never" } |
| 49 | + cp = { create = "always"} |
| 50 | + int_lb = { create = "never" } |
| 51 | + pub_lb = { create = "never" } |
| 52 | + workers = { create = "always"} |
| 53 | + pods = { create = "never" } |
| 54 | + } |
| 55 | + assign_dns = true |
| 56 | + create_vcn = true |
| 57 | + vcn_cidrs = [local.vcn_cidr] |
| 58 | + vcn_dns_label = "oke" |
| 59 | + vcn_name = "oke-${random_string.deploy_id.result}-vcn" |
| 60 | + lockdown_default_seclist = true |
| 61 | + allow_rules_public_lb ={ |
| 62 | + "Allow TCP ingress to public load balancers for HTTPS traffic from anywhere" : { protocol = 6, port = 443, source="0.0.0.0/0", source_type="CIDR_BLOCK"}, |
| 63 | + "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"} |
| 64 | + } |
| 65 | + # Network module - security |
| 66 | + allow_node_port_access = true |
| 67 | + allow_worker_internet_access = true |
| 68 | + allow_worker_ssh_access = true |
| 69 | + control_plane_allowed_cidrs = ["0.0.0.0/0"] |
| 70 | + control_plane_is_public = true |
| 71 | + assign_public_ip_to_control_plane = true |
| 72 | + enable_waf = false |
| 73 | + load_balancers = "public" |
| 74 | + preferred_load_balancer = "public" |
| 75 | + worker_is_public = false |
| 76 | + # Cluster module |
| 77 | + create_cluster = true |
| 78 | + cluster_name = "oke-${random_string.deploy_id.result}" |
| 79 | + cluster_type = "basic" |
| 80 | + cni_type = "flannel" |
| 81 | + kubernetes_version = local.cluster_k8s_latest_version |
| 82 | + pods_cidr = "10.244.0.0/16" |
| 83 | + services_cidr = "10.96.0.0/16" |
| 84 | + use_signed_images = false |
| 85 | + use_defined_tags = false |
| 86 | + # Workers |
| 87 | + worker_pool_mode = "node-pool" |
| 88 | + worker_pool_size = 2 |
| 89 | + worker_image_type = "oke" |
| 90 | + worker_pools = { |
| 91 | + np1 = { |
| 92 | + shape = "VM.Standard.E3.Flex", |
| 93 | + ocpus = 1, |
| 94 | + memory = 32, |
| 95 | + boot_volume_size = 120, |
| 96 | + create = true |
| 97 | + } |
8 | 98 | }
|
9 | 99 |
|
10 |
| - tenancy_ocid = var.tenancy_ocid |
11 |
| - compartment_ocid = var.compartment_ocid |
12 |
| - region = var.region |
| 100 | + # Bastion |
| 101 | + create_bastion = false |
13 | 102 |
|
14 |
| - app_name = "DevOps ${random_string.deploy_id.result}" |
| 103 | + # Operator |
| 104 | + create_operator = false |
15 | 105 |
|
16 |
| - metrics_server_enabled = false |
| 106 | + providers = { |
| 107 | + oci = oci |
| 108 | + oci.home = oci.home_region |
| 109 | + } |
| 110 | +} |
17 | 111 |
|
18 |
| - # OKE Node Pool 1 |
19 |
| - node_pool_cni_type_1 = "FLANNEL_OVERLAY" |
20 |
| - node_pool_autoscaler_enabled_1 = false |
21 |
| - node_pool_initial_num_worker_nodes_1 = 2 |
22 |
| - node_pool_max_num_worker_nodes_1 = 3 |
23 |
| - node_pool_instance_shape_1 = { "instanceShape" = "VM.Standard.E4.Flex", "ocpus" = 1, "memory" = 32 } |
24 |
| - node_pool_boot_volume_size_in_gbs_1 = 120 |
| 112 | +resource "null_resource" "add_sec_rules_lb" { |
25 | 113 |
|
26 |
| - # VCN for OKE arguments |
27 |
| - vcn_cidr_blocks = "10.22.0.0/16" |
| 114 | + provisioner "local-exec" { |
| 115 | + command = "chmod +x ./pub_lb_sec.sh && ./pub_lb_sec.sh" |
| 116 | + environment = { |
| 117 | + PUB_LB_SUBNET_ID = module.oke.pub_lb_subnet_id |
| 118 | + } |
| 119 | + working_dir = path.module |
| 120 | + } |
| 121 | + |
| 122 | + depends_on = [module.oke] |
28 | 123 | }
|
| 124 | + |
0 commit comments