Skip to content

Commit 5ee54a6

Browse files
authored
Merge pull request #71112 from jneczypor/OSDOCS-9249
OSDOCS-9249: Create an installation guide for enabling autoscaling on a cluster with Terraform
2 parents a1b3f0a + 0773e76 commit 5ee54a6

File tree

4 files changed

+91
-42
lines changed

4 files changed

+91
-42
lines changed

modules/rosa-cluster-cluster-role-name-change.adoc

Lines changed: 13 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -10,62 +10,41 @@ endif::[]
1010
= Changing your cluster and role prefix name
1111
:source-highlighter: coderay
1212

13-
By default, the Terraform files used in this guide create a cluster that uses the naming convention of `rosa-` with six-random letters or numbers. This Terraform plan uses your cluster name to create your account role and Operator role prefixes.
13+
By default, the Terraform files used in this guide create a cluster that uses the naming convention of `rosa-` followed by six-random letters or numbers. Terraform uses your cluster name to create your account role and Operator role prefixes.
1414

15-
.Sample code
16-
[source,terminal]
17-
----
18-
# If cluster_name is not null, use that, otherwise generate a random cluster name
19-
cluster_name = coalesce(var.cluster_name, "rosa-${random_string.random_name.result}")
20-
----
21-
22-
This code snippet from the `main.tf` file shows that if you set a name for the `cluster_name` variable, that value will be used instead of a randomly-generated string.
15+
You can customize your cluster and role prefix name by editing your `main.tf` file. If you set a name for the `cluster_name` variable in the `main.tf` file, this value is used instead of a randomly-generated string.
2316

2417
.Procedure
2518

26-
You can set the cluster name three different ways:
19+
* Choose one of the following methods to set the cluster name:
2720
28-
. You export the name of your cluster in the command line by running the following command:
21+
** Export the name of your cluster in the command line by running the following command:
2922
+
3023
[source,terminal]
3124
----
3225
$ export TF_VAR_cluster_name=<your_cluster_name>
3326
----
34-
+
35-
After exporting this variable, you can build your Terraform cluster by running the following command:
36-
+
37-
[source,terminal]
38-
----
39-
$ terraform init && terraform apply
40-
----
4127

42-
. You set a `cluster_name` value in the `terraform.tfvars` file:
28+
** Set a `cluster_name` value in your `terraform.tfvars` file:
4329
+
44-
[source,console]
45-
----
46-
###############################
47-
# General Cluster Information #
48-
###############################
49-
50-
# You can choose any OpenShift version that is currently supported. Make sure to use X.Y.Z when setting your version.
51-
rosa_openshift_version = "4.14.8"
52-
cluster_name = "test-tf"
53-
----
54-
+
55-
After setting this variable in the `terraform.tfvars` file, you can build your Terraform cluster by running the following command:
30+
.`terraform.tfvars` file excerpt
5631
+
5732
[source,terminal]
5833
----
59-
$ terraform init && terraform apply
34+
cluster_name = "<your_cluster_name>"
6035
----
6136

62-
. You enter the cluster name when prompted in the terminal:
37+
** Enter the cluster name when prompted in the terminal:
6338
+
64-
[source,terraform]
39+
[source,terminal]
6540
----
6641
FORTHCOMING
6742
----
6843

6944
ifeval::["{context}" == "rosa-sts-creating-a-cluster-quickly-terraform"]
7045
:tf-defaults:
7146
endif::[]
47+
48+
ifndef::tf-defaults[]
49+
You are ready to initiate Terraform.
50+
endif::tf-defaults[]
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
// Module included in the following assemblies:
2+
//
3+
// * rosa_install_access_delete_clusters/rosa-sts-creating-a-cluster-with-customizations-terraform.adoc
4+
//
5+
ifeval::["{context}" == "rosa-sts-creating-a-cluster-quickly-terraform"]
6+
:tf-defaults:
7+
endif::[]
8+
:_content-type: PROCEDURE
9+
[id="rosa-cluster-enable-autoscaling-terraform_{context}"]
10+
= Enabling autoscaling
11+
:source-highlighter: coderay
12+
13+
By default, the Terraform files used in this guide create a cluster with autoscaling disabled. You can enable autoscaling by editing your `main.tf` and `terraform.tfvars` files.
14+
15+
Enabling autoscaling requires you to set a maximum and minimum replicas range using the 'max_replicas' and 'min_replicas' variables.
16+
17+
[IMPORTANT]
18+
====
19+
If autoscaling is enabled, you cannot configure the worker node replicas.
20+
====
21+
22+
.Procedure
23+
24+
. Edit your `main.tf` file so that `autoscaling_enabled`, `min_replicas`, and `max_replicas` point to your `terraform.tfvars` file.
25+
+
26+
.Excerpt of a `main.tf` file with autoscaling enabled
27+
+
28+
[source,terminal]
29+
----
30+
autoscaling_enabled = var.autoscaling_enabled
31+
replicas = local.worker_node_replicas
32+
min_replicas = var.min_replicas
33+
max_replicas = var.max_replicas
34+
----
35+
36+
. Enable autoscaling and set a maximum and minimum replicas range in your `terraform.tfvars` file.
37+
38+
+
39+
Maximum and minimum replicas must be in multiples of 3 for multiple availability zone clusters.
40+
+
41+
.Excerpt of a `terraform.tfvars` file with autoscaling enabled
42+
+
43+
[source,terminal]
44+
----
45+
autoscaling_enabled = "true"
46+
worker_node_replicas = null
47+
min_replicas = "<minimum_replicas>"
48+
max_replicas = "<maximum_replicas>"
49+
----
50+
+
51+
.Example input
52+
+
53+
[source,terminal]
54+
----
55+
autoscaling_enabled = "true"
56+
worker_node_replicas = null
57+
min_replicas = "6"
58+
max_replicas = "15"
59+
----
60+
61+
ifndef::tf-defaults[]
62+
You are ready to initiate Terraform.
63+
endif::tf-defaults[]
64+
65+
ifeval::["{context}" == "rosa-sts-creating-a-cluster-quickly-terraform"]
66+
:!tf-defaults:
67+
endif::[]

modules/rosa-sts-cluster-terraform-file-creation.adoc

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ ifndef::tf-defaults[]
164164
+
165165
[NOTE]
166166
====
167-
Copy and then edit this file _before_ running the command to build your cluster.
167+
Copy and edit this file _before_ running the command to build your cluster.
168168
====
169169
+
170170
[source,terminal]
@@ -360,7 +360,7 @@ ifndef::tf-defaults[]
360360
+
361361
[NOTE]
362362
====
363-
Copy and then edit this file _before_ running the command to build your cluster.
363+
Copy and edit this file _before_ running the command to build your cluster.
364364
====
365365
endif::tf-defaults[]
366366
+
@@ -479,13 +479,13 @@ module "vpc" {
479479
EOF
480480
----
481481

482-
. *Optional*: Create the `terraform.tfvars` file by running the following command:
482+
. Create the `terraform.tfvars` file by running the following command:
483483
+
484484
[NOTE]
485485
====
486-
You can use the `terraform.tfvars` file to change your variables in one place without touching the rest of your Terraform files. If you do not create a `terraform.tfvars` file, you will be prompted for the required variables during cluster creation.
486+
Use the `terraform.tfvars` file to change variables in one place without modifying the rest of your Terraform files when customizing your cluster. If you do not create a `terraform.tfvars` file, you are prompted for the required variables during cluster creation.
487487
488-
Copy and then edit this file _before_ running the command to build your cluster.
488+
Copy and edit this file _before_ running the command to build your cluster.
489489
====
490490
+
491491
[source,terminal]
@@ -533,8 +533,10 @@ EOF
533533
----
534534
endif::tf-defaults[]
535535

536+
ifdef::tf-defaults[]
536537
You are ready to initiate Terraform.
538+
endif::tf-defaults[]
537539

538540
ifeval::["{context}" == "rosa-sts-creating-a-cluster-quickly-terraform"]
539-
:tf-defaults:
541+
:!tf-defaults:
540542
endif::[]

rosa_install_access_delete_clusters/terraform/rosa-sts-creating-a-cluster-with-customizations-terraform.adoc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ The cluster creation process outlined below shows how to use Terraform to create
2828

2929
[NOTE]
3030
====
31-
Clusters are customized by editing the default `main.tf`, `variables.tf`, and `terraform.tfvar` files. Cluster customizations must be performed *before* cluster creation. To customize, copy the default Terraform file from the procedure below and make the desired changes.
31+
You edit the default `main.tf`, `variables.tf`, and `terraform.tfvars` files to customize a cluster. Cluster customizations must be performed before you create a cluster. To customize, copy the default Terraform file from the procedure below and make the desired changes.
3232
====
3333

3434
include::modules/rosa-sts-cluster-terraform-setup.adoc[leveloffset=+2]
@@ -37,9 +37,10 @@ include::modules/rosa-sts-cluster-terraform-file-creation.adoc[leveloffset=+2]
3737
[id="rosa-sts-creating-a-cluster-with-customizations-terraform-customizing"]
3838
== Terraform customization options
3939

40-
The following sections detail individual customizations you can add to your `main.tf`, `variables.tf`, and `terraform.tfvar` files.
40+
The following sections detail individual customizations you can add to your `main.tf`, `variables.tf`, and `terraform.tfvars` files.
4141

4242
include::modules/rosa-cluster-cluster-role-name-change.adoc[leveloffset=+2]
43+
include::modules/rosa-cluster-enable-autoscaling-terraform.adoc[leveloffset=+2]
4344
include::modules/rosa-sts-cluster-terraform-execute.adoc[leveloffset=+1]
4445
include::modules/rosa-sts-cluster-terraform-destroy.adoc[leveloffset=+1]
4546

0 commit comments

Comments
 (0)