Skip to content
This repository was archived by the owner on Nov 24, 2023. It is now read-only.

Commit 20fdd09

Browse files
Roks-on-vpc repo developed by Jennifer, imported to use terraformibm-modules
1 parent 7be3e61 commit 20fdd09

File tree

6 files changed

+464
-0
lines changed

6 files changed

+464
-0
lines changed

examples/roks-on-vpc/README.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Module classic-free-cluster
2+
3+
This example is used to to provision an free IKS cluster on IBM Cloud Infrastructure - classic
4+
5+
## Example Usage
6+
```
7+
provider "ibm" {
8+
}
9+
10+
module "classic_free_cluster" {
11+
//Uncomment the following line to make the source point to registry level
12+
//source = "terraform-ibm-modules/cluster/ibm//modules/classic-free"
13+
14+
source = "../../modules/classic-free"
15+
16+
cluster_name = var.cluster_name
17+
worker_zone = var.worker_zone
18+
hardware = var.hardware
19+
create_timeout = var.create_timeout
20+
update_timeout = var.update_timeout
21+
delete_timeout = var.delete_timeout
22+
}
23+
```
24+
## NOTE:
25+
If we want to make use of a particular version of module, then set the "version" argument to respective module version.
26+
27+
28+
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
29+
## Inputs
30+
31+
| Name | Description | Type | Default | Required |
32+
|-----------------------------------|-------------------------------------------------------|--------|---------|----------|
33+
| cluster\_name | Name of the cluster | string | n/a | yes |
34+
| worker\_zone | The zone where the worker node is created. | string | n/a | yes |
35+
| hardware | The level of hardware isolation for your worker node. | string | n/a | yes |
36+
| create_timeout | Timeout duration for create | string | n/a | no |
37+
| update_timeout | Timeout duration for update | string | n/a | no |
38+
| delete_timeout | Timeout duration for delete | string | n/a | no |
39+
40+
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
41+
42+
## Usage
43+
44+
terraform apply

examples/roks-on-vpc/input.tfvars

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
3+
########## COS inputs ###########
4+
/*parameters = {
5+
service-endpoints = "private"
6+
}*/
7+

examples/roks-on-vpc/main.tf

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
locals {
2+
worker_zones = { for subnet in data.ibm_is_subnet.subnets : subnet.zone => { "subnet_id" = subnet.id } }
3+
4+
kms_config = [{
5+
instance_id = module.kms.kms_instance_guid
6+
crk_id = module.kms.kms_key_id
7+
private_endpoint = false
8+
},
9+
]
10+
}
11+
12+
##############################################################################
13+
# Resource Group
14+
##############################################################################
15+
16+
data ibm_resource_group resource_group {
17+
name = var.resource_group
18+
}
19+
20+
##############################################################################
21+
22+
##############################################################################
23+
# VPC Data
24+
#############################################################################
25+
26+
data ibm_is_vpc vpc {
27+
name = var.vpc_name
28+
}
29+
30+
#############################################################################
31+
# Get Subnet Data
32+
# > If the subnets cannot all be gotten by name, replace the `name`
33+
# field with the `identifier` field and get the subnets by ID instead
34+
# of by name.
35+
#############################################################################
36+
37+
data ibm_is_subnet subnets {
38+
count = length(var.subnet_names)
39+
name = var.subnet_names[count.index]
40+
}
41+
42+
##############################################################################
43+
# KMS
44+
##############################################################################
45+
46+
module kms {
47+
source = "terraform-ibm-modules/kms/ibm//modules/key-protect"
48+
49+
is_kp_instance_exist = false
50+
resource_group_id = data.ibm_resource_group.resource_group.id
51+
service_name = var.service_name
52+
location = var.location
53+
plan = "tiered-pricing"
54+
tags = var.kms_tags
55+
allowed_network_policy = var.allowed_network_policy
56+
key_name = var.key_name
57+
standard_key_type = var.standard_key_type
58+
force_delete = var.force_delete
59+
network_access_allowed = var.network_access_allowed
60+
}
61+
62+
##############################################################################
63+
64+
##############################################################################
65+
# COS Instance
66+
##############################################################################
67+
68+
module cos {
69+
source = "terraform-ibm-modules/cos/ibm//modules/instance"
70+
71+
service_name = var.cos_instance_name
72+
resource_group_id = data.ibm_resource_group.resource_group.id
73+
plan = var.plan
74+
region = var.region
75+
parameters = var.parameters
76+
create_timeout = var.create_timeout
77+
update_timeout = var.update_timeout
78+
delete_timeout = var.delete_timeout
79+
}
80+
81+
##############################################################################
82+
83+
##############################################################################
84+
# IAM Authorization
85+
##############################################################################
86+
87+
module "authorization_policy" {
88+
89+
source = "terraform-ibm-modules/iam/ibm//modules/service-authorization"
90+
91+
source_service_name = "cloud-object-storage"
92+
target_service_name = "kms"
93+
roles = var.iam_roles
94+
source_resource_instance_id = module.cos.cos_instance_id
95+
target_resource_instance_id = module.kms.kms_key_crn
96+
}
97+
98+
##############################################################################
99+
100+
##############################################################################
101+
# Container VPC Cluster
102+
##############################################################################
103+
104+
module "container_vpc_cluster" {
105+
106+
source = "terraform-ibm-modules/cluster/ibm//modules/vpc-openshift"
107+
108+
cluster_name = "${var.unique_id}-roks-cluster"
109+
vpc_id = data.ibm_is_vpc.vpc.id
110+
resource_group_id = data.ibm_resource_group.resource_group.id
111+
worker_pool_flavor = var.worker_pool_flavor
112+
worker_nodes_per_zone = var.worker_nodes_per_zone
113+
kube_version = var.kube_version
114+
tags = var.cluster_tags
115+
wait_till = var.wait_till
116+
cos_instance_crn = module.cos.cos_instance_id
117+
entitlement = var.entitlement
118+
worker_zones = local.worker_zones
119+
disable_public_service_endpoint = var.disable_public_service_endpoint
120+
kms_config = local.kms_config
121+
create_timeout = var.create_timeout
122+
update_timeout = var.update_timeout
123+
delete_timeout = var.delete_timeout
124+
125+
}
126+
127+
##############################################################################
128+
# Worker pool
129+
##############################################################################
130+
131+
132+
module "vpc_cluster_worker_pool" {
133+
134+
source = "terraform-ibm-modules/cluster/ibm//modules/configure-vpc-worker-pool"
135+
136+
for_each = { for wp in var.worker_pool_data : wp.pool_name => wp }
137+
worker_pool_name = each.value.pool_name
138+
flavor = each.value.machine_type
139+
worker_nodes_per_zone = each.value.workers_per_zone
140+
141+
cluster_name = module.container_vpc_cluster.vpc_openshift_cluster_id
142+
resource_group_id = data.ibm_resource_group.resource_group.id
143+
virtual_private_cloud = data.ibm_is_vpc.vpc.id
144+
worker_zones = local.worker_zones
145+
entitlement = var.entitlement
146+
}
147+

examples/roks-on-vpc/provider.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
provider "ibm" {
2+
3+
}

0 commit comments

Comments
 (0)