Skip to content

Commit a01dca5

Browse files
hyderkarthicgit
andauthored
feat: Added fss storage module. (#491)
* feat: Add FSS provisioning * FSS Storage module added * enable_fss changed to create_fss * changed enable_fss to create_fss in main.tf * added worker nsg for fss * FSS nsg rules moved to network module * formatting and removing create_fss variable Co-authored-by: Karthic Ravindran <karthic.ravindran@oracle.com>
1 parent f776bd3 commit a01dca5

30 files changed

+640
-27
lines changed

docs/codingconventions.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ Links that are used multiple times must be defined in the header using the `:uri
8585

8686
- Use `snake_case` when naming Terraform files, variables and resources
8787
- If you need a new .tf file for better clarity, use this naming scheme: `<resources_group>`: e.g. `subnets.tf`, `nsgs.tf`
88-
- If your variable is controlling a behaviour, use imperative style to name it: e.g. `create_internet_gateway`, `use_encryption`
88+
- If your variable is controlling a behaviour, use imperative style to name it: e.g. `create_internet_gateway`, `use_cluster_encryption`
8989

9090
=== Variable blocks
9191

docs/configuration.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ create_bastion_host = true
259259
OKE Variables:-
260260

261261
----
262-
use_encryption = true
262+
use_cluster_encryption = true
263263
cluster_kms_key_id = <cluster_kms_key_id>
264264
use_node_pool_volume_encryption = true
265265
node_pool_volume_kms_key_id = <node_pool_volume_kms_key_id>

docs/dependencies.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ The following table documents the {uri-terraform-options}[Terraform Options] dep
4646
|Whether to create an authentication secret for OCIR
4747
|create_bastion_host = true, create_operator = true, enable_operator_instance_principal = true, secret_id = secret ocid
4848

49-
|use_encryption
49+
|use_cluster_encryption
5050
|Uses OCI KMS to encrypt data in OKE's underlying etcd
5151
|create_bastion_host = true, create_operator = true, enable_operator_instance_principal = true
5252

docs/instructions.adoc

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
:uri-networks-subnets-cidr: https://erikberg.com/notes/networks.html
2525
:uri-oci: https://cloud.oracle.com/cloud-infrastructure
2626
:uri-oci-documentation: https://docs.cloud.oracle.com/iaas/Content/home.htm
27+
:uri-oci-fss-pvc: https://docs.oracle.com/en-us/iaas/Content/ContEng/Tasks/contengcreatingpersistentvolumeclaim.htm#Provisioning_Persistent_Volume_Claims_on_the_FileStorageService
2728
:uri-oci-instance-principal: https://docs.cloud.oracle.com/iaas/Content/Identity/Tasks/callingservicesfrominstances.htm
2829
:uri-oci-kms: https://docs.cloud.oracle.com/iaas/Content/KeyManagement/Concepts/keyoverview.htm
2930
:uri-oci-loadbalancer-annotations: https://github.com/oracle/oci-cloud-controller-manager/blob/master/docs/load-balancer-annotations.md
@@ -74,7 +75,7 @@ If you wish to use {uri-oci-kms}[OCI KMS] to encrypt Kubernetes secrets, the fol
7475
* link:#adding-the-bastion-host[bastion must be enabled]
7576
* link:#enabling-instance_principal-on-the-operator-host[operator instance_principal must be enabled]
7677

77-
* use_encryption must be set to _true_
78+
* use_cluster_encryption must be set to _true_
7879
* cluster_kms_key_id must be provided
7980

8081
If you wish to use {uri-oci-kms}[OCI KMS] to encrypt OKE nodepool boot/block volume, the following is required:
@@ -461,3 +462,22 @@ Review the following documentation and articles on creating load balancers of di
461462
* {uri-oci-load-balancers}[Specifying Alternative Load Balancer Shapes]
462463

463464
* {uri-oci-oke-flexible-loadbalancers}[Creating flexible OCI Load Balancers with OKE]
465+
466+
== Provisioning PVCs on the File Storage Service
467+
468+
. Set `create_fss` to true in terraform.tfvars
469+
470+
+
471+
----
472+
create_fss = false
473+
----
474+
475+
+
476+
It will create the File Storage service instance on a separate subnet with the network security group configured.
477+
478+
+
479+
You can then review the following documentation for creating persistent volume claim and persistent volume using file storage
480+
481+
* {uri-oci-fss-pvc}[Provisioning PV and PVC using FSS]
482+
483+
CAUTION: Running terraform destroy will remove the filesystem storage created using terraform. Ensure you have taken the necessary backup if needed.

docs/terraformoptions.adoc

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -611,13 +611,13 @@ EOT
611611
|Values
612612
|Default
613613

614-
|use_encryption
614+
|use_cluster_encryption
615615
|Whether to use {uri-oci-kms}[OCI KMS] to encrypt secrets.
616616
|true/false
617617
|false
618618

619619
|cluster_kms_key_id
620-
|The id of the OCI KMS key to be used as the master encryption key for encrypting Kubernetes' etcd . *Required* if _use_encryption_ is set to *true*
620+
|The id of the OCI KMS key to be used as the master encryption key for encrypting Kubernetes' etcd . *Required* if _use_cluster_encryption_ is set to *true*
621621
|`ocid1.key.oc1....`
622622
|
623623

@@ -712,6 +712,37 @@ node_pools = {
712712

713713
|===
714714

715+
== File Storage
716+
717+
[stripes=odd,cols="1m,4d,2m,2m", options=header,width="100%"]
718+
|===
719+
|Parameter
720+
|Description
721+
|Values
722+
|Default
723+
724+
|create_fss
725+
|Whether to create File storage or not.
726+
|true/false
727+
|false
728+
729+
|fss_mount_path
730+
|File storage mount path to be associated.
731+
|/oke_fss
732+
|/oke_fss
733+
734+
|max_fs_stat_bytes
735+
|Maximum tbytes, fbytes, and abytes, values reported by NFS FSSTAT calls through any associated mount targets.
736+
|23843202333
737+
|23843202333
738+
739+
|max_fs_stat_files
740+
|Maximum tfiles, ffiles, and afiles values reported by NFS FSSTAT.
741+
|223442
742+
|223442
743+
|===
744+
745+
715746
== Upgrade cluster
716747

717748
[stripes=odd,cols="1m,4d,2m,2m", options=header,width="100%"]

main.tf

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,9 @@ module "network" {
191191
# waf integration
192192
enable_waf = var.enable_waf
193193

194+
# fss integration
195+
create_fss = var.create_fss
196+
194197
depends_on = [
195198
module.vcn
196199
]
@@ -221,7 +224,7 @@ module "oke" {
221224
cluster_options_kubernetes_network_config_services_cidr = var.services_cidr
222225
cluster_subnets = module.network.subnet_ids
223226
vcn_id = module.vcn.vcn_id
224-
use_encryption = var.use_encryption
227+
use_cluster_encryption = var.use_cluster_encryption
225228
cluster_kms_key_id = var.cluster_kms_key_id
226229
use_signed_images = var.use_signed_images
227230
image_signing_keys = var.image_signing_keys
@@ -244,6 +247,7 @@ module "oke" {
244247
# worker nsgs
245248
worker_nsgs = concat(var.worker_nsgs, [module.network.worker_nsg_id])
246249

250+
247251
# freeform_tags
248252
freeform_tags = var.freeform_tags["oke"]
249253

@@ -256,6 +260,35 @@ module "oke" {
256260
}
257261
}
258262

263+
#fss
264+
module "storage" {
265+
source = "./modules/storage"
266+
267+
# general oci parameters
268+
tenancy_id = var.tenancy_id
269+
compartment_id = var.compartment_id
270+
availability_domain = var.availability_domains["fss"]
271+
label_prefix = var.label_prefix
272+
273+
# FSS network information
274+
subnets = var.subnets
275+
vcn_id = module.vcn.vcn_id
276+
nat_route_id = module.vcn.nat_route_id
277+
278+
fss_mount_path = var.fss_mount_path
279+
280+
# Export set configuration
281+
max_fs_stat_bytes = var.max_fs_stat_bytes
282+
max_fs_stat_files = var.max_fs_stat_files
283+
284+
providers = {
285+
oci.home = oci.home
286+
}
287+
288+
count = var.create_fss == true ? 1 : 0
289+
290+
}
291+
259292
# extensions to oke
260293
module "extensions" {
261294
source = "./modules/extensions"
@@ -292,7 +325,7 @@ module "extensions" {
292325
# oke cluster parameters
293326
cluster_id = module.oke.cluster_id
294327
pods_cidr = var.pods_cidr
295-
use_encryption = var.use_encryption
328+
use_cluster_encryption = var.use_cluster_encryption
296329
cluster_kms_key_id = var.cluster_kms_key_id
297330
cluster_kms_dynamic_group_id = module.oke.cluster_kms_dynamic_group_id
298331

modules/extensions/iam.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ resource "oci_identity_policy" "operator_instance_principal_dynamic_group" {
1818
description = "policy to allow operator host to manage dynamic group"
1919
name = var.label_prefix == "none" ? "operator-instance-principal-dynamic-group-${substr(uuid(), 0, 8)}" : "${var.label_prefix}-operator-instance-principal-dynamic-group-${substr(uuid(), 0, 8)}"
2020
statements = ["Allow dynamic-group ${var.operator_dynamic_group} to use dynamic-groups in tenancy"]
21-
count = (var.use_encryption == true && var.create_bastion_host == true && var.enable_operator_instance_principal == true) ? 1 : 0
21+
count = (var.use_cluster_encryption == true && var.create_bastion_host == true && var.enable_operator_instance_principal == true) ? 1 : 0
2222
}
2323

2424
# 30s delay to allow policies to take effect globally
@@ -57,5 +57,5 @@ resource "null_resource" "update_dynamic_group" {
5757
]
5858
}
5959

60-
count = (var.use_encryption == true && var.create_bastion_host == true && var.bastion_state == "RUNNING" && var.enable_operator_instance_principal == true) ? 1 : 0
60+
count = (var.use_cluster_encryption == true && var.create_bastion_host == true && var.bastion_state == "RUNNING" && var.enable_operator_instance_principal == true) ? 1 : 0
6161
}

modules/extensions/locals.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,5 @@ locals {
2727

2828
post_provisioning_ops = var.create_bastion_host == true && var.bastion_state == "RUNNING" && var.create_operator == true && var.operator_state == "RUNNING" && var.enable_operator_instance_principal == true ? true : false
2929

30-
dynamic_group_rule_this_cluster = (var.use_encryption == true) ? "ALL {resource.type = 'cluster', resource.id = '${var.cluster_id}'}" : "null"
30+
dynamic_group_rule_this_cluster = (var.use_cluster_encryption == true) ? "ALL {resource.type = 'cluster', resource.id = '${var.cluster_id}'}" : "null"
3131
}

modules/extensions/templates.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ locals {
100100

101101
update_dynamic_group_template = templatefile("${path.module}/scripts/update_dynamic_group.template.sh",
102102
{
103-
dynamic_group_id = var.use_encryption == true ? var.cluster_kms_dynamic_group_id : "null"
103+
dynamic_group_id = var.use_cluster_encryption == true ? var.cluster_kms_dynamic_group_id : "null"
104104
dynamic_group_rule = local.dynamic_group_rule_this_cluster
105105
home_region = data.oci_identity_regions.home_region.regions[0].name
106106
}

modules/extensions/variables.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ variable "cluster_id" {}
5454
variable "pods_cidr" {}
5555

5656
# encryption
57-
variable "use_encryption" {
57+
variable "use_cluster_encryption" {
5858
type = bool
5959
}
6060

0 commit comments

Comments
 (0)