this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Use autoscaling pool for cluster

+170 -124
+5
Makefile
··· 1 + .POSIX: 2 + 3 + .PHONY: infra 4 + infra: 5 + make -C infra
+1 -1
infra/Makefile
··· 1 - default: init apply 1 + default: init plan 2 2 3 3 init: 4 4 terraform init
+16 -3
infra/main.tf
··· 1 + # TODO The private key generated by this resource will be stored unencrypted in your Terraform state file. 2 + # Generate a private key file outside of Terraform and distribute it securely to the system where Terraform will be run instead. 3 + resource "tls_private_key" "ssh" { 4 + algorithm = "ECDSA" 5 + ecdsa_curve = "P256" 6 + } 7 + 8 + module "network" { 9 + source = "./modules/network" 10 + } 11 + 1 12 module "k3s_cluster" { 2 - source = "./modules/k3s-cluster" 3 - server_count = 1 4 - agent_count = 3 13 + source = "./modules/k3s-cluster" 14 + server_count = 1 15 + agent_count = 3 16 + ssh_public_key = tls_private_key.ssh.public_key_openssh 17 + subnet_id = module.network.subnet_id 5 18 }
+27 -6
infra/modules/k3s-cluster/main.tf
··· 1 - module "server_pool" { 2 - source = "../k3s-node-pool" 3 - node_count = var.server_count 1 + # module "server_pool" { 2 + # count = var.server_count 3 + # source = "../virtual-machine" 4 + # subnet_id = var.subnet_id 5 + # ssh_public_key = var.ssh_public_key 6 + # } 7 + 8 + # module "agent_pool" { 9 + # count = var.agent_count 10 + # source = "../virtual-machine" 11 + # subnet_id = var.subnet_id 12 + # ssh_public_key = var.ssh_public_key 13 + # } 14 + 15 + resource "oci_core_instance_configuration" "test_instance_configuration" { 16 + compartment_id = var.compartment_id 4 17 } 5 18 6 - module "agent_pool" { 7 - source = "../k3s-node-pool" 8 - node_count = var.agent_count 19 + resource "oci_core_instance_pool" "agent_pool" { 20 + #Required 21 + compartment_id = var.compartment_id 22 + instance_configuration_id = oci_core_instance_configuration.test_instance_configuration.id 23 + placement_configurations { 24 + #Required 25 + availability_domain = "gHLA:US-SANJOSE-1-AD-1" 26 + primary_subnet_id = var.subnet_id 27 + 28 + } 29 + size = var.agent_count 9 30 }
+13 -1
infra/modules/k3s-cluster/variables.tf
··· 3 3 } 4 4 5 5 variable "agent_count" { 6 - description = "Number of agent nodes" 6 + description = "Number of agent (worker) nodes" 7 + } 8 + 9 + variable "subnet_id" { 7 10 } 11 + 12 + variable "ssh_public_key" { 13 + description = "SSH public key to add to all nodes" 14 + } 15 + 16 + variable "compartment_id" { 17 + default = "ocid1.compartment.oc1..aaaaaaaasvkl7yw6gj2pytybimo6ax7fg2jq7m4t5aueig3xrnfxwo7xwulq" 18 + } 19 +
-4
infra/modules/k3s-node-pool/main.tf
··· 1 - module "virtual_machine" { 2 - count = var.node_count 3 - source = "../virtual-machine" 4 - }
-3
infra/modules/k3s-node-pool/variables.tf
··· 1 - variable "node_count" { 2 - description = "Number of node in the pool" 3 - }
+86
infra/modules/network/main.tf
··· 1 + resource "oci_core_vcn" "vcn" { 2 + cidr_blocks = var.vcn_cidr_blocks 3 + compartment_id = var.compartment_id 4 + } 5 + 6 + resource "oci_core_security_list" "security_list" { 7 + compartment_id = var.compartment_id 8 + vcn_id = oci_core_vcn.vcn.id 9 + 10 + ingress_security_rules { 11 + description = "Wireguard" 12 + protocol = "17" # UDP 13 + source = "0.0.0.0/0" 14 + stateless = false 15 + 16 + udp_options { 17 + source_port_range { 18 + min = 1 19 + max = 65535 20 + } 21 + 22 + min = 51820 23 + max = 51820 24 + } 25 + } 26 + 27 + ingress_security_rules { 28 + description = "HTTP" 29 + protocol = "6" # TCP 30 + source = "0.0.0.0/0" 31 + stateless = false 32 + 33 + tcp_options { 34 + source_port_range { 35 + min = 1 36 + max = 65535 37 + } 38 + 39 + min = 80 40 + max = 80 41 + } 42 + } 43 + 44 + ingress_security_rules { 45 + description = "HTTPS" 46 + protocol = "6" # TCP 47 + source = "0.0.0.0/0" 48 + stateless = false 49 + 50 + tcp_options { 51 + source_port_range { 52 + min = 1 53 + max = 65535 54 + } 55 + 56 + min = 443 57 + max = 443 58 + } 59 + } 60 + } 61 + 62 + resource "oci_core_subnet" "subnet" { 63 + cidr_block = var.subnet_cidr_block 64 + compartment_id = var.compartment_id 65 + route_table_id = oci_core_vcn.vcn.default_route_table_id 66 + vcn_id = oci_core_vcn.vcn.id 67 + 68 + security_list_ids = [ 69 + oci_core_vcn.vcn.default_security_list_id, 70 + oci_core_security_list.security_list.id 71 + ] 72 + } 73 + 74 + resource "oci_core_internet_gateway" "internet_gateway" { 75 + compartment_id = var.compartment_id 76 + vcn_id = oci_core_vcn.vcn.id 77 + } 78 + 79 + resource "oci_core_default_route_table" "default_route_table" { 80 + route_rules { 81 + destination = "0.0.0.0/0" 82 + destination_type = "CIDR_BLOCK" 83 + network_entity_id = oci_core_internet_gateway.internet_gateway.id 84 + } 85 + manage_default_resource_id = oci_core_vcn.vcn.default_route_table_id 86 + }
+3
infra/modules/network/outputs.tf
··· 1 + output "subnet_id" { 2 + value = oci_core_subnet.subnet.id 3 + }
+13
infra/modules/network/variables.tf
··· 1 + variable "compartment_id" { 2 + default = "ocid1.compartment.oc1..aaaaaaaasvkl7yw6gj2pytybimo6ax7fg2jq7m4t5aueig3xrnfxwo7xwulq" 3 + } 4 + 5 + variable "vcn_cidr_blocks" { 6 + default = [ 7 + "10.0.0.0/16" 8 + ] 9 + } 10 + 11 + variable "subnet_cidr_block" { 12 + default = "10.0.0.0/24" 13 + }
infra/modules/virtual-cloud-network/main.tf

This is a binary file and will not be displayed.

+2 -100
infra/modules/virtual-machine/main.tf
··· 1 - resource "tls_private_key" "ssh" { 2 - algorithm = "ECDSA" 3 - ecdsa_curve = "P256" 4 - } 5 - 6 - resource "local_file" "ssh_private_key" { 7 - content = tls_private_key.ssh.private_key_pem 8 - filename = "${path.module}/private.pem" 9 - file_permission = "0600" 10 - } 11 - 12 1 resource "oci_core_instance" "instance" { 13 2 availability_domain = "gHLA:US-SANJOSE-1-AD-1" # TODO 14 3 compartment_id = var.compartment_id ··· 20 9 21 10 create_vnic_details { 22 11 assign_public_ip = "true" 23 - subnet_id = oci_core_subnet.subnet.id 12 + subnet_id = var.subnet_id 24 13 } 25 14 26 15 source_details { ··· 29 18 } 30 19 31 20 metadata = { 32 - ssh_authorized_keys = tls_private_key.ssh.public_key_openssh 21 + ssh_authorized_keys = var.ssh_public_key 33 22 user_data = filebase64("${path.module}/cloud-init.yaml") 34 23 } 35 24 } 36 - 37 - resource "oci_core_vcn" "vcn" { 38 - cidr_block = var.vcn_cidr_blocks[0] # TODO deprecated, use cidr_blocks instead 39 - compartment_id = var.compartment_id 40 - } 41 - 42 - resource "oci_core_security_list" "security_list" { 43 - compartment_id = var.compartment_id 44 - vcn_id = oci_core_vcn.vcn.id 45 - 46 - ingress_security_rules { 47 - description = "Wireguard" 48 - protocol = "17" # UDP 49 - source = "0.0.0.0/0" 50 - stateless = false 51 - 52 - udp_options { 53 - source_port_range { 54 - min = 1 55 - max = 65535 56 - } 57 - 58 - min = 51820 59 - max = 51820 60 - } 61 - } 62 - 63 - ingress_security_rules { 64 - description = "HTTP" 65 - protocol = "6" # TCP 66 - source = "0.0.0.0/0" 67 - stateless = false 68 - 69 - tcp_options { 70 - source_port_range { 71 - min = 1 72 - max = 65535 73 - } 74 - 75 - min = 80 76 - max = 80 77 - } 78 - } 79 - 80 - ingress_security_rules { 81 - description = "HTTPS" 82 - protocol = "6" # TCP 83 - source = "0.0.0.0/0" 84 - stateless = false 85 - 86 - tcp_options { 87 - source_port_range { 88 - min = 1 89 - max = 65535 90 - } 91 - 92 - min = 443 93 - max = 443 94 - } 95 - } 96 - } 97 - 98 - resource "oci_core_subnet" "subnet" { 99 - cidr_block = var.subnet_cidr_block 100 - compartment_id = var.compartment_id 101 - route_table_id = oci_core_vcn.vcn.default_route_table_id 102 - vcn_id = oci_core_vcn.vcn.id 103 - 104 - security_list_ids = [ 105 - oci_core_vcn.vcn.default_security_list_id, 106 - oci_core_security_list.security_list.id 107 - ] 108 - } 109 - 110 - resource "oci_core_internet_gateway" "internet_gateway" { 111 - compartment_id = var.compartment_id 112 - vcn_id = oci_core_vcn.vcn.id 113 - } 114 - 115 - resource "oci_core_default_route_table" "default_route_table" { 116 - route_rules { 117 - destination = "0.0.0.0/0" 118 - destination_type = "CIDR_BLOCK" 119 - network_entity_id = oci_core_internet_gateway.internet_gateway.id 120 - } 121 - manage_default_resource_id = oci_core_vcn.vcn.default_route_table_id 122 - }
+4 -6
infra/modules/virtual-machine/variables.tf
··· 10 10 default = "ocid1.image.oc1.us-sanjose-1.aaaaaaaan4g4q527bljtyczck6xrsutbzps6h7mut2xcfhnbzw66sbbsvwoq" 11 11 } 12 12 13 - variable "vcn_cidr_blocks" { 14 - default = [ 15 - "10.0.0.0/16" 16 - ] 13 + variable "subnet_id" { 14 + description = "ID of the subnet for the virtual machine" 17 15 } 18 16 19 - variable "subnet_cidr_block" { 20 - default = "10.0.0.0/24" 17 + variable "ssh_public_key" { 18 + description = "SSH public key to add to all nodes" 21 19 }