-
Notifications
You must be signed in to change notification settings - Fork 1.8k
OSDOCS#10177: ROSA Terraform Tutorials and Enhancements #77742
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| ../../_attributes/ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| :_mod-docs-content-type: ASSEMBLY | ||
| [id="cloud-experts-cloud-experts-terraform-customization"] | ||
| = Tutorial: Customizing your cluster with Terraform | ||
| include::_attributes/attributes-openshift-dedicated.adoc[] | ||
| :context: cloud-experts-terraform-customization | ||
|
|
||
| toc::[] | ||
|
|
||
| You can customize your cluster with Terraform by using the following guides. This tutorial assumes that you have created your cluster using either xref:../../rosa_hcp/terraform/rosa-hcp-creating-a-cluster-quickly-terraform.adoc#rosa-hcp-creating-a-cluster-quickly-terraform[Creating a default ROSA cluster using Terraform] or xref:../../rosa_install_access_delete_clusters/terraform/rosa-classic-creating-a-cluster-quickly-terraform.adoc#rosa-classic-creating-a-cluster-quickly-terraform[Creating a default {rosa-classic} cluster using Terraform] or link:https://registry.terraform.io/providers/terraform-redhat/rhcs/latest/docs[Terraform registry documentation]. | ||
|
|
||
| include::modules/terraform-guide-env-variables.adoc[leveloffset=+1] | ||
|
|
||
| include::modules/terraform-guide-autoscaling.adoc[leveloffset=+1] | ||
|
|
||
| include::modules/terraform-guide-private-clusters.adoc[leveloffset=+1] | ||
|
|
||
| [role="_additional-resources"] | ||
| [id="additional-resources_cloud-experts-terraform-customization"] | ||
| .Additional resources | ||
|
|
||
| * See link:https://registry.terraform.io/providers/terraform-redhat/rhcs/latest/docs[Terraform registry documentation]. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| ../../images/ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| ../../modules/ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| ../../snippets/ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,7 @@ | ||
| // Module included in the following assemblies: | ||
| // | ||
| // * rosa_install_access_delete_clusters/rosa-classic-creating-a-cluster-quickly-terraform.adoc | ||
|
|
||
| :_content-type: PROCEDURE | ||
|
|
||
| [id="rosa-classic-cluster-terraform-file-creation_{context}"] | ||
| = Creating your Terraform files locally | ||
|
|
||
|
|
@@ -82,17 +80,11 @@ locals { | |
| resource "time_sleep" "wait_60_seconds" { | ||
| count = var.create_vpc ? 1 : 0 | ||
| depends_on = [module.vpc] | ||
| create_duration = "60s" | ||
| } | ||
|
|
||
| module "rosa-classic" { | ||
| source = "terraform-redhat/rosa-classic/rhcs" | ||
| version = "1.5.0" | ||
| cluster_name = local.cluster_name | ||
| openshift_version = var.openshift_version | ||
| account_role_prefix = local.cluster_name | ||
| operator_role_prefix = local.cluster_name | ||
| replicas = local.worker_node_replicas | ||
| aws_availability_zones = local.region_azs | ||
| create_oidc = true | ||
| private = var.private_cluster | ||
|
|
@@ -130,7 +122,6 @@ Copy and edit this file _before_ running the command to build your cluster. | |
| + | ||
| [source,terminal] | ||
| ---- | ||
| $ cat<<-EOF>variables.tf | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This part of the command is required for it to work |
||
| # | ||
| # Copyright (c) 2023 Red Hat, Inc. | ||
| # | ||
|
|
@@ -200,6 +191,7 @@ variable "aws_subnet_ids" { | |
| variable "private_cluster" { | ||
| type = bool | ||
| description = "If you want to create a private cluster, set this value to 'true'. If you want a publicly available cluster, set this value to 'false'." | ||
| default = "false" | ||
| } | ||
|
|
||
| #VPC Info | ||
|
|
@@ -247,7 +239,7 @@ variable "default_aws_tags" { | |
| EOF | ||
| ---- | ||
|
|
||
| . Create the `vpc.tf` file by running the following command: | ||
| . Create the vpc.tf file by running the following command: | ||
| + | ||
| [source,terminal] | ||
| ---- | ||
|
|
@@ -289,4 +281,4 @@ module "vpc" { | |
| EOF | ||
| ---- | ||
| + | ||
| You are ready to initiate Terraform. | ||
| You are ready to initiate Terraform. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -79,15 +79,10 @@ locals { | |
| # The network validator requires an additional 60 seconds to validate Terraform clusters. | ||
| resource "time_sleep" "wait_60_seconds" { | ||
| count = var.create_vpc ? 1 : 0 | ||
| depends_on = [module.vpc] | ||
| create_duration = "60s" | ||
| } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This curly brace is required for this to be a valid terraform file |
||
|
|
||
| module "rosa-hcp" { | ||
| source = "terraform-redhat/rosa-hcp/rhcs" | ||
| version = "1.6.3" | ||
| cluster_name = local.cluster_name | ||
| openshift_version = var.openshift_version | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This option is required for the module to work |
||
| account_role_prefix = local.cluster_name | ||
| operator_role_prefix = local.cluster_name | ||
| replicas = local.worker_node_replicas | ||
|
|
@@ -190,6 +185,7 @@ variable "aws_subnet_ids" { | |
| variable "private_cluster" { | ||
| type = bool | ||
| description = "If you want to create a private cluster, set this value to 'true'. If you want a publicly available cluster, set this value to 'false'." | ||
| default = false | ||
| } | ||
|
|
||
| #VPC Info | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| // Module included in the following assemblies: | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤖 [error] OpenShiftAsciiDoc.ModuleContainsContentType: Module is missing the '_mod-docs-content-type' variable. |
||
| // | ||
| // * cloud_experts_tutorials/terraform/cloud-experts-terraform-customization.adoc | ||
|
|
||
| :_mod-docs-content-type: PROCESS | ||
| [id="terraform-guide-autoscaling_{context}"] | ||
| = Enabling autoscaling on your cluster | ||
|
|
||
| In your `variables.tf` file, set the default value to `true`: | ||
|
|
||
| [source,terminal] | ||
| ---- | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this be empty? |
||
| ---- | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,67 @@ | ||||||
| // Module included in the following assemblies: | ||||||
| // | ||||||
| // * cloud_experts_tutorials/terraform/cloud-experts-terraform-customization.adoc | ||||||
|
|
||||||
| :_mod-docs-content-type: CONCEPT | ||||||
| [id="terraform-guide-env-variable_{context}"] | ||||||
| = Using environmental variables | ||||||
|
|
||||||
| You can use locally set variables to specify a value once and reuse that value later. | ||||||
|
|
||||||
| .Procedure | ||||||
|
|
||||||
| . Set an environment variable by running the following command: | ||||||
| + | ||||||
| [source,terminal] | ||||||
| ---- | ||||||
| $ export <1> = <2> | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Spaces between the variable name and value are not supported in bash, so probably better to not include the spaces here |
||||||
| VARIABLE_NAME="VARIABLE_VALUE" | ||||||
| ---- | ||||||
| + | ||||||
| Your variable name and value can be any string. For example, if you want to consistently refer to your cluster's name, you run the following commad: | ||||||
| + | ||||||
| .Example input | ||||||
| [source,terminal] | ||||||
| ---- | ||||||
| $ export CLUSTER_NAME="rosa-cluster" | ||||||
| ---- | ||||||
|
|
||||||
| . Confirm the environment variable by running the following: | ||||||
| + | ||||||
| [source,terminal] | ||||||
| ---- | ||||||
| $ echo $<variable_name> | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Again, maybe add a call out (1) here for "variable name" |
||||||
| ---- | ||||||
| + | ||||||
| .Example output | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Again, maybe show both example input and example output. |
||||||
| [source,terminal] | ||||||
| ---- | ||||||
| $ echo $CLUSTER_NAME | ||||||
| $ rosa-cluster | ||||||
| ---- | ||||||
|
|
||||||
| [id="terraform-guide-env-variable-table_{context}"] | ||||||
| == Examples of variables used for OpenShift resources | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
|
||||||
| Use this table as a guideline for your own environment. The table is not a comprehensive model of all possible environment variables. | ||||||
|
|
||||||
| [cols="1,1"] | ||||||
| |=== | ||||||
| |Example variable name| Description | ||||||
|
|
||||||
| |CLUSTER_NAME | ||||||
| |This is the text-based string that you use as the name of your cluster. | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
|
||||||
| |AWS_REGION | ||||||
| |This is text-based string is the AWS region that you want to use for your resource. | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
|
||||||
| |ACCOUNT_ROLES_PREFIX | ||||||
| | | ||||||
|
|
||||||
| | | ||||||
| | | ||||||
|
|
||||||
| |=== | ||||||
|
|
||||||
| [id="terraform-guide-env-variable-example_{context}"] | ||||||
| == Example workflow using environmental variables to create a ROSA cluster | ||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| // Module included in the following assemblies: | ||
| // | ||
| // * cloud_experts_tutorials/terraform/cloud-experts-terraform-customization.adoc | ||
|
|
||
| ifeval::["{context}" == "cloud-experts-terraform-customization"] | ||
| :enable-vpc: | ||
| endif::[] | ||
| :_mod-docs-content-type: CONCEPT | ||
| [id="terraform-guide-private-cluster_{context}"] | ||
| = Creating a private {hcp-title} cluster | ||
|
|
||
| . Run the following command in your terminal to create a private {hcp-title} cluster: | ||
| + | ||
| [source,terminal] | ||
| ---- | ||
| $ export TF_VAR_private_cluster="true" | ||
| ---- | ||
|
|
||
| include::snippets/terraform-apply.adoc[] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These two options are required for the module to work. Seems a bit weird to get rid of the other options as well