Skip to content

Commit 9d8366d

Browse files
committed
Update Blog “scale-kubernetes-clusters-using-hpe-greenlake-terraform-provider”
1 parent 6d2ab46 commit 9d8366d

File tree

2 files changed

+103
-85
lines changed

2 files changed

+103
-85
lines changed

content/blog/scale-kubernetes-clusters-using-hpe-greenlake-terraform-provider.md

Lines changed: 103 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: Scale Kubernetes Clusters using HPE GreenLake Terraform Provider
2+
title: Update Kubernetes Clusters using HPE GreenLake Terraform Provider
33
date: 2023-05-11T09:24:47.589Z
44
author: Tanushi Agarwal
55
authorimage: /img/Avatar1.svg
@@ -11,9 +11,9 @@ IaC or Infrastructure as code is an practice of automating the process of managi
1111
1212
As the part of upgrade, the following 3 scenarios are supported --
1313

14-
1. Scaling of a cluster's worker nodes. Please refer blog post [Scale Kubernetes Clusters using HPE GreenLake Terraform Provider](https://developer.hpe.com/blog/scale-kubernetes-cluster-using-hpe-greenlake-terraform-provider/) to check out scaling options available for woker nodes.
15-
2. Upgrade the kubernetes version of the cluster. Covered in this blog.
16-
3. Upgrade the OS version of the worker nodes inside a cluster. Covered in this blog.
14+
1. Scaling of a cluster's worker nodes. Please refer blog post [Scale Kubernetes Clusters using HPE GreenLake Terraform Provider](https://developer.hpe.com/blog/scale-kubernetes-cluster-using-hpe-greenlake-terraform-provider/) to check out scaling options available for woker nodes.
15+
2. Upgrade the kubernetes version of the cluster. Covered in this blog.
16+
3. Upgrade the OS version of the worker nodes inside a cluster. Covered in this blog.
1717

1818
# Prerequisite
1919

@@ -70,50 +70,50 @@ resource hpegl_caas_cluster test {
7070

7171
For Kubernetes version upgrade, we need to specify the new version of kubernetes that is available for upgrade in the resources block.
7272

73-
1. kubernetes_version: *Use the Kubernetes version that pops up on the cluster details page in the UI*
73+
1. kubernetes_version: *Use the Kubernetes version that pops up on the cluster details page in the UI*
7474

75+
![UI shows new versions that are available](/img/blog1.jpg)
7576

7677
Below is the reference Terraform configuration for updating the cluster's kubernetes version.
77-
78-
```hcl
78+
79+
```hcl
7980
terraform {
80-
required_providers {
81-
hpegl = {
82-
source = "hpe/hpegl"
83-
version = ">= 0.2.2"
84-
}
85-
}
81+
required_providers {
82+
hpegl = {
83+
source = "hpe/hpegl"
84+
version = ">= 0.2.2"
85+
}
86+
}
8687
}
87-
88+
8889
provider hpegl {
89-
caas {
90-
}
90+
caas {
91+
}
9192
}
92-
93+
9394
variable "HPEGL_SPACE" {
94-
type = string
95+
type = string
9596
}
96-
97+
9798
data "hpegl_caas_site" "blr" {
98-
name = "BLR"
99-
space_id = var.HPEGL_SPACE
100-
}
101-
99+
name = "BLR"
100+
space_id = var.HPEGL_SPACE
101+
}
102+
102103
data "hpegl_caas_cluster_blueprint" "bp" {
103-
name = "demo"
104-
site_id = data.hpegl_caas_site.blr.id
104+
name = "demo"
105+
site_id = data.hpegl_caas_site.blr.id
105106
}
106107
107108
resource hpegl_caas_cluster test {
108-
name = "tf-test"
109-
blueprint_id = data.hpegl_caas_cluster_blueprint.bp.id
110-
site_id = data.hpegl_caas_site.blr.id
111-
space_id = var.HPEGL_SPACE
112-
kubernetes_version = "1.23.9-hpe1"
109+
name = "tf-test"
110+
blueprint_id = data.hpegl_caas_cluster_blueprint.bp.id
111+
site_id = data.hpegl_caas_site.blr.id
112+
space_id = var.HPEGL_SPACE
113+
kubernetes_version = "1.23.13-hpe1"
113114
}
114115
```
115116

116-
117117
# Ready to Terraform plan
118118

119119
Terraform plan is a dry run that lets you preview the changes that Terraform plans to make to your infrastructure based on the data you provide in your Terraform file. To see this, run **terraform plan**
@@ -131,6 +131,7 @@ Terraform will perform the following actions:
131131
# hpegl_caas_cluster.test will be updated in-place
132132
~ resource "hpegl_caas_cluster" "test" {
133133
id = "a32fabb9-7c19-42d1-9a38-ebf122810c0a"
134+
~ kubernetes_version = "1.22.9-hpe1" -> "1.23.13-hpe1"
134135
name = "tf-test"
135136
# (17 unchanged attributes hidden)
136137
}
@@ -140,7 +141,6 @@ Plan: 0 to add, 1 to change, 0 to destroy.
140141
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
141142

142143
Note: You didn't use the -out option to save this plan, so Terraform can't guarantee to take exactly these actions if you run "terraform apply" now.
143-
144144
```
145145

146146
# Ready to Terraform apply
@@ -160,14 +160,9 @@ Terraform will perform the following actions:
160160
# hpegl_caas_cluster.test will be updated in-place
161161
~ resource "hpegl_caas_cluster" "test" {
162162
id = "a32fabb9-7c19-42d1-9a38-ebf122810c0a"
163+
~ kubernetes_version = "1.22.9-hpe1" -> "1.23.13-hpe1"
163164
name = "tf-test"
164165
# (17 unchanged attributes hidden)
165-
166-
+ worker_nodes {
167-
+ count = 1
168-
+ machine_blueprint_id = "0ac21c99-2fdb-491d-a590-a5016690b80b"
169-
+ name = "test-node-pool"
170-
}
171166
}
172167

173168
Plan: 0 to add, 1 to change, 0 to destroy.
@@ -190,74 +185,83 @@ hpegl_caas_cluster.test: Still modifying... [id=a32fabb9-7c19-42d1-9a38-ebf12281
190185
hpegl_caas_cluster.test: Still modifying... [id=a32fabb9-7c19-42d1-9a38-ebf122810c0a, 15m10s elapsed]
191186
hpegl_caas_cluster.test: Still modifying... [id=a32fabb9-7c19-42d1-9a38-ebf122810c0a, 17m10s elapsed]
192187
hpegl_caas_cluster.test: Still modifying... [id=a32fabb9-7c19-42d1-9a38-ebf122810c0a, 19m10s elapsed]
193-
hpegl_caas_cluster.test: Modifications complete after 19m18s [id=a32fabb9-7c19-42d1-9a38-ebf122810c0a]
188+
hpegl_caas_cluster.test: Still modifying... [id=a32fabb9-7c19-42d1-9a38-ebf122810c0a, 21m10s elapsed]
189+
hpegl_caas_cluster.test: Still modifying... [id=a32fabb9-7c19-42d1-9a38-ebf122810c0a, 23m10s elapsed]
190+
hpegl_caas_cluster.test: Still modifying... [id=a32fabb9-7c19-42d1-9a38-ebf122810c0a, 25m10s elapsed]
191+
hpegl_caas_cluster.test: Still modifying... [id=a32fabb9-7c19-42d1-9a38-ebf122810c0a, 27m10s elapsed]
192+
hpegl_caas_cluster.test: Still modifying... [id=a32fabb9-7c19-42d1-9a38-ebf122810c0a, 29m10s elapsed]
193+
hpegl_caas_cluster.test: Still modifying... [id=a32fabb9-7c19-42d1-9a38-ebf122810c0a, 31m10s elapsed]
194+
hpegl_caas_cluster.test: Still modifying... [id=a32fabb9-7c19-42d1-9a38-ebf122810c0a, 33m10s elapsed]
195+
hpegl_caas_cluster.test: Still modifying... [id=a32fabb9-7c19-42d1-9a38-ebf122810c0a, 35m10s elapsed]
196+
hpegl_caas_cluster.test: Modifications complete after 35m18s [id=a32fabb9-7c19-42d1-9a38-ebf122810c0a]
194197

195198
Apply complete! Resources: 0 added, 1 changed, 0 destroyed.
196199
```
197200

198201
# OS Version upgrade
199-
202+
200203
For OS version upgrade, we need to specify the new version of OS Image that is available for upgrade & the name of the OS Image in the worker node block.
201204
**Note**: The OS version is specific to a worker node pool. All the nodes in the worker node pool will be updated to the same OS version. However, we can have different node pool supporting different OS versions.
202205

203206
The worker node block consist of following fields -
204-
1. **name**: *The name of the worker nodepool. If you wish to update default or existing worker node pool, enter the name of that node pool or you can create a new node pool by specifying a new name.*
205-
2. **machine_blueprint_id**: *Fill in the ID for the machine blueprint that is already present in HPE GreenLake Central for your tenant. Use the machine blueprint data source to retrieve the machine blueprint ID.*
206-
3. **count**: *Add the number of nodes to be present as part of this node pool. We can scale up & down by updating the count value here.*
207+
208+
1. **name**: *The name of the worker nodepool. If you wish to update default or existing worker node pool, enter the name of that node pool or you can create a new node pool by specifying a new name.*
209+
2. **machine_blueprint_id**: *Fill in the ID for the machine blueprint that is already present in HPE GreenLake Central for your tenant. Use the machine blueprint data source to retrieve the machine blueprint ID.*
210+
3. **count**: *Add the number of nodes to be present as part of this node pool. We can scale up & down by updating the count value here.*
207211
4. **os_image**: *The name of the OS image. Use the machine blueprint data source to retrieve the name of OS image*
208212
5. **os_version**: *The version to be upgraded to. We can get this version in the UI. Whenever there is a new version present, UI will pop up a banner mentioning the new version.*
209213

210214
Below is the reference Terraform configuration for updating the worker nodepool's OS version.
211215

212-
```hcl
216+
```hcl
213217
terraform {
214-
required_providers {
215-
hpegl = {
216-
source = "hpe/hpegl"
217-
version = ">= 0.2.2"
218-
}
219-
}
218+
required_providers {
219+
hpegl = {
220+
source = "hpe/hpegl"
221+
version = ">= 0.2.2"
222+
}
223+
}
220224
}
221-
225+
222226
provider hpegl {
223-
caas {
224-
}
227+
caas {
228+
}
225229
}
226-
230+
227231
variable "HPEGL_SPACE" {
228-
type = string
232+
type = string
229233
}
230-
234+
231235
data "hpegl_caas_site" "blr" {
232-
name = "BLR"
233-
space_id = var.HPEGL_SPACE
234-
}
235-
236+
name = "BLR"
237+
space_id = var.HPEGL_SPACE
238+
}
239+
236240
data "hpegl_caas_cluster_blueprint" "bp" {
237-
name = "demo"
238-
site_id = data.hpegl_caas_site.blr.id
241+
name = "demo"
242+
site_id = data.hpegl_caas_site.blr.id
239243
}
240-
244+
241245
data "hpegl_caas_machine_blueprint" "standard_worker" {
242-
name = "standard-worker"
243-
site_id = "data.hpegl_caas_site.blr.id"
246+
name = "standard-worker"
247+
site_id = "data.hpegl_caas_site.blr.id"
244248
}
245249
246250
resource hpegl_caas_cluster test {
247-
name = "tf-test"
248-
blueprint_id = data.hpegl_caas_cluster_blueprint.bp.id
249-
site_id = data.hpegl_caas_site.blr.id
250-
space_id = var.HPEGL_SPACE
251-
251+
name = "tf-test"
252+
blueprint_id = data.hpegl_caas_cluster_blueprint.bp.id
253+
site_id = data.hpegl_caas_site.blr.id
254+
space_id = var.HPEGL_SPACE
255+
252256
worker_nodes {
253-
name = "test-node-pool"
254-
machine_blueprint_id = data.hpegl_caas_machine_blueprint.standard_worker.id
255-
count = "1"
256-
os_image = "sles-custom"
257-
os_version = "15.3"
258-
}
257+
name = "test-node-pool"
258+
machine_blueprint_id = data.hpegl_caas_machine_blueprint.standard_worker.id
259+
count = "1"
260+
os_image = "sles-custom"
261+
os_version = "15.3"
262+
}
259263
}
260-
```
264+
```
261265

262266
# Ready to Terraform plan
263267

@@ -277,7 +281,7 @@ Terraform will perform the following actions:
277281
~ resource "hpegl_caas_cluster" "test" {
278282
id = "a32fabb9-7c19-42d1-9a38-ebf122810c0a"
279283
name = "tf-test"
280-
# (17 unchanged attributes hidden)
284+
# (18 unchanged attributes hidden)
281285

282286
+ worker_nodes {
283287
+ count = 1
@@ -293,7 +297,6 @@ Plan: 0 to add, 1 to change, 0 to destroy.
293297
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
294298

295299
Note: You didn't use the -out option to save this plan, so Terraform can't guarantee to take exactly these actions if you run "terraform apply" now.
296-
297300
```
298301

299302
# Ready to Terraform apply
@@ -320,6 +323,8 @@ Terraform will perform the following actions:
320323
+ count = 1
321324
+ machine_blueprint_id = "0ac21c99-2fdb-491d-a590-a5016690b80b"
322325
+ name = "test-node-pool"
326+
+ os_image = "sles-custom"
327+
+ os_version = "15.3"
323328
}
324329
}
325330

@@ -343,7 +348,19 @@ hpegl_caas_cluster.test: Still modifying... [id=a32fabb9-7c19-42d1-9a38-ebf12281
343348
hpegl_caas_cluster.test: Still modifying... [id=a32fabb9-7c19-42d1-9a38-ebf122810c0a, 15m10s elapsed]
344349
hpegl_caas_cluster.test: Still modifying... [id=a32fabb9-7c19-42d1-9a38-ebf122810c0a, 17m10s elapsed]
345350
hpegl_caas_cluster.test: Still modifying... [id=a32fabb9-7c19-42d1-9a38-ebf122810c0a, 19m10s elapsed]
346-
hpegl_caas_cluster.test: Modifications complete after 19m18s [id=a32fabb9-7c19-42d1-9a38-ebf122810c0a]
351+
hpegl_caas_cluster.test: Still modifying... [id=a32fabb9-7c19-42d1-9a38-ebf122810c0a, 21m10s elapsed]
352+
hpegl_caas_cluster.test: Still modifying... [id=a32fabb9-7c19-42d1-9a38-ebf122810c0a, 23m10s elapsed]
353+
hpegl_caas_cluster.test: Still modifying... [id=a32fabb9-7c19-42d1-9a38-ebf122810c0a, 25m10s elapsed]
354+
hpegl_caas_cluster.test: Still modifying... [id=a32fabb9-7c19-42d1-9a38-ebf122810c0a, 27m10s elapsed]
355+
hpegl_caas_cluster.test: Still modifying... [id=a32fabb9-7c19-42d1-9a38-ebf122810c0a, 29m10s elapsed]
356+
hpegl_caas_cluster.test: Still modifying... [id=a32fabb9-7c19-42d1-9a38-ebf122810c0a, 31m10s elapsed]
357+
hpegl_caas_cluster.test: Still modifying... [id=a32fabb9-7c19-42d1-9a38-ebf122810c0a, 33m10s elapsed]
358+
hpegl_caas_cluster.test: Still modifying... [id=a32fabb9-7c19-42d1-9a38-ebf122810c0a, 35m10s elapsed]
359+
hpegl_caas_cluster.test: Still modifying... [id=a32fabb9-7c19-42d1-9a38-ebf122810c0a, 37m10s elapsed]
360+
hpegl_caas_cluster.test: Still modifying... [id=a32fabb9-7c19-42d1-9a38-ebf122810c0a, 39m10s elapsed]
361+
hpegl_caas_cluster.test: Still modifying... [id=a32fabb9-7c19-42d1-9a38-ebf122810c0a, 41m10s elapsed]
362+
hpegl_caas_cluster.test: Still modifying... [id=a32fabb9-7c19-42d1-9a38-ebf122810c0a, 43m10s elapsed]
363+
hpegl_caas_cluster.test: Modifications complete after 43m18s [id=a32fabb9-7c19-42d1-9a38-ebf122810c0a]
347364

348365
Apply complete! Resources: 0 added, 1 changed, 0 destroyed.
349366
```
@@ -356,11 +373,12 @@ In this blog, I covered how to update Kubernetes clusters with Terraform provide
356373

357374
I hope you found this information interesting and useful while considering the upgrade of Kubernetes cluster with HPE GreenLake Terraform provider. Use the following links to understand more about Terraform and HPE GreenLake Terraform Provider.
358375

359-
- [Learn more about Terraform](https://www.terraform.io/)
376+
* [Learn more about Terraform](https://www.terraform.io/)
377+
* [Learn more about HPE GreenLake](https://www.hpe.com/us/en/greenlake.html)
378+
* [Learn more about the HPE GreenLake Terraform provider](https://registry.terraform.io/providers/HPE/hpegl)
360379

361-
- [Learn more about HPE GreenLake](https://www.hpe.com/us/en/greenlake.html)
380+
Don’t forget, you can always find other tutorials and articles on HPE GreenLake on the [HPE Developer blog](https://developer.hpe.com/blog/tag/hpe-greenlake).
362381

363-
- [Learn more about the HPE GreenLake Terraform provider](https://registry.terraform.io/providers/HPE/hpegl)
382+
## Tags
364383

365-
Don’t forget, you can always find other tutorials and articles on HPE GreenLake on the [HPE Developer blog](https://developer.hpe.com/blog/tag/hpe-greenlake).
366-
384+
[hpe-greenlake,](https://developer.hpe.com/blog/tag/hpe-greenlake)[devops,](https://developer.hpe.com/blog/tag/devops)[terraform,](https://developer.hpe.com/blog/tag/terraform)[opensource,](https://developer.hpe.com/blog/tag/opensource)[hpe-greenlake-for-private-cloud-enterprise,](https://developer.hpe.com/blog/tag/hpe-greenlake-for-private-cloud-enterprise)[hpe-greenlake-for-private-cloud-enterprise-containers,](https://developer.hpe.com/blog/tag/hpe-greenlake-for-private-cloud-enterprise-containers)[containers-service,](https://developer.hpe.com/blog/tag/containers-service)[developer,](https://developer.hpe.com/blog/tag/developer)[devops,](https://developer.hpe.com/blog/tag/devops)[sre,](https://developer.hpe.com/blog/tag/sre)[site-reliability-engineer](https://developer.hpe.com/blog/tag/site-reliability-engineer)

static/img/blog1.jpg

67.7 KB
Loading

0 commit comments

Comments
 (0)