Skip to content

Commit ca9d512

Browse files
authored
Merge pull request #23 from alcampag/oke-module-update
Oke module update
2 parents ec71891 + 1797d77 commit ca9d512

File tree

5 files changed

+143
-22
lines changed

5 files changed

+143
-22
lines changed

deploy/devops/tf-env/data.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,7 @@ data "oci_identity_compartment" "compartment" {
2020
data "oci_identity_users" "users" {
2121
compartment_id = var.tenancy_ocid
2222
}
23+
24+
data "oci_containerengine_cluster_option" "oke" {
25+
cluster_option_id = "all"
26+
}

deploy/devops/tf-env/oke.tf

Lines changed: 116 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,124 @@
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+
}
48

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+
}
898
}
999

10-
tenancy_ocid = var.tenancy_ocid
11-
compartment_ocid = var.compartment_ocid
12-
region = var.region
100+
# Bastion
101+
create_bastion = false
13102

14-
app_name = "DevOps ${random_string.deploy_id.result}"
103+
# Operator
104+
create_operator = false
15105

16-
metrics_server_enabled = false
106+
providers = {
107+
oci = oci
108+
oci.home = oci.home_region
109+
}
110+
}
17111

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" {
25113

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]
28123
}
124+

deploy/devops/tf-env/output.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ output "devops_ons_topic_ocid" {
33
}
44

55
output "kubeconfig" {
6-
value = module.oke-quickstart.kubeconfig
6+
value = module.oke.cluster_kubeconfig
77
sensitive = true
88
}
99

1010
output "oke_cluster_ocid" {
11-
value = module.oke-quickstart.oke_cluster_ocid
11+
value = module.oke.cluster_id
1212
}
1313

1414
output "github_access_token_secret_ocid" {

deploy/devops/tf-env/provider.tf

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# TODO: To be modified before pushing to main
2+
3+
14
provider "oci" {
25
tenancy_ocid = var.tenancy_ocid
36
region = var.region
@@ -8,3 +11,15 @@ provider "oci" {
811
tenancy_ocid = var.tenancy_ocid
912
region = lookup(data.oci_identity_regions.home_region.regions[0], "name")
1013
}
14+
15+
16+
/*provider "oci" {
17+
config_file_profile = var.config_file_profile
18+
region = var.region
19+
}
20+
21+
provider "oci" {
22+
alias = "home_region"
23+
config_file_profile = var.config_file_profile
24+
region = lookup(data.oci_identity_regions.home_region.regions[0], "name")
25+
}*/

deploy/devops/tf-env/pub_lb_sec.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
3+
# shellcheck disable=SC2155
4+
export SEC_LIST_ID=$(oci network subnet get --subnet-id $PUB_LB_SUBNET_ID --query 'data."security-list-ids"[0]' --raw-output)
5+
6+
oci network security-list update --security-list-id $SEC_LIST_ID --egress-security-rules '[{"destination": "10.22.144.0/20", "protocol": "6", "isStateless": false, "tcpOptions": {"destinationPortRange": {"max": 10256, "min": 10256}}}]' --force

0 commit comments

Comments
 (0)