Skip to content

Commit

Permalink
feat: E2E PoC Readiness
Browse files Browse the repository at this point in the history
  • Loading branch information
nirajdp76 committed Nov 19, 2019
1 parent 059b04a commit deac9e4
Show file tree
Hide file tree
Showing 18 changed files with 716 additions and 144 deletions.
24 changes: 19 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Virtual Server for Virtual Private Cloud using Custom Image
# F5-BIGIP Virtual Server for Virtual Private Cloud using Custom Image

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).

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

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

## Costs

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.
Expand Down Expand Up @@ -41,21 +46,30 @@ Fill in the following values, based on the steps that you completed before you b
|Variable Name|Description|
|-------------|-----------|
|`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.|
|`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.|

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

|Variable Name|Description|Default Value|
|-------------|-----------|-------------|
|`ibmcloud_api_key`|[Temp hack] to workaround IBM IS Provider gap. The APIKey of the IBM Cloud account where resources will be provisioned.|`None`|
|`ibmcloud_vnf_svc_api_key`|The APIKey of the IBM Cloud NFV service account that is hosting the F5-BIGIP qcow2 image file.|`None`|
|`generation`|The VPC Generation to target. Valid values are 2 or 1..|`2`|
|`region`|The VPC Region that you want your VPC to be provisioned. To list available zones, run `ibmcloud is regions`.|`us-south`|
|`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`|
|`vpc_name`|The name of your VPC to be provisioned.|`f5-bigip-1nic-demo-vpc`|
|`ssh_key_name`|The name of your public SSH key.|`f5-ssh-pub-ke`|
|`f5_vsi_name`|The name of your F5 Virtual Server to be provisioned.|`f5-bigip-1nic-demo-appliance`|
|`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`|
|`vpc_name`|The name of your VPC to be provisioned.|`f5-1arm-vpc`|
|`ssh_key_name`|The name of your public SSH key.|`f5-sshkey`|
|`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`|
|`f5_vsi_name`|The name of your F5 Virtual Server to be provisioned.|`f5-1arm-vsi`|
|`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`|
|`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`|
|`vnf_f5bigip_cos_instance_id`|Hidden: The COS instance-id hosting the F5-BIGIP qcow2 image.|`NA`|
|`vnf_f5bigip_cos_image_url`|The COS image object url for F5-BIGIP qcow2 image.|`NA`|

## Outputs
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.

|Variable Name|Description|Default Value|
|-------------|-----------|-------------|
|f5_admin_portal|Web url to interact with F5-BIGIP admin portal.|`None`|
123 changes: 0 additions & 123 deletions main.tf

This file was deleted.

40 changes: 34 additions & 6 deletions provider.tf
Original file line number Diff line number Diff line change
@@ -1,20 +1,48 @@
#variable "ibmcloud_api_key" {
# default = ""
# description = "The APIKey of the IBM Cloud account where resources will be provisioned."
#}
##############################################################################
# Variable block - See each variable description
##############################################################################
variable "ibmcloud_api_key" {
default = ""
description = "Temp Hack to workaround IBM IS Provider gap. The APIKey of the IBM Cloud account where resources will be provisioned."
}

variable "ibmcloud_vnf_svc_api_key" {
default = ""
description = "The APIKey of the IBM Cloud NFV service account that is hosting the F5-BIGIP qcow2 image file."
}

variable "region" {
default = "us-south"
default = "us-south"
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`."
}

variable "generation" {
default = 2
default = 2
description = "The VPC Generation to target. Valid values are 2 or 1."
}

variable "resource_group" {
default = "Default"
description = "The resource group to use. If unspecified, the account's default resource group is used."
}

##############################################################################
# Provider block - Default using logged user creds
##############################################################################
provider "ibm" {
# ibmcloud_api_key = "${var.ibmcloud_api_key}"
generation = "${var.generation}"
region = "${var.region}"
resource_group = "${var.resource_group}"
ibmcloud_timeout = 300
}

##############################################################################
# Provider block - Alias initialized tointeract with VNFSVC account
##############################################################################
provider "ibm" {
alias = "vfnsvc"
ibmcloud_api_key = "${var.ibmcloud_vnf_svc_api_key}"
generation = "${var.generation}"
region = "${var.region}"
ibmcloud_timeout = 300
Expand Down
29 changes: 19 additions & 10 deletions variables.tf
Original file line number Diff line number Diff line change
@@ -1,39 +1,48 @@
variable "vnf_f5bigip_cos_instance_id" {
default = ""
description = "The COS instance-id hosting the F5-BIGIP qcow2 image."
}
variable "vnf_f5bigip_cos_image_url" {
default = ""
description = "The COS image object url for F5-BIGIP qcow2 image."
}

variable "zone" {
default = "us-south-1"
default = "us-south-1"
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`."
}

variable "vpc_name" {
default = "f5-bigip-1nic-demo-vpc"
default = "f5-1arm-vpc"
description = "The name of your VPC to be provisioned."
}

variable "ssh_public_key" {
default = ""
default = ""
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."
}

variable "ssh_key_name" {
default = "f5-ssh-pub-key"
default = "f5-sshkey"
description = "The name of the public SSH key."
}

variable "f5_image" {
default = "r006-648e7564-a7e1-40d5-8e92-6ff67c26ce9c"
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."
variable "f5_image_name" {
default = "f5-bigip-15-0-1-0-0-11"
description = "The name of the F5 custom image to be provisioned in your IBM Cloud account."
}

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

variable "profile" {
default = "bx2-2x8"
default = "bx2-2x8"
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`."
}

variable "f5_license" {
default = ""
default = ""
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."
}
49 changes: 49 additions & 0 deletions vnf-f5-poc-master/backends.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
##############################################################################
# This file creates two compute instances that will be used by PoC to setup
# F5-BIGIP loadbalancer. Each of the backend server will be enabled with nginx
# and a customize welcome page via cloud-init.
# - Two Virtual Server using ubuntu-18-04-amd64
##############################################################################

data "template_file" "welcom_page" {
template = "${file("${path.module}/templates/index.nginx-debian.html.tpl")}"
vars = {
server_marker = "One"
}
}

##############################################################################
# Read Public Image using the image name and visibility
##############################################################################
data "ibm_is_image" "ubuntu_18_image" {
name = "ibm-ubuntu-18-04-64"
visibility = "public"
}

resource "ibm_is_instance" "backend_vsi" {
count = 2
name = "backend-vsi-0${count.index}"
image = "${data.ibm_is_image.ubuntu_18_image.id}"
profile = "cx2-2x4"

primary_network_interface = {
subnet = "${ibm_is_subnet.f5_subnet1.id}"
}

vpc = "${ibm_is_vpc.f5_vpc.id}"
zone = "${var.zone}"
keys = ["${ibm_is_ssh_key.f5_ssh_pub_key.id}"]
user_data = <<EOF
#!/bin/bash -v
apt-get update -y
apt-get install -y nginx > /tmp/nginx.log
echo "${base64encode(data.template_file.welcom_page.rendered)}" | base64 -d | sed 's/SERVER_MARKER/${count.index}/g' > /var/www/html/index.nginx-debian.html
service nginx start
EOF

//User can configure timeouts
timeouts {
create = "10m"
delete = "10m"
}
}
43 changes: 43 additions & 0 deletions vnf-f5-poc-master/compute.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
##############################################################################
# This file creates the compute instances for the solution.
# - Virtual Server using F5-BIGIP custom image
# - Two virtual servers initialized with nginx to demo Load Balancing using F5-BIGIP
##############################################################################


##############################################################################
# Create ssh key for all virtual servers.
##############################################################################
resource "ibm_is_ssh_key" "f5_ssh_pub_key" {
name = "${var.ssh_key_name}"
public_key = "${var.ssh_public_key}"
}

##############################################################################
# Create F5-BIGIP virtual server.
##############################################################################
resource "ibm_is_instance" "f5_vsi" {
name = "${var.f5_vsi_name}"
image = "${data.ibm_is_image.f5_custom_image.id}"
profile = "${var.profile}"

primary_network_interface = {
subnet = "${ibm_is_subnet.f5_subnet1.id}"
}

vpc = "${ibm_is_vpc.f5_vpc.id}"
zone = "${var.zone}"
keys = ["${ibm_is_ssh_key.f5_ssh_pub_key.id}"]
# user_data = "$(replace(file("f5-userdata.sh"), "F5-LICENSE-REPLACEMENT", var.f5_license)"

//User can configure timeouts
timeouts {
create = "10m"
delete = "10m"
}

# Hack to handle some race condition; will remove it once have root caused the issues.
provisioner "local-exec" {
command = "sleep 30"
}
}
Loading

0 comments on commit deac9e4

Please sign in to comment.