-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
114f0ce
commit 0ca08d2
Showing
15 changed files
with
231 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
data "oci_containerengine_cluster_kube_config" "cluster_kube_config" { | ||
#Required | ||
cluster_id = var.cluster_ocid | ||
|
||
#Optional | ||
endpoint = var.cluster_public_endpoint | ||
token_version = "2.0.0" | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
provider "helm" { | ||
kubernetes { | ||
config_path = "~/.kube/config" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
resource "helm_release" "traefik" { | ||
namespace = "traefik-loadbalancer" | ||
create_namespace = true | ||
name = "traefik" | ||
repository = "https://traefik.github.io/charts" | ||
chart = "traefik" | ||
version = var.traefik_chart_version | ||
|
||
# Helm chart deployment can sometimes take longer than the default 5 minutes | ||
timeout = var.timeout_seconds | ||
|
||
# If values file specified by the var.values_file input variable exists then apply the values from this file | ||
# else apply the default values from the chart | ||
values = [fileexists("${path.root}/${var.values_file}") == true ? file("${path.root}/${var.values_file}") : ""] | ||
|
||
set { | ||
name = "deployment.replicas" | ||
value = var.replica_count | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
variable "compartment_ocid" {} | ||
variable "environment" { | ||
default = "prod" | ||
} | ||
variable "cluster_ocid" { | ||
type = string | ||
} | ||
variable "cluster_public_endpoint" { | ||
type = string | ||
} | ||
|
||
variable "namespace" { | ||
description = "Namespace to install traefik chart into" | ||
type = string | ||
default = "traefik" | ||
} | ||
|
||
variable "traefik_chart_version" { | ||
description = "Version of Traefik chart to install" | ||
type = string | ||
default = "21.1.0" # See https://artifacthub.io/packages/helm/traefik/traefik for latest version(s) | ||
} | ||
|
||
# Helm chart deployment can sometimes take longer than the default 5 minutes | ||
variable "timeout_seconds" { | ||
type = number | ||
description = "Helm chart deployment can sometimes take longer than the default 5 minutes. Set a custom timeout here." | ||
default = 800 # 10 minutes | ||
} | ||
|
||
variable "replica_count" { | ||
description = "Number of replica pods to create" | ||
type = number | ||
default = 1 | ||
} | ||
|
||
variable "values_file" { | ||
description = "The name of the traefik helmchart values file to use" | ||
type = string | ||
default = "values.yaml" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
output "public_subnet_id" { | ||
value = oci_core_subnet.vcn_public_subnet.id | ||
} | ||
|
||
output "private_subnet_id" { | ||
value = oci_core_subnet.vcn_private_subnet.id | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters