Skip to content

Commit deac9e4

Browse files
committed
feat: E2E PoC Readiness
1 parent 059b04a commit deac9e4

18 files changed

+716
-144
lines changed

README.md

+19-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Virtual Server for Virtual Private Cloud using Custom Image
1+
# F5-BIGIP Virtual Server for Virtual Private Cloud using Custom Image
22

33
With this template, you can use IBM Cloud Schematics to create F5-BIGIP virtual server using custom image from you IBM Cloud account. Schematics uses [Terraform](https://www.terraform.io/) as the infrastructure-as-code engine. With this template, you can create and manage infrastructure as a single unit as follows. For more information about how to use this template, see the [IBM Cloud Schematics documentation](https://cloud.ibm.com/docs/schematics).
44

@@ -10,6 +10,11 @@ With this template, you can use IBM Cloud Schematics to create F5-BIGIP virtual
1010
* This is a poc work.
1111
* [Bring your F5 Custom Image](https://cloud.ibm.com/docs/vpc-on-classic-vsi?topic=vpc-on-classic-vsi-images#custom-images)
1212

13+
**Must have IBM IS Terraform Provider fixes**:
14+
* Provide `data source for ibm_login_target` that would provide some key information from provider session (example: account-id)
15+
* Provide `resource for ibm_is_image` - IS Image create, update, delete
16+
* Catalog offering Deployment variable must provide way to mark some variable sensitive (example: vendor svc account apikey)
17+
1318
## Costs
1419

1520
When you apply template, the infrastructure resources that you create incur charges as follows. To clean up the resources, you can [delete your Schematics workspace or your instance](https://cloud.ibm.com/docs/schematics?topic=schematics-manage-lifecycle#destroy-resources). Removing the workspace or the instance cannot be undone. Make sure that you back up any data that you must keep before you start the deletion process.
@@ -41,21 +46,30 @@ Fill in the following values, based on the steps that you completed before you b
4146
|Variable Name|Description|
4247
|-------------|-----------|
4348
|`ssh_public_key`|Enter the [public SSH key](https://cloud.ibm.com/docs/vpc-on-classic-vsi?topic=vpc-on-classic-vsi-ssh-keys) that you use to access your VPC virtual servers. Use the public key from the `~/.ssh/id_rsa.pub` file generated by the latest version of ssh-keygen tool, with the recommended key-size 2048.|
44-
|`f5_image`|The ID of the F5 custom image provisioned in your IBM Cloud account. To list available images, run `ibmcloud is images`. The default image is for an `f5-bigip` image in a demo account.|
4549

4650
### Optional values
4751
Before you apply your template, you can customize the following default variable values.
4852

4953
|Variable Name|Description|Default Value|
5054
|-------------|-----------|-------------|
55+
|`ibmcloud_api_key`|[Temp hack] to workaround IBM IS Provider gap. The APIKey of the IBM Cloud account where resources will be provisioned.|`None`|
56+
|`ibmcloud_vnf_svc_api_key`|The APIKey of the IBM Cloud NFV service account that is hosting the F5-BIGIP qcow2 image file.|`None`|
5157
|`generation`|The VPC Generation to target. Valid values are 2 or 1..|`2`|
5258
|`region`|The VPC Region that you want your VPC to be provisioned. To list available zones, run `ibmcloud is regions`.|`us-south`|
5359
|`zone`|The VPC Zone that you want your VPC virtual servers to be provisioned. To list available zones, run `ibmcloud is zones`.|`us-south-1`|
54-
|`vpc_name`|The name of your VPC to be provisioned.|`f5-bigip-1nic-demo-vpc`|
55-
|`ssh_key_name`|The name of your public SSH key.|`f5-ssh-pub-ke`|
56-
|`f5_vsi_name`|The name of your F5 Virtual Server to be provisioned.|`f5-bigip-1nic-demo-appliance`|
60+
|`resource_group`|The resource group to use. If unspecified, the account's default resource group is used. To list available resource groups, run `ibmcloud resource groups`.|`Default`|
61+
|`vpc_name`|The name of your VPC to be provisioned.|`f5-1arm-vpc`|
62+
|`ssh_key_name`|The name of your public SSH key.|`f5-sshkey`|
63+
|`f5_image_name`|The name of the F5 custom image to be provisioned in your IBM Cloud account.|`f5-bigip-15-0-1-0-0-11`|
64+
|`f5_vsi_name`|The name of your F5 Virtual Server to be provisioned.|`f5-1arm-vsi`|
5765
|`profile`|Enter the profile of compute CPU and memory resources that you want your VPC virtual servers to have. To list available profiles, run `ibmcloud is instance-profiles`.|`bx2-2x8`|
5866
|`f5_license`|Optional: The BYOL license key that you want your F5 virtual server in a VPC to be used by registration flow during cloud-init.|`None`|
67+
|`vnf_f5bigip_cos_instance_id`|Hidden: The COS instance-id hosting the F5-BIGIP qcow2 image.|`NA`|
68+
|`vnf_f5bigip_cos_image_url`|The COS image object url for F5-BIGIP qcow2 image.|`NA`|
5969

6070
## Outputs
6171
After you apply the template your VPC resources are successfully provisioned in IBM Cloud, you can review information such as the virtual server IP addresses and VPC identifiers in the Schematics log files, in the `Terraform SHOW` section.
72+
73+
|Variable Name|Description|Default Value|
74+
|-------------|-----------|-------------|
75+
|f5_admin_portal|Web url to interact with F5-BIGIP admin portal.|`None`|

main.tf

-123
This file was deleted.

provider.tf

+34-6
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,48 @@
1-
#variable "ibmcloud_api_key" {
2-
# default = ""
3-
# description = "The APIKey of the IBM Cloud account where resources will be provisioned."
4-
#}
1+
##############################################################################
2+
# Variable block - See each variable description
3+
##############################################################################
4+
variable "ibmcloud_api_key" {
5+
default = ""
6+
description = "Temp Hack to workaround IBM IS Provider gap. The APIKey of the IBM Cloud account where resources will be provisioned."
7+
}
8+
9+
variable "ibmcloud_vnf_svc_api_key" {
10+
default = ""
11+
description = "The APIKey of the IBM Cloud NFV service account that is hosting the F5-BIGIP qcow2 image file."
12+
}
513

614
variable "region" {
7-
default = "us-south"
15+
default = "us-south"
816
description = "The VPC Region that you want your VPC, networks and the F5 virtual server to be provisioned in. To list available regions, run `ibmcloud is regions`."
917
}
1018

1119
variable "generation" {
12-
default = 2
20+
default = 2
1321
description = "The VPC Generation to target. Valid values are 2 or 1."
1422
}
1523

24+
variable "resource_group" {
25+
default = "Default"
26+
description = "The resource group to use. If unspecified, the account's default resource group is used."
27+
}
28+
29+
##############################################################################
30+
# Provider block - Default using logged user creds
31+
##############################################################################
1632
provider "ibm" {
1733
# ibmcloud_api_key = "${var.ibmcloud_api_key}"
34+
generation = "${var.generation}"
35+
region = "${var.region}"
36+
resource_group = "${var.resource_group}"
37+
ibmcloud_timeout = 300
38+
}
39+
40+
##############################################################################
41+
# Provider block - Alias initialized tointeract with VNFSVC account
42+
##############################################################################
43+
provider "ibm" {
44+
alias = "vfnsvc"
45+
ibmcloud_api_key = "${var.ibmcloud_vnf_svc_api_key}"
1846
generation = "${var.generation}"
1947
region = "${var.region}"
2048
ibmcloud_timeout = 300

variables.tf

+19-10
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,48 @@
1+
variable "vnf_f5bigip_cos_instance_id" {
2+
default = ""
3+
description = "The COS instance-id hosting the F5-BIGIP qcow2 image."
4+
}
5+
variable "vnf_f5bigip_cos_image_url" {
6+
default = ""
7+
description = "The COS image object url for F5-BIGIP qcow2 image."
8+
}
9+
110
variable "zone" {
2-
default = "us-south-1"
11+
default = "us-south-1"
312
description = "The VPC Zone that you want your VPC networks and virtual servers to be provisioned in. To list available zones, run `ibmcloud is zones`."
413
}
514

615
variable "vpc_name" {
7-
default = "f5-bigip-1nic-demo-vpc"
16+
default = "f5-1arm-vpc"
817
description = "The name of your VPC to be provisioned."
918
}
1019

1120
variable "ssh_public_key" {
12-
default = ""
21+
default = ""
1322
description = "The [public SSH key](https://cloud.ibm.com/docs/vpc-on-classic-vsi?topic=vpc-on-classic-vsi-ssh-keys) that you use to access your VPC virtual servers. Use the public key from the `~/.ssh/id_rsa.pub` file generated by the latest version of ssh-keygen tool, with the recommended key-size 2048."
1423
}
1524

1625
variable "ssh_key_name" {
17-
default = "f5-ssh-pub-key"
26+
default = "f5-sshkey"
1827
description = "The name of the public SSH key."
1928
}
2029

21-
variable "f5_image" {
22-
default = "r006-648e7564-a7e1-40d5-8e92-6ff67c26ce9c"
23-
description = "The ID of the F5 custom image provisioned in your IBM Cloud account. To list available images, run `ibmcloud is images`. The default image is for an `f5-bigip` image in a demo account."
30+
variable "f5_image_name" {
31+
default = "f5-bigip-15-0-1-0-0-11"
32+
description = "The name of the F5 custom image to be provisioned in your IBM Cloud account."
2433
}
2534

2635
variable "f5_vsi_name" {
27-
default = "f5-bigip-1nic-demo-appliance"
36+
default = "f5-1arm-vsi"
2837
description = "The name of your F5 Virtual Server to be provisioned."
2938
}
3039

3140
variable "profile" {
32-
default = "bx2-2x8"
41+
default = "bx2-2x8"
3342
description = "The profile of compute CPU and memory resources that you want your VPC virtual servers to have. To list available profiles, run `ibmcloud is instance-profiles`."
3443
}
3544

3645
variable "f5_license" {
37-
default = ""
46+
default = ""
3847
description = "Optional. The BYOL license key that you want your F5 virtual server in a VPC to be used by registration flow during cloud-init."
3948
}

vnf-f5-poc-master/backends.tf

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
##############################################################################
2+
# This file creates two compute instances that will be used by PoC to setup
3+
# F5-BIGIP loadbalancer. Each of the backend server will be enabled with nginx
4+
# and a customize welcome page via cloud-init.
5+
# - Two Virtual Server using ubuntu-18-04-amd64
6+
##############################################################################
7+
8+
data "template_file" "welcom_page" {
9+
template = "${file("${path.module}/templates/index.nginx-debian.html.tpl")}"
10+
vars = {
11+
server_marker = "One"
12+
}
13+
}
14+
15+
##############################################################################
16+
# Read Public Image using the image name and visibility
17+
##############################################################################
18+
data "ibm_is_image" "ubuntu_18_image" {
19+
name = "ibm-ubuntu-18-04-64"
20+
visibility = "public"
21+
}
22+
23+
resource "ibm_is_instance" "backend_vsi" {
24+
count = 2
25+
name = "backend-vsi-0${count.index}"
26+
image = "${data.ibm_is_image.ubuntu_18_image.id}"
27+
profile = "cx2-2x4"
28+
29+
primary_network_interface = {
30+
subnet = "${ibm_is_subnet.f5_subnet1.id}"
31+
}
32+
33+
vpc = "${ibm_is_vpc.f5_vpc.id}"
34+
zone = "${var.zone}"
35+
keys = ["${ibm_is_ssh_key.f5_ssh_pub_key.id}"]
36+
user_data = <<EOF
37+
#!/bin/bash -v
38+
apt-get update -y
39+
apt-get install -y nginx > /tmp/nginx.log
40+
echo "${base64encode(data.template_file.welcom_page.rendered)}" | base64 -d | sed 's/SERVER_MARKER/${count.index}/g' > /var/www/html/index.nginx-debian.html
41+
service nginx start
42+
EOF
43+
44+
//User can configure timeouts
45+
timeouts {
46+
create = "10m"
47+
delete = "10m"
48+
}
49+
}

vnf-f5-poc-master/compute.tf

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
##############################################################################
2+
# This file creates the compute instances for the solution.
3+
# - Virtual Server using F5-BIGIP custom image
4+
# - Two virtual servers initialized with nginx to demo Load Balancing using F5-BIGIP
5+
##############################################################################
6+
7+
8+
##############################################################################
9+
# Create ssh key for all virtual servers.
10+
##############################################################################
11+
resource "ibm_is_ssh_key" "f5_ssh_pub_key" {
12+
name = "${var.ssh_key_name}"
13+
public_key = "${var.ssh_public_key}"
14+
}
15+
16+
##############################################################################
17+
# Create F5-BIGIP virtual server.
18+
##############################################################################
19+
resource "ibm_is_instance" "f5_vsi" {
20+
name = "${var.f5_vsi_name}"
21+
image = "${data.ibm_is_image.f5_custom_image.id}"
22+
profile = "${var.profile}"
23+
24+
primary_network_interface = {
25+
subnet = "${ibm_is_subnet.f5_subnet1.id}"
26+
}
27+
28+
vpc = "${ibm_is_vpc.f5_vpc.id}"
29+
zone = "${var.zone}"
30+
keys = ["${ibm_is_ssh_key.f5_ssh_pub_key.id}"]
31+
# user_data = "$(replace(file("f5-userdata.sh"), "F5-LICENSE-REPLACEMENT", var.f5_license)"
32+
33+
//User can configure timeouts
34+
timeouts {
35+
create = "10m"
36+
delete = "10m"
37+
}
38+
39+
# Hack to handle some race condition; will remove it once have root caused the issues.
40+
provisioner "local-exec" {
41+
command = "sleep 30"
42+
}
43+
}

0 commit comments

Comments
 (0)