Skip to content

Commit da8bc81

Browse files
Update Blog “highly-available-nfs-workload-on-hpe-greenlake-for-private-cloud-enterprise-using-serviceguard-for-linux”
1 parent 6aeaeef commit da8bc81

File tree

5 files changed

+115
-34
lines changed

5 files changed

+115
-34
lines changed

content/blog/highly-available-nfs-workload-on-hpe-greenlake-for-private-cloud-enterprise-using-serviceguard-for-linux.md

Lines changed: 115 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,13 @@ One of the options provided through HPE GreenLake is to make it easy for custome
1717

1818
## Terraform
1919

20-
2120
Terraform is an open-source Infrastructure-as-Code framework originally created by HashiCorp that is written in Go. It uses a declarative language (HashiCorp Configuration Language HCL or JSON more recently) to describe the desired state of the infrastructure in terms of cloud, virtual machines, networks, storage, and many other components. Terraform uses the concept of “providers” to integrate with all major public clouds. Terraform is a so-called idempotent system in the sense that it does not generate any side effects if applied multiple times on infrastructure already in the desired state. Terraform has gained quite the momentum in the last few years.
2221

2322
## HPE Serviceguard for Linux
2423

2524
HPE Serviceguard for Linux (SGLX) is a high availability (HA) and disaster recovery (DR) clustering solution that increases uptime for your critical applications by protecting them from a multitude of infrastructure and application faults across physical or virtual environments over any distance. The solution also reduces the impact of unplanned downtime with no compromise on data integrity or performance, and it helps achieve near zero planned downtime for maintenance.
2625

27-
## Ansible
28-
26+
## Ansible
2927

3028
Ansible Automation Platform is an end-to-end automation platform to configure systems, deploy software, and orchestrate advanced workflows. It includes resources to create, manage, and scale across the entire enterprise.
3129

@@ -47,7 +45,6 @@ You can create a virtual machine in the Virtual Machines service of HPE GreenLak
4745

4846
## Building a Terraform configuration file from scratch
4947

50-
5148
Let’s start building this Terraform (TF) file using your favourite editor.
5249
Selecting a Terraform provider
5350
The first section of the file will enumerate the “providers” you rely upon for building your infrastructure, and they could be multiple providers in a single TF file. In the case here, you only have the HPE GreenLake provider referenced as hpe/hpegl in the official Terraform registry.
@@ -74,9 +71,7 @@ https://registry.terraform.io/providers/HPE/hpegl/latest This page also provides
7471
The docs folder is your best source of information for using the different data sources and resources provided by the provider. If you navigate to the resources section, you will see that one resource you can configure with this provider is a VM instance. This article will focus on this resource.
7572
Note: Because this is open source, do not hesitate to open issues, or even a pull request, if you identify an issue.
7673

77-
##
78-
Setting up the Terraform provider
79-
74+
## Setting up the Terraform provider
8075

8176
Set up the required parameters for hpegl provider that was specified earlier. As previously explained, you can either explicitly set those parameters in your TF file or have them set in a series of environment variables or have a mix of both. It is recommended to add the following two parameters in your TF file:
8277

@@ -93,31 +88,55 @@ provider "hpegl" {
9388
The rest (such as tenant id, user id and user secret key) can be placed in a RC file, which you can source before running your Terraform command.
9489
You can find your location and your space name from the HPE GreenLake for Private Cloud Enterprise Overview. In the example shown below, FTC06 is our location:
9590

91+
![](/img/picture1.png)
92+
9693
In the capture below, Default is the space you will use for your work with Terraform. You can check your available Spaces from the HPE GreenLake console under your profile icon, Change Space.
9794

98-
Setting up API Client access
95+
![](/img/picture2.png)
96+
97+
## Setting up API Client access
98+
99+
99100
Next, you need to create a new API Client access dedicated to Terraform. You can do this from the HPE GreenLake console under your settings icon, select User Management and then the API Clients tab.
100101

102+
![](/img/picture3.png)
103+
101104
Create a new API Client and be sure to note down the Issuer, Client ID and Client Secret values which are shown.
102105
The value for the tenant ID may be seen in the Tenant ID field under the API Access menu and in the URL of your browser.
103106

107+
![](/img/picture4.png)
108+
104109
With this you can now build a resource file that defines the following environment variables:
110+
111+
```
105112
export HPEGL_TENANT_ID=<Your Tenant ID>
106113
export HPEGL_USER_ID=<Client ID of the API Client>
107114
export HPEGL_USER_SECRET=<Secret Key displayed when you created the API Client>
108115
export HPEGL_IAM_SERVICE_URL=<Issuer URL>
116+
```
117+
118+
119+
109120
And execute it on your machine to set these environment variables.
110121

111-
Assign Roles to API Client
122+
## Assign Roles to API Client
123+
124+
112125
Once your API Client has been created, you need to assign a Role and a Space. You can assign a Role and a Space by clicking on your new API Client and then clicking the Create Assignment button.
113126
Since intent is to use this API Client to create resources in the Virtual Machines Service, we need to assign an appropriate Virtual Machines Role. Choose a Role like ‘Private Cloud Tenant Contributor’ and choose the same Space as used earlier, I.e., ‘Default.’
114127

115128
Note: More details on HPE GreenLake user roles can be found in the HPE GreenLake documentation.
129+
130+
##
116131
Set API Client Usernames and Passwords
132+
133+
117134
When a user creates virtual machines using the HPE GreenLake for Private Cloud Enterprise: Virtual Machines user interface, they first set the Linux and Windows username and password. Once this is done, any virtual machines subsequently created by that user will inherit these credentials. The user can later use these credentials to log into these virtual machines.
118135
API Clients which are used to create virtual machines can also set Linux and Windows username and password values. Since the API Client does not use the HPE GreenLake for Private Cloud Enterprise: Virtual Machines user interface, this must be done via an API call.
119-
Here is a sample script which reads the VM*USERNAME and VM_PASSWORD environment variables and uses the values for Linux and Windows username and password for the API Client. The script assumes a Location value of ‘FTC06’ and Space value of ‘Default’.
120-
To execute this script, first set appropriate values for the VM_USERNAME and VM_PASSWORD environment variables. Next, execute the resource file, which was created earlier, which sets the HPEGL** environment variables for your API Client. Finally, execute the script below.
136+
Here is a sample script which reads the VM\*USERNAME and VM_PASSWORD environment variables and uses the values for Linux and Windows username and password for the API Client. The script assumes a Location value of ‘FTC06’ and Space value of ‘Default’.
137+
To execute this script, first set appropriate values for the VM_USERNAME and VM_PASSWORD environment variables. Next, execute the resource file, which was created earlier, which sets the HPEGL\** environment variables for your API Client. Finally, execute the script below.
138+
139+
```
121140
#!/bin/bash
122141
export LOCATION='FTC06'
123142
export SPACE='Default'
@@ -135,9 +154,8 @@ echo "Token: ${ACCESS_TOKEN}"
135154
curl -s -k -X GET \
136155
"https://client.greenlake.hpe.com/api/iac-vmaas/v1/whoami?space=${SPACE_ENCODED}&location=${LOCATION}" \
137156
-H "Authorization: ${ACCESS_TOKEN}" | jq '.'
138-
157+
139158
# Sets user settings
140-
141159
curl -s -k -X POST \
142160
"https://client.greenlake.hpe.com/api/iac-vmaas/v1beta1/user-settings?space=${SPACE_ENCODED}&location=${LOCATION}" \
143161
-H "Authorization: ${ACCESS_TOKEN}" \
@@ -151,7 +169,12 @@ curl -s -k -X POST \
151169
}
152170
}'
153171
172+
```
173+
174+
##
154175
Querying for infrastructure components
176+
177+
155178
Your next step with the TF file is to query the HPE GreenLake provider to collect information needed to create your first VM instance. From the documentation, you can see that you need to gather the following information:
156179
• Cloud ID
157180
• Group ID
@@ -164,58 +187,69 @@ Your next step with the TF file is to query the HPE GreenLake provider to collec
164187
• Folder Code
165188
For this, you will use the Terraform data statements. For example, the following statement retrieves the Cloud ID and stores it (in variable called cloud), which we can later retrieve using: data.hpegl_vmaas_cloud.cloud.id
166189

190+
```
167191
# Retrieve cloud id
168-
169192
data "hpegl_vmaas_cloud" "cloud" {
170193
name = "HPE GreenLake VMaaS Cloud"
171194
}
195+
196+
```
197+
172198
Using a similar technique, you can retrieve the rest of the data you need:
173199

200+
```
174201
# And a network
175-
176202
data "hpegl_vmaas_network" "blue_segment" {
177203
name = "Blue-Segment"
178204
}
179-
205+
180206
data "hpegl_vmaas_cloud_folder" "compute_folder" {
181207
cloud_id = data.hpegl_vmaas_cloud.cloud.id
182208
name = "ComputeFolder"
183209
}
184-
210+
185211
# Locate a resource pool
186-
187212
data "hpegl_vmaas_resource_pool" "cl_resource_pool" {
188213
cloud_id = data.hpegl_vmaas_cloud.cloud.id
189214
name = "gl-ftc06-G2i-vm-02"
190215
}
191-
216+
192217
# And a group
193-
194218
data "hpegl_vmaas_group" "default_group" {
195219
name = "Default"
196220
}
197-
221+
198222
# Locate a plan
199-
200223
data "hpegl_vmaas_plan" "g2i_medium" {
201224
name = "G2i-medium"
202225
}
203-
226+
204227
# A layout
205-
206228
data "hpegl_vmaas_layout" "vmware" {
207229
name = "Vmware VM"
208230
instance_type_code = "vmware"
209231
}
210-
232+
211233
# And a template
212-
213234
data "hpegl_vmaas_template" "vanilla" {
214235
name = "redhat8-20220331T1850"
215236
}
216-
You can get information about each of the data statements supported by the hpegl provider from GitHub.
217-
Creating VM resources
237+
238+
```
239+
240+
######
241+
242+
243+
You can get information about each of the data statements supported by the hpegl provider from [GitHub.](https://github.com/hpe/terraform-provider-hpegl/tree/main/docs/data-sources)
244+
245+
## Creating VM resources
246+
247+
218248
The next step is to use a Terraform resource statement to create a random integer (used in VM names) and a second resource to request the creation of several VM instances:
249+
250+
251+
252+
```
219253
resource "random_integer" "random" {
220254
min = 1
221255
max = 50000
@@ -230,13 +264,39 @@ resource "hpegl_vmaas_instance" " my_HA_NFS" {
230264
layout_id = data.hpegl_vmaas_layout.vmware.id
231265
plan_id = data.hpegl_vmaas_plan.g2i_medium.id
232266
instance_type_code = data.hpegl_vmaas_layout.vmware.instance_type_code
267+
network {
268+
id = data.hpegl_vmaas_network.blue_segment.id
269+
}
270+
271+
volume {
272+
name = "root_vol"
273+
size = 50
274+
datastore_id = "auto"
275+
}
276+
volume {
277+
name = "drbd_vol"
278+
size = 50
279+
datastore_id = "auto"
280+
}
281+
282+
config {
283+
resource_pool_id = data.hpegl_vmaas_resource_pool.cl_resource_pool.id
284+
template_id = data.hpegl_vmaas_template.vanilla.id
285+
no_agent = false
286+
asset_tag = "vm_terraform_sglx"
287+
folder_code = data.hpegl_vmaas_cloud_folder.compute_folder.code
288+
create_user = true
289+
}
290+
291+
}
233292
234293
```
235294

236-
```
237-
238-
}
295+
239296
Finally, we will create a VM to act as Serviceguard quorum node:
297+
298+
299+
```
240300
resource "hpegl_vmaas_instance" "my_quorum" {
241301
count = 1
242302
name = "drbd-${count.index}-qs-${random_integer.random.result}"
@@ -246,17 +306,38 @@ resource "hpegl_vmaas_instance" "my_quorum" {
246306
layout_id = data.hpegl_vmaas_layout.vmware.id
247307
plan_id = data.hpegl_vmaas_plan.g2i_medium.id
248308
instance_type_code = data.hpegl_vmaas_layout.vmware.instance_type_code
309+
network {
310+
id = data.hpegl_vmaas_network.blue_segment.id
311+
}
312+
313+
volume {
314+
name = "root_vol"
315+
size = 50
316+
datastore_id = "auto"
317+
}
318+
319+
config {
320+
resource_pool_id = data.hpegl_vmaas_resource_pool.cl_resource_pool.id
321+
template_id = data.hpegl_vmaas_template.vanilla.id
322+
no_agent = false
323+
asset_tag = "vm_terraform_sglx_quorum"
324+
folder_code = data.hpegl_vmaas_cloud_folder.compute_folder.code
325+
create_user = true
326+
}
327+
}
249328
250329
```
251330

252-
```
253-
254-
}
331+
255332

256333
3 VMs need to be created to setup SGLX. 2 VMs will be used to create Serviceguard for Linux nodes where the NFS service will be up and running. The third VM will act as a quorum server for the Serviceguard cluster to ensure that split brain of the cluster does not impact the availability of the monitored workload.
257334
Note: You can get information about each of the resource statements supported by the hpegl provider from GitHub.
258335
Note: An existing Serviceguard Quorum Server in your environment can be used instead of provisioning a third VM, provided the Quorum Server is reachable to the 2 VM’s that were created.
336+
337+
##
259338
Terraform init
339+
340+
260341
Before you can use Terraform, you need to initialize it from the configuration file we have created. This is done with the following step:
261342
terraform init
262343
Terraform ready to plan

static/img/picture1.png

-182 KB
Loading

static/img/picture2.png

-1.17 MB
Loading

static/img/picture3.png

12.6 KB
Loading

static/img/picture4.png

-38.9 KB
Loading

0 commit comments

Comments
 (0)