Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
113 changes: 77 additions & 36 deletions integration-tests/src/test/resources/oke/terraform/cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,62 +2,103 @@
# Copyright (c) 2020, 2021, Oracle and/or its affiliates.
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
*/
variable "cluster_kubernetes_version" { default = "v1.15.7" }
variable "cluster_name" { default = "tfTestCluster" }
variable "cluster_options_add_ons_is_kubernetes_dashboard_enabled" { default = true }
variable "cluster_options_add_ons_is_tiller_enabled" { default = true }
variable "cluster_options_kubernetes_network_config_pods_cidr" { default = "10.1.0.0/16" }
variable "cluster_options_kubernetes_network_config_services_cidr" { default = "10.2.0.0/16" }
variable "node_pool_initial_node_labels_key" { default = "key" }
variable "node_pool_initial_node_labels_value" { default = "value" }
variable "node_pool_kubernetes_version" { default = "v1.11.5" }
variable "node_pool_name" { default = "tfTestCluster_workers" }
variable "node_pool_node_image_name" { default = "Oracle-Linux-7.6" }
variable "node_pool_node_shape" { default = "VM.Standard2.1" }
variable "node_pool_quantity_per_subnet" { default = 2 }
variable "node_pool_ssh_public_key" { }
variable "cluster_kubernetes_version" {
default = "v1.17.9"
}

data "oci_identity_availability_domains" "tfsample_availability_domains" {
compartment_id = "${var.compartment_ocid}"
variable "cluster_name" {
default = "tfTestCluster"
}

variable "cluster_options_add_ons_is_kubernetes_dashboard_enabled" {
default = true
}

variable "cluster_options_add_ons_is_tiller_enabled" {
default = true
}

variable "cluster_options_kubernetes_network_config_pods_cidr" {
default = "10.1.0.0/16"
}

variable "cluster_options_kubernetes_network_config_services_cidr" {
default = "10.2.0.0/16"
}

variable "node_pool_initial_node_labels_key" {
default = "key"
}

variable "node_pool_initial_node_labels_value" {
default = "value"
}

variable "node_pool_kubernetes_version" {
default = "v1.17.9"
}

variable "node_pool_name" {
default = "tfTestCluster_workers"
}

variable "node_pool_node_image_name" {
default = "Oracle-Linux-7.6"
}

variable "node_pool_node_shape" {
default = "VM.Standard2.1"
}

variable "node_pool_quantity_per_subnet" {
default = 2
}

variable "node_pool_ssh_public_key" {
}

data "oci_identity_availability_domains" "tfsample_availability_domains" {
compartment_id = var.compartment_ocid
}

resource "oci_containerengine_cluster" "tfsample_cluster" {
#Required
compartment_id = "${var.compartment_ocid}"
kubernetes_version = "${var.cluster_kubernetes_version}"
name = "${var.cluster_name}"
vcn_id = "${oci_core_virtual_network.oke-vcn.id}"
compartment_id = var.compartment_ocid
kubernetes_version = var.cluster_kubernetes_version
name = var.cluster_name
vcn_id = oci_core_virtual_network.oke-vcn.id

#Optional
options {
service_lb_subnet_ids = ["${oci_core_subnet.oke-subnet-loadbalancer-1.id}", "${oci_core_subnet.oke-subnet-loadbalancer-2.id}"]
service_lb_subnet_ids = [oci_core_subnet.oke-subnet-loadbalancer-1.id, oci_core_subnet.oke-subnet-loadbalancer-2.id]

#Optional
add_ons {
#Optional
is_kubernetes_dashboard_enabled = "${var.cluster_options_add_ons_is_kubernetes_dashboard_enabled}"
is_tiller_enabled = "${var.cluster_options_add_ons_is_tiller_enabled}"
is_kubernetes_dashboard_enabled = var.cluster_options_add_ons_is_kubernetes_dashboard_enabled
is_tiller_enabled = var.cluster_options_add_ons_is_tiller_enabled
}
}
}

resource "oci_containerengine_node_pool" "tfsample_node_pool" {
#Required
cluster_id = "${oci_containerengine_cluster.tfsample_cluster.id}"
compartment_id = "${var.compartment_ocid}"
kubernetes_version = "${var.node_pool_kubernetes_version}"
name = "${var.node_pool_name}"
node_image_name = "${var.node_pool_node_image_name}"
node_shape = "${var.node_pool_node_shape}"
#subnet_ids = ["${oci_core_subnet.oke-subnet-worker-1.id}", "${oci_core_subnet.oke-subnet-worker-2.id}","${oci_core_subnet.oke-subnet-worker-3.id}"]
subnet_ids = ["${oci_core_subnet.oke-subnet-worker-1.id}", "${oci_core_subnet.oke-subnet-worker-2.id}"]
#Required
cluster_id = oci_containerengine_cluster.tfsample_cluster.id
compartment_id = var.compartment_ocid
kubernetes_version = var.node_pool_kubernetes_version
name = var.node_pool_name
node_image_name = var.node_pool_node_image_name
node_shape = var.node_pool_node_shape

#subnet_ids = ["${oci_core_subnet.oke-subnet-worker-1.id}", "${oci_core_subnet.oke-subnet-worker-2.id}","${oci_core_subnet.oke-subnet-worker-3.id}"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete commented out line

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left them intentionally , so we can switch between2 and 3 nodes in cluster

subnet_ids = [oci_core_subnet.oke-subnet-worker-1.id, oci_core_subnet.oke-subnet-worker-2.id]

#Optional
quantity_per_subnet = "${var.node_pool_quantity_per_subnet}"
ssh_public_key = "${var.node_pool_ssh_public_key}"
#Optional
quantity_per_subnet = var.node_pool_quantity_per_subnet
ssh_public_key = var.node_pool_ssh_public_key
}

output "cluster_id" {
value = "${oci_containerengine_cluster.tfsample_cluster.id}"
value = oci_containerengine_cluster.tfsample_cluster.id
}

5 changes: 3 additions & 2 deletions integration-tests/src/test/resources/oke/terraform/export.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
*/
resource "oci_file_storage_export" "oketest_export" {
#Required
export_set_id = "${oci_file_storage_export_set.oketest_export_set.id}"
file_system_id = "${oci_file_storage_file_system.oketest_fs.id}"
export_set_id = oci_file_storage_export_set.oketest_export_set.id
file_system_id = oci_file_storage_file_system.oketest_fs.id
path = "/oketest"
}

Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@

resource "oci_file_storage_export_set" "oketest_export_set" {
# Required
mount_target_id = "${oci_file_storage_mount_target.oketest_mount_target.id}"
mount_target_id = oci_file_storage_mount_target.oketest_mount_target.id
}

Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

resource "oci_file_storage_file_system" "oketest_fs" {
#Required
availability_domain = "${lookup(data.oci_identity_availability_domains.ADs.availability_domains[1],"name")}"
compartment_id = "${var.compartment_ocid}"
availability_domain = data.oci_identity_availability_domains.ADs.availability_domains[1]["name"]
compartment_id = var.compartment_ocid
}

14 changes: 10 additions & 4 deletions integration-tests/src/test/resources/oke/terraform/kube_config.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,21 @@
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
*/

variable "cluster_kube_config_expiration" { default = 2592000 }
variable "cluster_kube_config_token_version" { default = "1.0.0" }
variable "cluster_kube_config_expiration" {
default = 2592000
}

variable "cluster_kube_config_token_version" {
default = "2.0.0"
}

data "oci_containerengine_cluster_kube_config" "tfsample_cluster_kube_config" {
#Required
cluster_id = "${oci_containerengine_cluster.tfsample_cluster.id}"
cluster_id = oci_containerengine_cluster.tfsample_cluster.id
}

resource "local_file" "tfsample_cluster_kube_config_file" {
content = "${data.oci_containerengine_cluster_kube_config.tfsample_cluster_kube_config.content}"
content = data.oci_containerengine_cluster_kube_config.tfsample_cluster_kube_config.content
filename = "${path.module}/${var.cluster_name}_kubeconfig"
}

Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
*/
resource "oci_file_storage_mount_target" "oketest_mount_target" {
#Required
availability_domain = "${lookup(data.oci_identity_availability_domains.ADs.availability_domains[1],"name")}"
compartment_id = "${var.compartment_ocid}"
subnet_id = "${oci_core_subnet.oke-subnet-worker-2.id}"
availability_domain = data.oci_identity_availability_domains.ADs.availability_domains[1]["name"]

compartment_id = var.compartment_ocid
subnet_id = oci_core_subnet.oke-subnet-worker-2.id

#Optional
display_name = "${var.cluster_name}-mt"
}

31 changes: 21 additions & 10 deletions integration-tests/src/test/resources/oke/terraform/provider.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,28 @@
*/

// These variables would commonly be defined as environment variables or sourced in a .env file
variable "tenancy_ocid" {}
variable "user_ocid" {}
variable "fingerprint" {}
variable "private_key_path" {}
variable "region" { default = "us-phoenix-1" }
variable "tenancy_ocid" {
}

variable "user_ocid" {
}

variable "fingerprint" {
}

variable "private_key_path" {
}

variable "region" {
default = "us-phoenix-1"
}

provider "oci" {
version = ">= 3.0.0"
region = "${var.region}"
tenancy_ocid = "${var.tenancy_ocid}"
user_ocid = "${var.user_ocid}"
fingerprint = "${var.fingerprint}"
private_key_path = "${var.private_key_path}"
region = var.region
tenancy_ocid = var.tenancy_ocid
user_ocid = var.user_ocid
fingerprint = var.fingerprint
private_key_path = var.private_key_path
}

Loading