Skip to content

Commit

Permalink
Merge pull request #43 from oracle-quickstart/nikhsin/revert-tagging
Browse files Browse the repository at this point in the history
Nikhsin/revert tagging
  • Loading branch information
nikhisin3001 authored Aug 29, 2024
2 parents c5242ab + e171ae8 commit d11f814
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 63 deletions.
5 changes: 4 additions & 1 deletion .terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

75 changes: 13 additions & 62 deletions infrastructure.tf
Original file line number Diff line number Diff line change
Expand Up @@ -227,11 +227,6 @@ locals {
pool_formatter_id = join("", ["$", "{launchCount}"])
}

data "oci_identity_availability_domain" "availability_domain" {
compartment_id = var.compartment_ocid
ad_number = "1"
}

data "oci_identity_availability_domains" "ads" {
compartment_id = var.compartment_ocid
}
Expand Down Expand Up @@ -265,21 +260,6 @@ resource "oci_identity_tag" "openshift_instance_role" {
provider = oci.home
}

resource "oci_identity_tag" "openshift_resource" {
description = "Openshift Resource"
is_cost_tracking = "true"
is_retired = "false"
name = "openshift-resource"
tag_namespace_id = oci_identity_tag_namespace.openshift_tags.id
provider = oci.home
}

locals {
common_defined_tags = {
"openshift-${var.cluster_name}.openshift-resource" = "openshift-resource"
}
}

data "oci_core_compute_global_image_capability_schemas" "image_capability_schemas" {
}

Expand All @@ -302,7 +282,6 @@ resource "oci_core_image" "openshift_image" {

source_image_type = "QCOW2"
}
defined_tags = local.common_defined_tags
}

resource "oci_core_shape_management" "imaging_control_plane_shape" {
Expand All @@ -325,7 +304,6 @@ resource "oci_core_compute_image_capability_schema" "openshift_image_capability_
compute_global_image_capability_schema_version_name = local.global_image_capability_schemas[0].current_version_name
image_id = oci_core_image.openshift_image[0].id
schema_data = local.image_schema_data
defined_tags = local.common_defined_tags
}

##Define network
Expand All @@ -336,21 +314,18 @@ resource "oci_core_vcn" "openshift_vcn" {
compartment_id = var.compartment_ocid
display_name = var.cluster_name
dns_label = var.vcn_dns_label
defined_tags = local.common_defined_tags
}

resource "oci_core_internet_gateway" "internet_gateway" {
compartment_id = var.compartment_ocid
display_name = "InternetGateway"
vcn_id = oci_core_vcn.openshift_vcn.id
defined_tags = local.common_defined_tags
}

resource "oci_core_nat_gateway" "nat_gateway" {
compartment_id = var.compartment_ocid
vcn_id = oci_core_vcn.openshift_vcn.id
display_name = "NatGateway"
defined_tags = local.common_defined_tags
}

data "oci_core_services" "oci_services" {
Expand All @@ -372,7 +347,6 @@ resource "oci_core_service_gateway" "service_gateway" {
vcn_id = oci_core_vcn.openshift_vcn.id

display_name = "ServiceGateway"
defined_tags = local.common_defined_tags
}

resource "oci_core_route_table" "public_routes" {
Expand All @@ -385,7 +359,6 @@ resource "oci_core_route_table" "public_routes" {
destination_type = "CIDR_BLOCK"
network_entity_id = oci_core_internet_gateway.internet_gateway.id
}
defined_tags = local.common_defined_tags
}

resource "oci_core_route_table" "private_routes" {
Expand All @@ -403,7 +376,6 @@ resource "oci_core_route_table" "private_routes" {
destination_type = "SERVICE_CIDR_BLOCK"
network_entity_id = oci_core_service_gateway.service_gateway.id
}
defined_tags = local.common_defined_tags
}

resource "oci_core_security_list" "private" {
Expand All @@ -419,7 +391,6 @@ resource "oci_core_security_list" "private" {
destination = local.anywhere
protocol = local.all_protocols
}
defined_tags = local.common_defined_tags
}

resource "oci_core_security_list" "public" {
Expand All @@ -443,7 +414,6 @@ resource "oci_core_security_list" "public" {
destination = local.anywhere
protocol = local.all_protocols
}
defined_tags = local.common_defined_tags
}

resource "oci_core_subnet" "private" {
Expand All @@ -459,7 +429,6 @@ resource "oci_core_subnet" "private" {

dns_label = "private"
prohibit_public_ip_on_vnic = true
defined_tags = local.common_defined_tags
}

resource "oci_core_subnet" "public" {
Expand All @@ -475,14 +444,12 @@ resource "oci_core_subnet" "public" {

dns_label = "public"
prohibit_public_ip_on_vnic = false
defined_tags = local.common_defined_tags
}

resource "oci_core_network_security_group" "cluster_lb_nsg" {
compartment_id = var.compartment_ocid
vcn_id = oci_core_vcn.openshift_vcn.id
display_name = "cluster-lb-nsg"
defined_tags = local.common_defined_tags
}

resource "oci_core_network_security_group_security_rule" "cluster_lb_nsg_rule_1" {
Expand Down Expand Up @@ -542,7 +509,6 @@ resource "oci_core_network_security_group" "cluster_controlplane_nsg" {
compartment_id = var.compartment_ocid
vcn_id = oci_core_vcn.openshift_vcn.id
display_name = "cluster-controlplane-nsg"
defined_tags = local.common_defined_tags
}

resource "oci_core_network_security_group_security_rule" "cluster_controlplane_nsg_rule_1" {
Expand All @@ -563,7 +529,6 @@ resource "oci_core_network_security_group" "cluster_compute_nsg" {
compartment_id = var.compartment_ocid
vcn_id = oci_core_vcn.openshift_vcn.id
display_name = "cluster-compute-nsg"
defined_tags = local.common_defined_tags
}

resource "oci_core_network_security_group_security_rule" "cluster_compute_nsg_rule_1" {
Expand Down Expand Up @@ -592,7 +557,6 @@ resource "oci_load_balancer_load_balancer" "openshift_api_int_lb" {
maximum_bandwidth_in_mbps = var.load_balancer_shape_details_maximum_bandwidth_in_mbps
minimum_bandwidth_in_mbps = var.load_balancer_shape_details_minimum_bandwidth_in_mbps
}
defined_tags = local.common_defined_tags
}

resource "oci_load_balancer_load_balancer" "openshift_api_apps_lb" {
Expand All @@ -607,7 +571,6 @@ resource "oci_load_balancer_load_balancer" "openshift_api_apps_lb" {
maximum_bandwidth_in_mbps = var.load_balancer_shape_details_maximum_bandwidth_in_mbps
minimum_bandwidth_in_mbps = var.load_balancer_shape_details_minimum_bandwidth_in_mbps
}
defined_tags = local.common_defined_tags
}

resource "oci_load_balancer_backend_set" "openshift_cluster_api_backend_external" {
Expand Down Expand Up @@ -750,7 +713,7 @@ resource "oci_identity_dynamic_group" "openshift_control_plane_nodes" {
matching_rule = "all {instance.compartment.id='${var.compartment_ocid}', tag.openshift-${var.cluster_name}.instance-role.value='control_plane'}"
name = "${var.cluster_name}_control_plane_nodes"
provider = oci.home
defined_tags = local.common_defined_tags

}

resource "oci_identity_policy" "openshift_control_plane_nodes" {
Expand All @@ -764,8 +727,7 @@ resource "oci_identity_policy" "openshift_control_plane_nodes" {
"Allow dynamic-group ${oci_identity_dynamic_group.openshift_control_plane_nodes.name} to use virtual-network-family in compartment id ${var.compartment_ocid}",
"Allow dynamic-group ${oci_identity_dynamic_group.openshift_control_plane_nodes.name} to manage load-balancers in compartment id ${var.compartment_ocid}",
]
provider = oci.home
defined_tags = local.common_defined_tags
provider = oci.home
}

resource "oci_identity_dynamic_group" "openshift_compute_nodes" {
Expand All @@ -774,7 +736,6 @@ resource "oci_identity_dynamic_group" "openshift_compute_nodes" {
matching_rule = "all {instance.compartment.id='${var.compartment_ocid}', tag.openshift-${var.cluster_name}.instance-role.value='compute'}"
name = "${var.cluster_name}_compute_nodes"
provider = oci.home
defined_tags = local.common_defined_tags
}

resource "oci_dns_zone" "openshift" {
Expand All @@ -784,7 +745,6 @@ resource "oci_dns_zone" "openshift" {
view_id = var.enable_private_dns ? data.oci_dns_resolver.dns_resolver.default_view_id : null
zone_type = "PRIMARY"
depends_on = [oci_core_subnet.private]
defined_tags = local.common_defined_tags
}

resource "oci_dns_rrset" "openshift_api" {
Expand Down Expand Up @@ -854,12 +814,9 @@ resource "oci_core_instance_configuration" "control_plane_node_config" {
]
subnet_id = oci_core_subnet.private.id
}
defined_tags = merge(
local.common_defined_tags,
{
"openshift-${var.cluster_name}.instance-role" = "control_plane"
}
)
defined_tags = {
"openshift-${var.cluster_name}.instance-role" = "control_plane"
}
shape = var.control_plane_shape
shape_config {
memory_in_gbs = var.control_plane_memory
Expand All @@ -882,7 +839,6 @@ resource "oci_core_instance_pool" "control_plane_nodes" {
instance_configuration_id = oci_core_instance_configuration.control_plane_node_config[0].id
instance_display_name_formatter = "${var.cluster_name}-control-plane-${local.pool_formatter_id}"
instance_hostname_formatter = "${var.cluster_name}-control-plane-${local.pool_formatter_id}"
defined_tags = local.common_defined_tags

load_balancers {
backend_set_name = oci_load_balancer_backend_set.openshift_cluster_api_backend_external.name
Expand Down Expand Up @@ -920,13 +876,13 @@ resource "oci_core_instance_pool" "control_plane_nodes" {
port = "22624"
vnic_selection = "PrimaryVnic"
}
dynamic placement_configurations {
dynamic "placement_configurations" {
for_each = local.availability_domains
content {
availability_domain = placement_configurations.value.name
primary_subnet_id = oci_core_subnet.private.id
primary_subnet_id = oci_core_subnet.private.id
}

}
size = var.control_plane_count
}
Expand All @@ -938,7 +894,6 @@ resource "oci_core_instance_configuration" "compute_node_config" {
instance_details {
instance_type = "compute"
launch_details {
# availability_domain = data.oci_identity_availability_domain.availability_domain.name
compartment_id = var.compartment_ocid
create_vnic_details {
assign_private_dns_record = "true"
Expand All @@ -948,12 +903,9 @@ resource "oci_core_instance_configuration" "compute_node_config" {
]
subnet_id = oci_core_subnet.private.id
}
defined_tags = merge(
local.common_defined_tags,
{
"openshift-${var.cluster_name}.instance-role" = "compute"
}
)
defined_tags = {
"openshift-${var.cluster_name}.instance-role" = "compute"
}
shape = var.compute_shape
shape_config {
memory_in_gbs = var.compute_memory
Expand All @@ -976,7 +928,6 @@ resource "oci_core_instance_pool" "compute_nodes" {
instance_configuration_id = oci_core_instance_configuration.compute_node_config[0].id
instance_display_name_formatter = "${var.cluster_name}-compute-${local.pool_formatter_id}"
instance_hostname_formatter = "${var.cluster_name}-compute-${local.pool_formatter_id}"
defined_tags = local.common_defined_tags
load_balancers {
backend_set_name = oci_load_balancer_backend_set.openshift_cluster_ingress_https_backend.name
load_balancer_id = oci_load_balancer_load_balancer.openshift_api_apps_lb.id
Expand All @@ -989,11 +940,11 @@ resource "oci_core_instance_pool" "compute_nodes" {
port = "80"
vnic_selection = "PrimaryVnic"
}
dynamic placement_configurations {
dynamic "placement_configurations" {
for_each = local.availability_domains
content {
availability_domain = placement_configurations.value.name
primary_subnet_id = oci_core_subnet.private.id
primary_subnet_id = oci_core_subnet.private.id
}
}
size = var.compute_count
Expand Down

0 comments on commit d11f814

Please sign in to comment.