Skip to content

Commit

Permalink
zero-zero-four
Browse files Browse the repository at this point in the history
Signed-off-by: junior <[email protected]>
  • Loading branch information
junior committed May 23, 2023
1 parent 3757d0c commit 45d8460
Show file tree
Hide file tree
Showing 5 changed files with 151 additions and 68 deletions.
2 changes: 1 addition & 1 deletion deploy/terraform/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.0.3
0.0.4
69 changes: 41 additions & 28 deletions deploy/terraform/oke.tf
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
# Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2022,2023, Oracle and/or its affiliates. All rights reserved.
# Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
#
#

################################################################################
# OKE Cluster
################################################################################
module "oke-quickstart" {
source = "github.com/oracle-quickstart/terraform-oci-oke-quickstart?ref=0.8.8"
source = "github.com/oracle-quickstart/terraform-oci-oke-quickstart?ref=0.9.2"

providers = {
oci = oci
oci.home_region = oci.home_region
}

# Oracle Cloud Infrastructure Tenancy and Compartment OCID
tenancy_ocid = var.tenancy_ocid
Expand All @@ -15,7 +20,8 @@ module "oke-quickstart" {

# Note: Just few arguments are showing here to simplify the basic example. All other arguments are using default values.
# App Name to identify deployment. Used for naming resources.
app_name = "Unreal Pixel Streaming"
app_name = "Unreal Pixel Streaming"
k8s_version = var.k8s_version

# Freeform Tags + Defined Tags. Tags are applied to all resources.
tag_values = { "freeformTags" = { "Environment" = "Development", "DeploymentType" = "full", "Quickstart" = "terraform-oke-unreal-pixel-streaming" }, "definedTags" = {} }
Expand All @@ -28,11 +34,12 @@ module "oke-quickstart" {

# OKE Node Pool 1 arguments
node_pool_cni_type_1 = "FLANNEL_OVERLAY" # Use "OCI_VCN_IP_NATIVE" for VCN Native PODs Network. If the node pool 1 uses the OCI_VCN_IP_NATIVE, the cluster will also be configured with same cni
cluster_autoscaler_enabled = false
node_pool_autoscaler_enabled_1 = true
node_pool_name_1 = "Default"
node_pool_initial_num_worker_nodes_1 = 3 # Minimum number of nodes in the node pool
node_pool_max_num_worker_nodes_1 = 10 # Maximum number of nodes in the node pool
node_pool_initial_num_worker_nodes_1 = 3 # Minimum number of nodes in the node pool 1 (Default)
node_pool_max_num_worker_nodes_1 = 10 # Maximum number of nodes in the node pool 1 (Default)
node_pool_instance_shape_1 = var.node_pool_instance_shape_1
node_pool_boot_volume_size_in_gbs_1 = 120
extra_node_pools = local.extra_node_pools
extra_security_list_name_for_nodes = "turn_for_nodes_security_list"

Expand All @@ -44,36 +51,42 @@ module "oke-quickstart" {
# Extra Node Pools for TURN and GPU node pools
locals {
extra_node_pools = [{
node_pool_name = "Turn"
node_pool_min_nodes = 1
node_pool_max_nodes = 1
node_k8s_version = "Latest"
node_pool_shape = var.node_pool_instance_shape_turn.instanceShape
node_pool_shape_specific_ad = 0
node_pool_name = "Turn"
node_pool_min_nodes = 1
node_pool_max_nodes = 1
node_k8s_version = var.k8s_version
node_pool_shape = var.node_pool_instance_shape_turn.instanceShape
# node_pool_shape_specific_ad = 0
node_pool_node_shape_config_ocpus = var.node_pool_instance_shape_turn.ocpus
node_pool_node_shape_config_memory_in_gbs = var.node_pool_instance_shape_turn.memory
node_pool_boot_volume_size_in_gbs = "100"
existent_oke_nodepool_id_for_autoscaler = null
node_pool_alternative_subnet = "turn_nodes_subnet"
image_operating_system = "Oracle Linux"
image_operating_system_version = "8"
extra_initial_node_labels = [{ key = "app.pixel/turn", value = "true" }]
cni_type = "FLANNEL_OVERLAY"
node_pool_boot_volume_size_in_gbs = 100
node_pool_autoscaler_enabled = false
# existent_oke_nodepool_id_for_autoscaler = null
node_pool_alternative_subnet = "turn_nodes_subnet"
# node_pool_oke_init_params = ""
# node_pool_cloud_init_parts = []
# image_operating_system = "Oracle Linux"
# image_operating_system_version = "8"
extra_initial_node_labels = [{ key = "app.pixel/turn", value = "true" }]
cni_type = "FLANNEL_OVERLAY"
}, {
node_pool_name = "GPU"
node_pool_min_nodes = 1
node_pool_max_nodes = 1
node_k8s_version = "Latest"
node_k8s_version = var.k8s_version
node_pool_shape = var.node_pool_instance_shape_gpu.instanceShape
node_pool_shape_specific_ad = var.node_pool_shape_specific_ad_gpu
node_pool_node_shape_config_ocpus = var.node_pool_instance_shape_gpu.ocpus
node_pool_node_shape_config_memory_in_gbs = var.node_pool_instance_shape_gpu.memory
node_pool_boot_volume_size_in_gbs = "100"
existent_oke_nodepool_id_for_autoscaler = null
node_pool_alternative_subnet = null
image_operating_system = "Oracle Linux"
image_operating_system_version = "8"
extra_initial_node_labels = [{ key = "app.pixel/gpu", value = "true" }]
cni_type = "FLANNEL_OVERLAY"
node_pool_boot_volume_size_in_gbs = 100
node_pool_autoscaler_enabled = false
# existent_oke_nodepool_id_for_autoscaler = null
node_pool_alternative_subnet = null
# node_pool_oke_init_params = ""
# node_pool_cloud_init_parts = []
# image_operating_system = "Oracle Linux"
# image_operating_system_version = "8"
extra_initial_node_labels = [{ key = "app.pixel/gpu", value = "true" }]
cni_type = "FLANNEL_OVERLAY"
}, ]
}
97 changes: 58 additions & 39 deletions deploy/terraform/providers.tf
Original file line number Diff line number Diff line change
@@ -1,41 +1,38 @@
# Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
# Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
#

terraform {
required_version = ">= 1.1"
required_providers {
oci = {
source = "oracle/oci"
version = "~> 4, < 5"
# https://registry.terraform.io/providers/oracle/oci/
configuration_aliases = [oci.home_region, oci.current_region]
}
kubernetes = {
source = "hashicorp/kubernetes"
version = "~> 2"
# https://registry.terraform.io/providers/hashicorp/kubernetes/
}
helm = {
source = "hashicorp/helm"
version = "~> 2"
# https://registry.terraform.io/providers/hashicorp/helm/
}
tls = {
source = "hashicorp/tls"
version = "~> 4"
# https://registry.terraform.io/providers/hashicorp/tls/
}
local = {
source = "hashicorp/local"
version = "~> 2"
# https://registry.terraform.io/providers/hashicorp/local/
}
random = {
source = "hashicorp/random"
version = "~> 3"
# https://registry.terraform.io/providers/hashicorp/random/
}
#

provider "oci" {
tenancy_ocid = var.tenancy_ocid
region = var.region

user_ocid = var.user_ocid
fingerprint = var.fingerprint
private_key_path = var.private_key_path
}

provider "oci" {
alias = "home_region"
tenancy_ocid = var.tenancy_ocid
region = local.home_region

user_ocid = var.user_ocid
fingerprint = var.fingerprint
private_key_path = var.private_key_path
}

# New configuration to avoid Terraform Kubernetes provider interpolation. https://registry.terraform.io/providers/hashicorp/kubernetes/2.2.0/docs#stacking-with-managed-kubernetes-cluster-resources
# Currently need to uncheck to refresh (--refresh=false) when destroying or else the terraform destroy will fail

# https://docs.cloud.oracle.com/en-us/iaas/Content/ContEng/Tasks/contengdownloadkubeconfigfile.htm#notes
provider "kubernetes" {
host = local.cluster_endpoint
cluster_ca_certificate = local.cluster_ca_certificate
insecure = local.external_private_endpoint
exec {
api_version = "client.authentication.k8s.io/v1beta1"
args = ["ce", "cluster", "generate-token", "--cluster-id", local.cluster_id, "--region", local.cluster_region]
command = "oci"
}
}

Expand All @@ -44,6 +41,7 @@ provider "helm" {
kubernetes {
host = local.cluster_endpoint
cluster_ca_certificate = local.cluster_ca_certificate
insecure = local.external_private_endpoint
exec {
api_version = "client.authentication.k8s.io/v1beta1"
args = ["ce", "cluster", "generate-token", "--cluster-id", local.cluster_id, "--region", local.cluster_region]
Expand All @@ -53,8 +51,29 @@ provider "helm" {
}

locals {
cluster_endpoint = yamldecode(module.oke-quickstart.kubeconfig)["clusters"][0]["cluster"]["server"]
cluster_endpoint = yamldecode(module.oke-quickstart.kubeconfig)["clusters"][0]["cluster"]["server"]
external_private_endpoint = false
# cluster_endpoint = (var.cluster_endpoint_visibility == "Private") ? (
# "https://${module.oke.orm_private_endpoint_oke_api_ip_address}:6443") : (
# yamldecode(module.oke.kubeconfig)["clusters"][0]["cluster"]["server"])
# external_private_endpoint = (var.cluster_endpoint_visibility == "Private") ? true : false
cluster_ca_certificate = base64decode(yamldecode(module.oke-quickstart.kubeconfig)["clusters"][0]["cluster"]["certificate-authority-data"])
cluster_id = yamldecode(module.oke-quickstart.kubeconfig)["users"][0]["user"]["exec"]["args"][4]
cluster_region = yamldecode(module.oke-quickstart.kubeconfig)["users"][0]["user"]["exec"]["args"][6]
}
}

# Gets home and current regions
data "oci_identity_tenancy" "tenant_details" {
tenancy_id = var.tenancy_ocid
}
data "oci_identity_regions" "home_region" {
filter {
name = "key"
values = [data.oci_identity_tenancy.tenant_details.home_region_key]
}

count = var.home_region != "" ? 0 : 1
}
locals {
home_region = var.home_region != "" ? var.home_region : lookup(data.oci_identity_regions.home_region.0.regions.0, "name")
}
11 changes: 11 additions & 0 deletions deploy/terraform/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ variable "fingerprint" {
variable "private_key_path" {
default = ""
}
variable "home_region" {
default = ""
}

################################################################################
# Variables: OCI Networking
Expand All @@ -27,6 +30,14 @@ variable "vcn_cidr_blocks" {
description = "IPv4 CIDR Blocks for the Virtual Cloud Network (VCN). If use more than one block, separate them with comma. e.g.: 10.20.0.0/16,10.80.0.0/16. If you plan to peer this VCN with another VCN, the VCNs must not have overlapping CIDRs."
}

################################################################################
# Variables: OKE Cluster
################################################################################
variable "k8s_version" {
default = "Latest"
description = "Kubernetes version installed on your Control Plane and worker nodes. If not version select, will use the latest available."
}

################################################################################
# Variables: OKE Node Pools
################################################################################
Expand Down
40 changes: 40 additions & 0 deletions deploy/terraform/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Copyright (c) 2022,2023, Oracle and/or its affiliates. All rights reserved.
# Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
#

terraform {
required_version = ">= 1.1"
required_providers {
oci = {
source = "oracle/oci"
version = "~> 4, < 5"
# https://registry.terraform.io/providers/oracle/oci/
configuration_aliases = [oci.home_region]
}
kubernetes = {
source = "hashicorp/kubernetes"
version = "~> 2"
# https://registry.terraform.io/providers/hashicorp/kubernetes/
}
helm = {
source = "hashicorp/helm"
version = "~> 2"
# https://registry.terraform.io/providers/hashicorp/helm/
}
tls = {
source = "hashicorp/tls"
version = "~> 4"
# https://registry.terraform.io/providers/hashicorp/tls/
}
local = {
source = "hashicorp/local"
version = "~> 2"
# https://registry.terraform.io/providers/hashicorp/local/
}
random = {
source = "hashicorp/random"
version = "~> 3"
# https://registry.terraform.io/providers/hashicorp/random/
}
}
}

0 comments on commit 45d8460

Please sign in to comment.