Skip to content

Commit 5a905b5

Browse files
Jordan-Williams2Jordan-Williams2
authored andcommitted
fix: update code
1 parent e7301f0 commit 5a905b5

File tree

10 files changed

+169
-24
lines changed

10 files changed

+169
-24
lines changed

chart/cloud-pak-deployer/templates/install-job.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,11 @@ spec:
7575
- '/cloud-pak-deployer/cp-deploy.sh vault set -vs cp4d_admin_cpd_{{ .Values.cluster_name }} -vsv {{ .Values.deployer.admin_password }} && /cloud-pak-deployer/cp-deploy.sh env apply -vvvv {{ .Values.deployer.accept_license_flag }}'
7676
resources:
7777
limits:
78-
cpu: 200m
78+
cpu: 250m
7979
memory: 512Mi
8080
requests:
81-
cpu: 10m
82-
memory: 64Mi
81+
cpu: 100m
82+
memory: 256Mi
8383
serviceAccount: {{ .Values.deployer.prefix }}-sa
8484
volumes:
8585
- name: config-volume

chart/cloud-pak-deployer/templates/uninstall-job.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,11 @@ spec:
6666
- /cloud-pak-deployer/scripts/cp4d/cp4d-delete-instance.sh cpd <<< "y"
6767
resources:
6868
limits:
69-
cpu: 200m
69+
cpu: 250m
7070
memory: 512Mi
7171
requests:
72-
cpu: 10m
73-
memory: 64Mi
72+
cpu: 100m
73+
memory: 256Mi
7474
restartPolicy: Never
7575
securityContext:
7676
runAsUser: 0

examples/basic/main.tf

Lines changed: 90 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,106 @@
11
##############################################################################
2-
# ROKS Landing zone
2+
locals {
3+
cluster_name = var.existing_cluster_name != null ? var.existing_cluster_name : module.ocp_base[0].cluster_name
4+
cluster_rg_id = var.existing_cluster_rg_id != null ? var.existing_cluster_rg_id : module.resource_group[0].resource_group_id
5+
}
6+
###############################################################################
7+
8+
##############################################################################
9+
# Resource Group
310
##############################################################################
411

5-
module "roks_landing_zone" {
6-
source = "git::https://github.com/terraform-ibm-modules/terraform-ibm-landing-zone.git//patterns/roks-quickstart?ref=v6.6.1"
7-
ibmcloud_api_key = var.ibmcloud_api_key
8-
prefix = var.prefix
9-
region = var.region
10-
resource_tags = var.resource_tags
12+
module "resource_group" {
13+
count = var.existing_cluster_rg_id == null ? 1 : 0
14+
source = "terraform-ibm-modules/resource-group/ibm"
15+
version = "1.1.6"
16+
# if an existing resource group is not set (null) create a new one using prefix
17+
resource_group_name = "${var.prefix}-resource-group"
18+
}
19+
20+
########################################################################################################################
21+
# VPC + Subnet + Public Gateway
22+
#
23+
# NOTE: This is a very simple VPC with single subnet in a single zone with a public gateway enabled, that will allow
24+
# all traffic ingress/egress by default.
25+
# For production use cases this would need to be enhanced by adding more subnets and zones for resiliency, and
26+
# ACLs/Security Groups for network security.
27+
########################################################################################################################
28+
29+
resource "ibm_is_vpc" "vpc" {
30+
name = "${var.prefix}-vpc"
31+
resource_group = local.cluster_rg_id
32+
address_prefix_management = "auto"
33+
tags = var.resource_tags
34+
}
35+
36+
resource "ibm_is_public_gateway" "gateway" {
37+
name = "${var.prefix}-gateway-1"
38+
vpc = ibm_is_vpc.vpc.id
39+
resource_group = local.cluster_rg_id
40+
zone = "${var.region}-1"
41+
}
42+
43+
resource "ibm_is_subnet" "subnet_zone_1" {
44+
name = "${var.prefix}-subnet-1"
45+
vpc = ibm_is_vpc.vpc.id
46+
resource_group = local.cluster_rg_id
47+
zone = "${var.region}-1"
48+
total_ipv4_address_count = 256
49+
public_gateway = ibm_is_public_gateway.gateway.id
50+
}
51+
52+
########################################################################################################################
53+
# OCP VPC cluster (single zone)
54+
########################################################################################################################
55+
56+
locals {
57+
cluster_vpc_subnets = {
58+
default = [
59+
{
60+
id = ibm_is_subnet.subnet_zone_1.id
61+
cidr_block = ibm_is_subnet.subnet_zone_1.ipv4_cidr_block
62+
zone = ibm_is_subnet.subnet_zone_1.zone
63+
}
64+
]
65+
}
66+
67+
worker_pools = [
68+
{
69+
subnet_prefix = "default"
70+
pool_name = "default" # ibm_container_vpc_cluster automatically names default pool "default" (See https://github.com/IBM-Cloud/terraform-provider-ibm/issues/2849)
71+
machine_type = "bx2.16x64"
72+
operating_system = "REDHAT_8_64"
73+
workers_per_zone = 3 # minimum of 2 is allowed when using single zone
74+
}
75+
]
76+
}
77+
78+
module "ocp_base" {
79+
count = var.existing_cluster_name == null ? 1 : 0
80+
source = "terraform-ibm-modules/base-ocp-vpc/ibm"
81+
version = "3.41.7"
82+
resource_group_id = local.cluster_rg_id
83+
region = var.region
84+
tags = var.resource_tags
85+
cluster_name = var.prefix
86+
force_delete_storage = true
87+
vpc_id = ibm_is_vpc.vpc.id
88+
vpc_subnets = local.cluster_vpc_subnets
89+
worker_pools = local.worker_pools
90+
disable_outbound_traffic_protection = true # set as True to enable outbound traffic
1191
}
1292

1393
##############################################################################
1494
# Deploy cloudpak_data
1595
##############################################################################
96+
1697
module "cloudpak_data" {
1798
source = "../../solutions/deploy"
1899
ibmcloud_api_key = var.ibmcloud_api_key
19100
prefix = var.prefix
20101
region = var.region
21-
cluster_name = module.roks_landing_zone.workload_cluster_id
102+
cluster_name = local.cluster_name
103+
cluster_rg_id = local.cluster_rg_id
22104
cloud_pak_deployer_image = "quay.io/cloud-pak-deployer/cloud-pak-deployer"
23105
cpd_admin_password = "Passw0rd" #pragma: allowlist secret
24106
cpd_entitlement_key = "entitlementKey"

examples/basic/variables.tf

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,19 @@ variable "install_odf_cluster_addon" {
3636
type = bool
3737
default = false
3838
}
39+
40+
variable "existing_cluster_name" {
41+
description = "Existing cluster name"
42+
type = string
43+
default = "ocp-cp4d-v2"
44+
validation {
45+
condition = can(regex("^[a-z][a-z0-9-]{0,12}[a-z0-9]$", var.existing_cluster_name))
46+
error_message = "Existing cluster name must begin with a letter and contain only lowercase letters, numbers, and - characters. Existing cluster names must end with a lowercase letter or number and be 13 or fewer characters."
47+
}
48+
}
49+
50+
variable "existing_cluster_rg_id" {
51+
description = "Existing resource group id"
52+
type = string
53+
default = null
54+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
apiVersion: v1
2+
clusters:
3+
- cluster:
4+
server: https://c106-e.us-south.containers.cloud.ibm.com:31203
5+
name: ocp-cp4d-v2/d04fmmsd0trb3gtjs3k0
6+
- cluster:
7+
server: https://c106-e.us-south.containers.cloud.ibm.com:31203
8+
name: c106-e-us-south-containers-cloud-ibm-com:31203
9+
contexts:
10+
- context:
11+
cluster: ocp-cp4d-v2/d04fmmsd0trb3gtjs3k0
12+
namespace: default
13+
user: ""
14+
name: ocp-cp4d-v2/d04fmmsd0trb3gtjs3k0
15+
- context:
16+
cluster: c106-e-us-south-containers-cloud-ibm-com:31203
17+
namespace: default
18+
user: IAM#[email protected]/c106-e-us-south-containers-cloud-ibm-com:31203
19+
name: default/c106-e-us-south-containers-cloud-ibm-com:31203/IAM#[email protected]
20+
current-context: default/c106-e-us-south-containers-cloud-ibm-com:31203/IAM#[email protected]
21+
kind: Config
22+
preferences: {}
23+
users:
24+
- name: IAM#[email protected]/c106-e-us-south-containers-cloud-ibm-com:31203
25+
user:
26+
token: sha256~3zsiX1Et5jdtmk0kycFC_j52OcuYi0hMDLz66vGlyqo

solutions/deploy/README.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ You need the following permissions to run this module:
105105
| <a name="requirement_external"></a> [external](#requirement\_external) | >= 2.3.4 |
106106
| <a name="requirement_helm"></a> [helm](#requirement\_helm) | >= 2.8.0, <3.0.0 |
107107
| <a name="requirement_ibm"></a> [ibm](#requirement\_ibm) | 1.71.3 |
108+
| <a name="requirement_shell"></a> [shell](#requirement\_shell) | 1.7.10 |
108109

109110
### Modules
110111

@@ -124,18 +125,20 @@ You need the following permissions to run this module:
124125
| [external_external.schematics](https://registry.terraform.io/providers/hashicorp/external/latest/docs/data-sources/external) | data source |
125126
| [ibm_container_cluster_config.cluster_config](https://registry.terraform.io/providers/ibm-cloud/ibm/1.71.3/docs/data-sources/container_cluster_config) | data source |
126127
| [ibm_container_vpc_cluster.cluster_info](https://registry.terraform.io/providers/ibm-cloud/ibm/1.71.3/docs/data-sources/container_vpc_cluster) | data source |
128+
| [ibm_iam_auth_token.tokendata](https://registry.terraform.io/providers/ibm-cloud/ibm/1.71.3/docs/data-sources/iam_auth_token) | data source |
127129

128130
### Inputs
129131

130132
| Name | Description | Type | Default | Required |
131133
|------|-------------|------|---------|:--------:|
132134
| <a name="input_cloud_pak_deployer_image"></a> [cloud\_pak\_deployer\_image](#input\_cloud\_pak\_deployer\_image) | Cloud Pak Deployer image to use. If `null`, the image will be built using Code Engine. | `string` | `null` | no |
133-
| <a name="input_cloud_pak_deployer_release"></a> [cloud\_pak\_deployer\_release](#input\_cloud\_pak\_deployer\_release) | Release of Cloud Pak Deployer version to use. View releases at: https://github.com/IBM/cloud-pak-deployer/releases. | `string` | `"v3.1.2"` | no |
134-
| <a name="input_cloud_pak_deployer_secret"></a> [cloud\_pak\_deployer\_secret](#input\_cloud\_pak\_deployer\_secret) | Secret for accessing the Cloud Pak Deployer image. If `null`, a default secret will be created. | <pre>object({<br/> username = string<br/> password = string<br/> server = string<br/> email = string<br/> })</pre> | `null` | no |
135-
| <a name="input_cluster_name"></a> [cluster\_name](#input\_cluster\_name) | Name of the OpenShift cluster. | `string` | n/a | yes |
135+
| <a name="input_cloud_pak_deployer_release"></a> [cloud\_pak\_deployer\_release](#input\_cloud\_pak\_deployer\_release) | Release of Cloud Pak Deployer version to use. View releases at: https://github.com/IBM/cloud-pak-deployer/releases. | `string` | `"v3.1.3"` | no |
136+
| <a name="input_cloud_pak_deployer_secret"></a> [cloud\_pak\_deployer\_secret](#input\_cloud\_pak\_deployer\_secret) | Secret for accessing the Cloud Pak Deployer image. If `null`, a default secret will be created # pragma: allowlist secret. | <pre>object({<br/> username = string<br/> password = string<br/> server = string<br/> email = string<br/> })</pre> | `null` | no |
137+
| <a name="input_cluster_name"></a> [cluster\_name](#input\_cluster\_name) | Name of Red Hat OpenShift cluster to install watsonx onto | `string` | n/a | yes |
138+
| <a name="input_cluster_rg_id"></a> [cluster\_rg\_id](#input\_cluster\_rg\_id) | Resource group id of the cluster | `string` | n/a | yes |
136139
| <a name="input_code_engine_project_id"></a> [code\_engine\_project\_id](#input\_code\_engine\_project\_id) | If you want to use an existing project, you can pass the code engine project ID and the Cloud Pak Deployer build will be built within the existing project instead of creating a new one. | `string` | `null` | no |
137140
| <a name="input_code_engine_project_name"></a> [code\_engine\_project\_name](#input\_code\_engine\_project\_name) | If the variable cloud\_pak\_deployer\_image is null, it will build the image with code engine and store it within a private ICR registry. Provide a name if you want to set the name. If not defined, default will be `{prefix}-cpd-{random-suffix}`. | `string` | `null` | no |
138-
| <a name="input_cpd_accept_license"></a> [cpd\_accept\_license](#input\_cpd\_accept\_license) | When set to 'true', it is understood that the user has read the terms of the Cloud Pak license(s) and agrees to the terms outlined. | `bool` | `false` | no |
141+
| <a name="input_cpd_accept_license"></a> [cpd\_accept\_license](#input\_cpd\_accept\_license) | When set to 'true', it is understood that the user has read the terms of the Cloud Pak license(s) and agrees to the terms outlined. | `bool` | `true` | no |
139142
| <a name="input_cpd_admin_password"></a> [cpd\_admin\_password](#input\_cpd\_admin\_password) | Password for the Cloud Pak for Data admin user. | `string` | n/a | yes |
140143
| <a name="input_cpd_entitlement_key"></a> [cpd\_entitlement\_key](#input\_cpd\_entitlement\_key) | Cloud Pak for Data entitlement key for access to the IBM Entitled Registry. Can be fetched from https://myibm.ibm.com/products-services/containerlibrary. | `string` | n/a | yes |
141144
| <a name="input_cpd_version"></a> [cpd\_version](#input\_cpd\_version) | Cloud Pak for Data version to install. Only version 5.x.x is supported | `string` | `"5.0.3"` | no |

solutions/deploy/main.tf

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ locals {
1010
}
1111
}
1212

13-
# Retrieve the OpenShift cluster info
13+
# Retrieve the openshift cluster info
1414
data "ibm_container_vpc_cluster" "cluster_info" {
15-
name = var.cluster_name
15+
name = var.cluster_name
16+
resource_group_id = var.cluster_rg_id
1617
}
1718

1819
module "build_cpd_image" {

solutions/deploy/providers.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@ data "ibm_container_cluster_config" "cluster_config" {
99
config_dir = local.kube_config_dir
1010
}
1111

12+
data "ibm_iam_auth_token" "tokendata" {}
13+
14+
provider "shell" {
15+
sensitive_environment = {
16+
TOKEN = data.ibm_iam_auth_token.tokendata.iam_access_token
17+
}
18+
}
19+
1220
provider "helm" {
1321
kubernetes {
1422
host = data.ibm_container_cluster_config.cluster_config.host

solutions/deploy/variables.tf

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@ variable "cloud_pak_deployer_image" {
5353
variable "cloud_pak_deployer_release" {
5454
description = "Release of Cloud Pak Deployer version to use. View releases at: https://github.com/IBM/cloud-pak-deployer/releases."
5555
type = string
56-
default = "v3.1.2"
56+
default = "v3.1.3"
5757
}
5858

5959
variable "cloud_pak_deployer_secret" {
60-
description = "Secret for accessing the Cloud Pak Deployer image. If `null`, a default secret will be created."
60+
description = "Secret for accessing the Cloud Pak Deployer image. If `null`, a default secret will be created # pragma: allowlist secret."
6161
type = object({
6262
username = string
6363
password = string
@@ -68,7 +68,12 @@ variable "cloud_pak_deployer_secret" {
6868
}
6969

7070
variable "cluster_name" {
71-
description = "Name of the OpenShift cluster."
71+
description = "Name of Red Hat OpenShift cluster to install watsonx onto"
72+
type = string
73+
}
74+
75+
variable "cluster_rg_id" {
76+
description = "Resource group id of the cluster"
7277
type = string
7378
}
7479

@@ -119,7 +124,7 @@ variable "odf_config" {
119124
variable "cpd_accept_license" {
120125
description = "When set to 'true', it is understood that the user has read the terms of the Cloud Pak license(s) and agrees to the terms outlined."
121126
type = bool
122-
default = false
127+
default = true
123128
}
124129

125130
variable "cpd_admin_password" {

solutions/deploy/version.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,9 @@ terraform {
1313
source = "hashicorp/helm"
1414
version = ">= 2.8.0, <3.0.0"
1515
}
16+
shell = {
17+
source = "scottwinkler/shell"
18+
version = "1.7.10"
19+
}
1620
}
1721
}

0 commit comments

Comments
 (0)