Skip to content

Commit a6e4131

Browse files
committed
oke-rm-1.1.2
1 parent 33557aa commit a6e4131

File tree

10 files changed

+224
-35
lines changed

10 files changed

+224
-35
lines changed

app-dev/devops-and-containers/oke/oke-rm/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ This stack is used to create the initial network infrastructure for OKE. When co
1616
* By default, everything is private, but there is the possibility to create public subnets
1717
* Be careful when modifying the default values, as inputs are not validated
1818

19-
[![Deploy to Oracle Cloud](https://oci-resourcemanager-plugin.plugins.oci.oraclecloud.com/latest/deploy-to-oracle-cloud.svg)](https://cloud.oracle.com/resourcemanager/stacks/create?zipUrl=https://github.com/oracle-devrel/technology-engineering/releases/download/oke-rm-1.1.2/infra.zip)
19+
[![Deploy to Oracle Cloud](https://oci-resourcemanager-plugin.plugins.oci.oraclecloud.com/latest/deploy-to-oracle-cloud.svg)](https://cloud.oracle.com/resourcemanager/stacks/create?zipUrl=https://github.com/oracle-devrel/technology-engineering/releases/download/oke-rm-1.1.3/infra.zip)
2020

2121
## Step 2: Create the OKE control plane
2222

2323
This stack is used to create the OKE control plane ONLY.
2424

25-
[![Deploy to Oracle Cloud](https://oci-resourcemanager-plugin.plugins.oci.oraclecloud.com/latest/deploy-to-oracle-cloud.svg)](https://cloud.oracle.com/resourcemanager/stacks/create?zipUrl=https://github.com/oracle-devrel/technology-engineering/releases/download/oke-rm-1.1.2/oke.zip)
25+
[![Deploy to Oracle Cloud](https://oci-resourcemanager-plugin.plugins.oci.oraclecloud.com/latest/deploy-to-oracle-cloud.svg)](https://cloud.oracle.com/resourcemanager/stacks/create?zipUrl=https://github.com/oracle-devrel/technology-engineering/releases/download/oke-rm-1.1.3/oke.zip)
2626

2727
Also note that if the network infrastructure is located in a different compartment than the OKE cluster AND you are planning to use the OCI_VCN_NATIVE CNI,
2828
you must add these policies:
Binary file not shown.

app-dev/devops-and-containers/oke/oke-rm/infra/provider.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ terraform {
33
required_providers {
44
oci = {
55
source = "oracle/oci"
6-
version = "7.4.0"
6+
version = "7.7.0"
77
}
88
null = {
99
source = "hashicorp/null"

app-dev/devops-and-containers/oke/oke-rm/oke/locals.tf

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,20 @@ locals {
66
enable_cert_manager = var.cluster_type == "enhanced" && var.enable_cert_manager
77
enable_metrics_server = var.cluster_type == "enhanced" && var.enable_cert_manager && var.enable_metrics_server
88
enable_cluster_autoscaler = var.cluster_type == "enhanced" && var.enable_cluster_autoscaler
9-
create_autoscaler_policies = var.cluster_type == "enhanced"&& var.enable_cluster_autoscaler && var.create_autoscaler_policies
9+
create_autoscaler_policies = var.cluster_type == "enhanced" && var.enable_cluster_autoscaler && var.create_autoscaler_policies
10+
}
11+
12+
# OIDC
13+
locals {
14+
oidc_discovery_enabled = var.cluster_type == "enhanced" && var.enable_oidc_discovery
15+
oidc_authentication_enabled = var.cluster_type == "enhanced" && var.enable_oidc_authentication
16+
oidc_token_authentication_config = {
17+
client_id = var.oidc_client_id
18+
issuer_url = var.oidc_issuer
19+
username_claim = var.oidc_username_claim
20+
username_prefix = var.oidc_username_prefix
21+
groups_claim = var.oidc_groups_claim
22+
groups_prefix = var.oidc_groups_prefix
23+
}
24+
1025
}

app-dev/devops-and-containers/oke/oke-rm/oke/oke.tf

Lines changed: 69 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ locals {
3737

3838
module "oke" {
3939
source = "oracle-terraform-modules/oke/oci"
40-
version = "5.2.4"
40+
version = "5.3.1"
4141
compartment_id = var.oke_compartment_id
4242
# IAM - Policies
4343
create_iam_autoscaler_policy = "never"
@@ -68,7 +68,7 @@ module "oke" {
6868
create_vcn = false
6969
vcn_id = var.vcn_id
7070
# Network module - security
71-
control_plane_allowed_cidrs = var.cp_allowed_cidr_list # ["0.0.0.0/0"]
71+
control_plane_allowed_cidrs = var.cp_allowed_cidr_list
7272
control_plane_is_public = ! local.is_cp_subnet_private
7373
load_balancers = local.is_lb_subnet_private ? "internal" : "public"
7474
preferred_load_balancer = local.is_lb_subnet_private ? "internal" : "public"
@@ -84,6 +84,15 @@ module "oke" {
8484
use_signed_images = false
8585
use_defined_tags = false
8686

87+
# OIDC
88+
oidc_discovery_enabled = local.oidc_discovery_enabled
89+
oidc_token_auth_enabled = local.oidc_authentication_enabled
90+
oidc_token_authentication_config = local.oidc_token_authentication_config
91+
92+
cluster_freeform_tags = {
93+
cluster = var.cluster_name
94+
}
95+
8796
# Bastion
8897
create_bastion = false
8998

@@ -101,7 +110,7 @@ module "oke" {
101110

102111
# Set this to true to enable in-transit encryption on all node pools by default
103112
# NOTE: in-transit encryption is supported only for paravirtualized attached block volumes (NOT boot volumes), hence you will need to create another StorageClass in the cluster as the default oci-bv StorageClass uses iSCSI
104-
# Also note that Bare Metal instances do not support paravirtualized volumes, so do not enable this for node pools that require BM instances
113+
# Also note that Bare Metal instances do not support paravirtualized volumes, so do not enable this in node pools that require BM instances
105114
worker_pv_transit_encryption = false
106115
# Enable encryption of volumes with a key managed by you, in your OCI Vault
107116
#worker_volume_kms_key_id = local.volume_kms_key_id
@@ -110,7 +119,7 @@ module "oke" {
110119
#max_pods_per_node = 31
111120

112121
worker_disable_default_cloud_init = false # If set to true, will let you full control over the cloud init, set it when using ubuntu nodes or nodes with taints (can even be set individually at the node pool level)
113-
worker_cloud_init = [{ content_type = "text/cloud-config", content = yamlencode(local.cloud_init_ol)}] # Cloud init is different, depending if you are using Ubuntu or Oracle Linux nodes
122+
worker_cloud_init = [{ content_type = "text/cloud-config", content = yamlencode(local.cloud_init_ol)}] # Cloud init is different, depending if you are using Ubuntu or Oracle Linux nodes. You can also set taints with the cloud init
114123

115124
# GLOBAL TAGS TO BE APPLIED ON ALL NODES
116125
# NOTE: tags will be applied to both the node pool and the nodes
@@ -125,34 +134,23 @@ module "oke" {
125134

126135
worker_pools = {
127136

128-
# SYSTEM NODE POOL TO BE ENABLED FOR THE CLUSTER AUTOSCALER
129-
np-system-ad1 = {
130-
shape = "VM.Standard.E4.Flex"
131-
size = 1
132-
placement_ads = ["1"]
133-
ocpus = 1
134-
memory = 16
135-
node_cycling_enabled = true
136-
node_cycling_max_surge = "50%"
137-
node_cycling_max_unavailable = "25%"
138-
node_labels = {
139-
role = "system"
140-
}
141-
create = false
142-
}
143-
144137
# SAMPLE NODE POOL, SET create = true TO PROVISION IT
145138
np-ad1 = {
146139
shape = "VM.Standard.E4.Flex"
147140
size = 1
141+
kubernetes_version = var.kubernetes_version # You can set this value as fixed, so that control plane and data plane are upgraded separately
148142
placement_ads = ["1"] # As best practice, one node pool should be associated only to one specific AD
149-
ocpus = 2 # No need to specify ocpus and memory if you are not using a Flex shape
143+
ocpus = 1 # No need to specify ocpus and memory if you are not using a Flex shape
144+
memory = 16
145+
#image_type = "custom"
150146
#image_id = "" # You can override global worker node parameters individually in the node pool
151-
memory = 16 # No need to specify ocpus and memory if you are not using a Flex shape
152-
node_cycling_enabled = true # Option to enable/disable node pool cycling through Terraform. NOT SUPPORTED WITH BARE METAL NODES!
147+
node_cycling_enabled = false # Option to enable/disable node pool cycling through Terraform. Only works with Enhanced clusters!
153148
node_cycling_max_surge = "50%"
154149
node_cycling_max_unavailable = "25%"
155-
boot_volume_size = 100 # For Oracle Linux, make sure the oci-growfs command is specified in the cloud-init script. This module already implement this
150+
151+
node_cycling_mode = ["boot_volume"] # Valid values are instance and boot_volume. Only works when (kubernetes_version, image_id, boot_volume_size, node_metadata, ssh_public_key, volume_kms_key_id) are modified. If you need to change something else, switch to instance
152+
# NOTE: boot_volume mode seems to work only for Flannel clusters for now
153+
boot_volume_size = 100 # For Oracle Linux, make sure the oci-growfs command is specified in the cloud-init script. This module already implements this
156154
freeform_tags = { # Nodes in the node pool will be tagged with these freeform tags
157155
"oke-cluster-name" = var.cluster_name
158156
}
@@ -161,6 +159,23 @@ module "oke" {
161159
create = false # Set it to true so that the node pool is created
162160
}
163161

162+
# SYSTEM NODE POOL TO BE ENABLED FOR THE CLUSTER AUTOSCALER
163+
np-system-ad1 = {
164+
shape = "VM.Standard.E4.Flex"
165+
size = 1
166+
placement_ads = ["1"]
167+
ocpus = 1
168+
memory = 16
169+
node_cycling_enabled = true # Only works with Enhanced clusters!
170+
node_cycling_max_surge = "50%"
171+
node_cycling_max_unavailable = "25%"
172+
node_cycling_mode = ["boot_volume"]
173+
node_labels = {
174+
role = "system"
175+
}
176+
create = false
177+
}
178+
164179

165180
# SAMPLE NODE POOL WITH A CLOUD INIT TO SET NODE TAINTS
166181
np-taints = { # An example of a node pool using a custom cloud-init script to define taints at the node pool level
@@ -174,12 +189,13 @@ module "oke" {
174189
node_cycling_enabled = true
175190
node_cycling_max_surge = "50%"
176191
node_cycling_max_unavailable = "25%"
192+
node_cycling_mode = ["boot_volume"]
177193
boot_volume_size = 100
178-
ignore_initial_pool_size = false
179194
create = false
180195
}
181196

182197

198+
# SAMPLE AUTOSCALED NODE POOL
183199
# This is a sample pool where autoscaling is enabled, note the freeform tag
184200
# REQUIREMENTS FOR ENABLING THE CLUSTER AUTOSCALER
185201
# - THE CLUSTER AUTOSCALER ADDON MUST BE ENABLED
@@ -196,13 +212,41 @@ module "oke" {
196212
node_cycling_enabled = true
197213
node_cycling_max_surge = "50%"
198214
node_cycling_max_unavailable = "25%"
215+
node_cycling_mode = ["boot_volume"]
199216
boot_volume_size = 100
200217
ignore_initial_pool_size = true
201218
freeform_tags = {
202219
cluster_autoscaler = "enabled"
203220
}
204221
create = false
205222
}
223+
224+
# SAMPLE AUTOSCALED PREEMPTIBLE NODE POOL
225+
# Often, to save money it makes sense to provision preemptible instances, as autoscaled node pools are already very dynamic
226+
np-autoscaled-preemptible-ad1 = {
227+
shape = "VM.Standard.E4.Flex"
228+
size = 1
229+
placement_ads = ["1"]
230+
ocpus = 1
231+
memory = 16
232+
node_cycling_enabled = true
233+
node_cycling_max_surge = "50%"
234+
node_cycling_max_unavailable = "25%"
235+
node_cycling_mode = ["boot_volume"]
236+
boot_volume_size = 70
237+
ignore_initial_pool_size = true
238+
freeform_tags = {
239+
cluster_autoscaler = "enabled"
240+
}
241+
preemptible_config = {
242+
enable = true
243+
is_preserve_boot_volume = false
244+
}
245+
create = false
246+
}
247+
248+
249+
206250
}
207251

208252
providers = {
Binary file not shown.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
output "cluster_id" {
2+
value = module.oke.cluster_id
3+
}
4+
5+
output "worker_pools" {
6+
value = module.oke.worker_pools
7+
}
8+
9+
output "oidc_discovery_endpoint" {
10+
value = module.oke.cluster_oidc_discovery_endpoint
11+
}

app-dev/devops-and-containers/oke/oke-rm/oke/provider.tf

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,9 @@ terraform {
33
required_providers {
44
oci = {
55
source = "oracle/oci"
6-
version = "7.4.0"
6+
version = "7.7.0"
77
configuration_aliases = [oci.home]
88
}
9-
helm = {
10-
source = "hashicorp/helm"
11-
version = "~> 2.9.0"
12-
}
139
}
1410
}
1511

app-dev/devops-and-containers/oke/oke-rm/oke/schema.yaml

Lines changed: 93 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,21 @@ variableGroups:
5656
- oke_vault_id
5757
- cluster_kms_key_id
5858

59+
- title: "OIDC"
60+
visible:
61+
eq:
62+
- ${cluster_type}
63+
- enhanced
64+
variables:
65+
- enable_oidc_discovery
66+
- enable_oidc_authentication
67+
- oidc_issuer
68+
- oidc_client_id
69+
- oidc_username_claim
70+
- oidc_username_prefix
71+
- oidc_groups_claim
72+
- oidc_groups_prefix
73+
5974
variables:
6075

6176
region:
@@ -281,4 +296,81 @@ variables:
281296
description: "Key used to encrypt secrets located in etcd"
282297
dependsOn:
283298
compartmentId: ${oke_vault_compartment_id}
284-
vaultId: ${oke_vault_id}
299+
vaultId: ${oke_vault_id}
300+
301+
# OIDC
302+
303+
enable_oidc_discovery:
304+
title: "Enable OIDC Discovery"
305+
description: "Enable OKE to act as an Identity Provider to exchange pod SeviceAccounts for access tokens"
306+
type: boolean
307+
308+
enable_oidc_authentication:
309+
title: "Enable OIDC Authentication"
310+
description: "Enable OIDC authentication performed by an external OIDC Identity Provider"
311+
type: boolean
312+
313+
oidc_issuer:
314+
title: "OIDC Issuer URL"
315+
description: "URL of the external Identity Provider token issuer. Control Plane MUST be able to reach it"
316+
type: string
317+
required: true
318+
visible: ${enable_oidc_authentication}
319+
320+
oidc_client_id:
321+
title: "OIDC Client Id"
322+
description: "OIDC Client Id on the external Identity Provider"
323+
type: string
324+
required: true
325+
visible: ${enable_oidc_authentication}
326+
327+
oidc_username_claim:
328+
title: "OIDC username claim"
329+
description: "Claim representing the username"
330+
type: string
331+
required: true
332+
visible: ${enable_oidc_authentication}
333+
334+
oidc_username_prefix:
335+
title: "OIDC username prefix"
336+
description: "Prefix prepended to the username"
337+
type: string
338+
required: true
339+
visible: ${enable_oidc_authentication}
340+
341+
oidc_groups_claim:
342+
title: "OIDC groups claim"
343+
description: "Claim representing the groups"
344+
type: string
345+
required: true
346+
visible: ${enable_oidc_authentication}
347+
348+
oidc_groups_prefix:
349+
title: "OIDC groups prefix"
350+
description: "Prefix prepended to the groups"
351+
type: string
352+
required: true
353+
visible: ${enable_oidc_authentication}
354+
355+
356+
# OUTPUT SECTION
357+
358+
outputGroups:
359+
- title: OKE
360+
outputs:
361+
- cluster_id
362+
- worker_pools
363+
- oidc_discovery_endpoint
364+
365+
outputs:
366+
cluster_id:
367+
type: ocid
368+
title: OKE Cluster OCID
369+
370+
worker_pools:
371+
type: map
372+
title: Worker Pools
373+
374+
oidc_discovery_endpoint:
375+
type: link
376+
title: OIDC Discovery Endpoint

app-dev/devops-and-containers/oke/oke-rm/oke/variable.tf

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,4 +80,35 @@ variable "oke_vault_id" {
8080

8181
variable "cluster_kms_key_id" {
8282
default = null
83+
}
84+
85+
# OIDC
86+
87+
variable "enable_oidc_discovery" {
88+
type = bool
89+
default = false
90+
}
91+
92+
variable "enable_oidc_authentication" {
93+
type = bool
94+
default = false
95+
}
96+
97+
variable "oidc_issuer" {
98+
default = null
99+
}
100+
variable "oidc_client_id" {
101+
default = null
102+
}
103+
variable "oidc_username_claim" {
104+
default = "sub"
105+
}
106+
variable "oidc_username_prefix" {
107+
default = "oidc:"
108+
}
109+
variable "oidc_groups_claim" {
110+
default = "groups"
111+
}
112+
variable "oidc_groups_prefix" {
113+
default = "oidc:"
83114
}

0 commit comments

Comments
 (0)