Skip to content

Commit 830192e

Browse files
devoncrousehyder
authored andcommitted
feat: Add oci_containerengine_cluster type with 'basic' or 'enhanced'
Signed-off-by: Devon Crouse <[email protected]>
1 parent 6c9168a commit 830192e

File tree

6 files changed

+28
-12
lines changed

6 files changed

+28
-12
lines changed

main.tf

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2017, 2022 Oracle Corporation and/or affiliates.
1+
# Copyright 2017, 2023 Oracle Corporation and/or affiliates.
22
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl
33

44
module "vcn" {
@@ -248,10 +248,14 @@ module "oke" {
248248
ssh_public_key_path = var.ssh_public_key_path
249249

250250
# oke cluster parameters
251-
cluster_kubernetes_version = var.kubernetes_version
252-
control_plane_type = var.control_plane_type
253-
control_plane_nsgs = concat(var.control_plane_nsgs, [module.network.control_plane_nsg_id])
254-
cluster_name = var.cluster_name
251+
cluster_kubernetes_version = var.kubernetes_version
252+
control_plane_type = var.control_plane_type
253+
control_plane_nsgs = concat(var.control_plane_nsgs, [module.network.control_plane_nsg_id])
254+
cluster_name = var.cluster_name
255+
cluster_type = lookup({
256+
"basic" = "BASIC_CLUSTER",
257+
"enhanced" = "ENHANCED_CLUSTER"
258+
}, lower(var.cluster_type), "BASIC_CLUSTER")
255259
cluster_options_add_ons_is_kubernetes_dashboard_enabled = var.dashboard_enabled
256260
cluster_options_kubernetes_network_config_pods_cidr = var.pods_cidr
257261
cluster_options_kubernetes_network_config_services_cidr = var.services_cidr

modules/oke/cluster.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2017, 2022 Oracle Corporation and/or affiliates.
1+
# Copyright 2017, 2023 Oracle Corporation and/or affiliates.
22
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl
33

44
# 30s delay to allow policies to take effect globally
@@ -13,7 +13,7 @@ resource "oci_containerengine_cluster" "k8s_cluster" {
1313
kubernetes_version = var.cluster_kubernetes_version
1414
kms_key_id = var.use_cluster_encryption == true ? var.cluster_kms_key_id : null
1515
name = var.label_prefix == "none" ? var.cluster_name : "${var.label_prefix}-${var.cluster_name}"
16-
16+
type = var.cluster_type
1717
depends_on = [time_sleep.wait_30_seconds]
1818

1919
cluster_pod_network_options {

modules/oke/variables.tf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2017, 2022 Oracle Corporation and/or its affiliates.
1+
# Copyright (c) 2017, 2023 Oracle Corporation and/or its affiliates.
22
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl
33

44
# oci provider
@@ -25,6 +25,7 @@ variable "control_plane_nsgs" {
2525
}
2626

2727
variable "cluster_name" {}
28+
variable "cluster_type" {}
2829

2930
variable "cluster_options_add_ons_is_kubernetes_dashboard_enabled" {
3031
type = bool

terraform.tfvars.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ allow_pod_internet_access = true
168168
allow_worker_internet_access = true
169169
allow_worker_ssh_access = false
170170
cluster_name = "oke"
171+
cluster_type = "basic"
171172
cni_type = "flannel"
172173
control_plane_type = "private"
173174
control_plane_allowed_cidrs = ["0.0.0.0/0"]

variables.tf

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2017, 2022 Oracle Corporation and/or its affiliates.
1+
# Copyright (c) 2017, 2023 Oracle Corporation and/or its affiliates.
22
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl
33

44
# OCI Provider parameters
@@ -545,6 +545,16 @@ variable "cluster_name" {
545545
type = string
546546
}
547547

548+
variable "cluster_type" {
549+
default = "basic"
550+
description = "The cluster type. See <a href=https://docs.oracle.com/en-us/iaas/Content/ContEng/Tasks/contengworkingwithenhancedclusters.htm>Working with Enhanced Clusters and Basic Clusters</a> for more information."
551+
type = string
552+
validation {
553+
condition = contains(["basic", "enhanced"], lower(var.cluster_type))
554+
error_message = "Accepted values are 'basic' or 'enhanced'."
555+
}
556+
}
557+
548558
variable "cni_type" {
549559
# Keep flannel as default so users can upgrade without impact. Give a grace period for users to plan and change
550560
default = "flannel"

versions.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
# Copyright 2017, 2022 Oracle Corporation and/or affiliates.
1+
# Copyright 2017, 2023 Oracle Corporation and/or affiliates.
22
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl
33

44
terraform {
55
required_providers {
66
oci = {
77
source = "oracle/oci"
88
configuration_aliases = [oci.home]
9-
version = ">= 4.67.3"
9+
version = "~> 4.114.0"
1010
}
1111
}
12-
required_version = ">= 1.1.0"
12+
required_version = ">= 1.2.0"
1313
}

0 commit comments

Comments
 (0)