mirror of
https://github.com/vcscsvcscs/OCI-Kubernetes-cluster-with-traefik.git
synced 2025-08-13 22:39:06 +02:00
Add oke and nlb to managed cluster
This commit is contained in:
23
oci-managed/oke/cluster.tf
Normal file
23
oci-managed/oke/cluster.tf
Normal file
@@ -0,0 +1,23 @@
|
||||
resource "oci_containerengine_cluster" "k8s_cluster" {
|
||||
compartment_id = var.compartment_ocid
|
||||
kubernetes_version = var.kubernetes_version
|
||||
name = "${var.cluster_name}-${var.environment}-cluster"
|
||||
vcn_id = var.vcn_id
|
||||
|
||||
endpoint_config {
|
||||
is_public_ip_enabled = true
|
||||
subnet_id = var.vcn_public_subnet_id
|
||||
}
|
||||
|
||||
options {
|
||||
add_ons {
|
||||
is_kubernetes_dashboard_enabled = var.kubernetes_dashboard_enabled
|
||||
is_tiller_enabled = var.tiller_enabled
|
||||
}
|
||||
kubernetes_network_config {
|
||||
pods_cidr = "10.244.0.0/16"
|
||||
services_cidr = "10.96.0.0/16"
|
||||
}
|
||||
service_lb_subnet_ids = [var.vcn_public_subnet_id]
|
||||
}
|
||||
}
|
14
oci-managed/oke/data.tf
Normal file
14
oci-managed/oke/data.tf
Normal file
@@ -0,0 +1,14 @@
|
||||
data "oci_identity_availability_domains" "ads" {
|
||||
compartment_id = var.compartment_ocid
|
||||
}
|
||||
|
||||
data "oci_core_images" "latest_image" {
|
||||
compartment_id = var.compartment_ocid
|
||||
operating_system = "Oracle Linux"
|
||||
operating_system_version = "8.8"
|
||||
filter {
|
||||
name = "display_name"
|
||||
values = ["^.*aarch64-.*$"]
|
||||
regex = true
|
||||
}
|
||||
}
|
34
oci-managed/oke/node_pool.tf
Normal file
34
oci-managed/oke/node_pool.tf
Normal file
@@ -0,0 +1,34 @@
|
||||
resource "oci_containerengine_node_pool" "k8s_node_pool" {
|
||||
cluster_id = oci_containerengine_cluster.k8s_cluster.id
|
||||
compartment_id = var.compartment_ocid
|
||||
kubernetes_version = var.kubernetes_version
|
||||
name = "${var.cluster_name}-${var.environment}-arm-node-pool"
|
||||
node_config_details {
|
||||
dynamic "placement_configs" {
|
||||
for_each = var.node_availability_domains
|
||||
content {
|
||||
availability_domain = placement_configs.value
|
||||
subnet_id = var.vcn_private_subnet_id
|
||||
}
|
||||
}
|
||||
size = var.node_pool_size
|
||||
}
|
||||
node_shape = "VM.Standard.A1.Flex"
|
||||
|
||||
node_shape_config {
|
||||
memory_in_gbs = 12
|
||||
ocpus = 2
|
||||
}
|
||||
|
||||
node_source_details {
|
||||
image_id = data.oci_core_images.latest_image.images.0.id
|
||||
source_type = "image"
|
||||
}
|
||||
|
||||
initial_node_labels {
|
||||
key = "name"
|
||||
value = "${var.cluster_name}-${var.environment}-cluster"
|
||||
}
|
||||
|
||||
ssh_public_key = file(var.ssh_public_key)
|
||||
}
|
7
oci-managed/oke/output.tf
Normal file
7
oci-managed/oke/output.tf
Normal file
@@ -0,0 +1,7 @@
|
||||
output "cluster_ocid" {
|
||||
value = oci_containerengine_cluster.k8s_cluster.id
|
||||
}
|
||||
|
||||
output "public_endpoint" {
|
||||
value = one(oci_containerengine_cluster.k8s_cluster.endpoints)
|
||||
}
|
37
oci-managed/oke/variables.tf
Normal file
37
oci-managed/oke/variables.tf
Normal file
@@ -0,0 +1,37 @@
|
||||
variable "compartment_ocid" {}
|
||||
variable "cluster_name" {
|
||||
type = string
|
||||
}
|
||||
variable "environment" {
|
||||
default = "prod"
|
||||
}
|
||||
|
||||
variable "kubernetes_version" {
|
||||
default = "v1.28.2"
|
||||
}
|
||||
variable "ssh_public_key" {
|
||||
type = string
|
||||
}
|
||||
variable "node_availability_domains" {
|
||||
type = list(string)
|
||||
default = data.oci_identity_availability_domains.ads.availability_domains[*].name
|
||||
}
|
||||
variable "node_pool_size" {
|
||||
type = number
|
||||
default = 2
|
||||
}
|
||||
variable "kubernetes_dashboard_enabled" {
|
||||
default = false
|
||||
}
|
||||
variable "tiller_enabled" {
|
||||
default = false
|
||||
}
|
||||
|
||||
variable "vcn_id" {}
|
||||
variable "vcn_public_subnet_id" {
|
||||
type = string
|
||||
}
|
||||
variable "vcn_private_subnet_id" {
|
||||
type = string
|
||||
}
|
||||
|
Reference in New Issue
Block a user