From b0e5626ee799a9e54aed3b8571e72592b206bcc6 Mon Sep 17 00:00:00 2001 From: staebler Date: Tue, 26 Mar 2019 13:13:20 -0400 Subject: [PATCH 1/4] upi/vsphere: add dns for control plane and compute hostnames Add DNS records for the control plane and compute hostnames so that they are resolvable from within the cluster. --- upi/vsphere/main.tf | 1 + upi/vsphere/route53/main.tf | 20 ++++++++++++++++++++ upi/vsphere/route53/variables.tf | 4 ++++ upi/vsphere/variables.tf | 5 +++++ 4 files changed, 30 insertions(+) diff --git a/upi/vsphere/main.tf b/upi/vsphere/main.tf index aeca9abb616..282414f34b4 100644 --- a/upi/vsphere/main.tf +++ b/upi/vsphere/main.tf @@ -75,4 +75,5 @@ module "dns" { cluster_domain = "${var.cluster_domain}" bootstrap_ip = "${var.bootstrap_complete ? "" : var.bootstrap_ip}" control_plane_ips = "${var.control_plane_ips}" + compute_ips = "${var.compute_ips}" } diff --git a/upi/vsphere/route53/main.tf b/upi/vsphere/route53/main.tf index bcf89381fde..3a6932ece15 100644 --- a/upi/vsphere/route53/main.tf +++ b/upi/vsphere/route53/main.tf @@ -71,3 +71,23 @@ resource "aws_route53_record" "ingress" { name = "*.apps.${var.cluster_domain}" records = ["${var.compute_ips}"] } + +resource "aws_route53_record" "control_plane_nodes" { + count = "${length(var.control_plane_ips)}" + + type = "A" + ttl = "60" + zone_id = "${aws_route53_zone.cluster.zone_id}" + name = "control-plane-${count.index}.${var.cluster_domain}" + records = ["${var.control_plane_ips[count.index]}"] +} + +resource "aws_route53_record" "compute_nodes" { + count = "${length(var.compute_ips)}" + + type = "A" + ttl = "60" + zone_id = "${aws_route53_zone.cluster.zone_id}" + name = "compute-${count.index}.${var.cluster_domain}" + records = ["${var.compute_ips[count.index]}"] +} diff --git a/upi/vsphere/route53/variables.tf b/upi/vsphere/route53/variables.tf index 99c8fb6c3d5..d5af77333e4 100644 --- a/upi/vsphere/route53/variables.tf +++ b/upi/vsphere/route53/variables.tf @@ -11,6 +11,10 @@ variable "control_plane_ips" { type = "list" } +variable "compute_ips" { + type = "list" +} + variable "base_domain" { description = "The base domain used for public records." type = "string" diff --git a/upi/vsphere/variables.tf b/upi/vsphere/variables.tf index 2392f8882c4..c7d6e72d46e 100644 --- a/upi/vsphere/variables.tf +++ b/upi/vsphere/variables.tf @@ -124,3 +124,8 @@ variable "compute_instance_count" { variable "compute_ignition" { type = "string" } + +variable "compute_ips" { + type = "list" + default = [] +} From 4e08b3be69ac0f393fbe0e1e2272d1ac04034efc Mon Sep 17 00:00:00 2001 From: staebler Date: Thu, 28 Mar 2019 13:23:57 -0400 Subject: [PATCH 2/4] upi/vsphere: put pull secret directly in vm ignition config The bootstrap machine pulls ignition config from a publicly-accessible url. The pull secret contains sensitive information that should not be publicly accessible. These changes strip the pull secret out of the ignition config posted publicly and instead includes it in the ignition config set directly in the vm. --- upi/vsphere/README.md | 5 ++++- upi/vsphere/machine/main.tf | 24 ++++++++++++++++++++++++ upi/vsphere/machine/variables.tf | 5 +++++ upi/vsphere/main.tf | 1 + upi/vsphere/terraform.tfvars.example | 8 ++++++++ upi/vsphere/variables.tf | 4 ++++ 6 files changed, 46 insertions(+), 1 deletion(-) diff --git a/upi/vsphere/README.md b/upi/vsphere/README.md index 6bae41b8c4d..733f39fa3c3 100644 --- a/upi/vsphere/README.md +++ b/upi/vsphere/README.md @@ -17,9 +17,12 @@ sshKey: YOUR_SSH_KEY 2. Run `openshift-install create ignition-configs`. 3. Fill out a terraform.tfvars file with the ignition configs generated. -There is an example terraform.tfvars file in this directory named terraform.tfvars.example. The example file is set up for use with the dev cluster running at vcsa.vmware.devcluster.openshift.com. At a minimum, you need to set values for `cluster_id`, `cluster_domain`, `vsphere_user`, `vsphere_password`, `bootstrap_ignition_url`, `control_plane_ignition`, and `compute_ignition`. +There is an example terraform.tfvars file in this directory named terraform.tfvars.example. The example file is set up for use with the dev cluster running at vcsa.vmware.devcluster.openshift.com. At a minimum, you need to set values for `cluster_id`, `cluster_domain`, `vsphere_user`, `vsphere_password`, `pull_secret`, `bootstrap_ignition_url`, `control_plane_ignition`, and `compute_ignition`. The bootstrap ignition config must be placed in a location that will be accessible by the bootstrap machine. For example, you could store the bootstrap ignition config in a gist. Initially, the `bootstrap_complete` variable must be false, the `bootstrap_ip` variable must be an empty string, and the `control_plane_ips variable must be an empty list. +To secure your pull secret, you should remove the pull from the bootstrap ignition config and pass it as a variable to terraform. + a) Create an ignition config without the pull secret via `jq 'del(.storage.files[] | select(.path=="/root/.docker/config.json"))' bootstrap.ign`. + b) Extract the pull secret to pass to terraform via `jq '.storage.files[] | select(.path=="/root/.docker/config.json")' bootstrap.ign`. 4. Run `terraform init`. diff --git a/upi/vsphere/machine/main.tf b/upi/vsphere/machine/main.tf index 7f3394514af..01c85558cce 100644 --- a/upi/vsphere/machine/main.tf +++ b/upi/vsphere/machine/main.tf @@ -1,5 +1,25 @@ locals { ignition_encoded = "data:text/plain;charset=utf-8;base64,${base64encode(var.ignition)}" + + pull_secret_ignition = < Date: Tue, 26 Mar 2019 23:05:53 -0400 Subject: [PATCH 3/4] upi/vsphere: use static ip addresses Static IP addresses are now working with rhcos. --- upi/vsphere/README.md | 48 +++++++++++------------ upi/vsphere/machine/main.tf | 58 ++++++++++++++++++++++++---- upi/vsphere/machine/variables.tf | 12 ++++-- upi/vsphere/main.tf | 15 ++++--- upi/vsphere/route53/main.tf | 16 +------- upi/vsphere/terraform.tfvars.example | 29 ++++++-------- upi/vsphere/variables.tf | 41 +++++++------------- 7 files changed, 116 insertions(+), 103 deletions(-) diff --git a/upi/vsphere/README.md b/upi/vsphere/README.md index 733f39fa3c3..f54aa0bf72e 100644 --- a/upi/vsphere/README.md +++ b/upi/vsphere/README.md @@ -17,42 +17,38 @@ sshKey: YOUR_SSH_KEY 2. Run `openshift-install create ignition-configs`. 3. Fill out a terraform.tfvars file with the ignition configs generated. -There is an example terraform.tfvars file in this directory named terraform.tfvars.example. The example file is set up for use with the dev cluster running at vcsa.vmware.devcluster.openshift.com. At a minimum, you need to set values for `cluster_id`, `cluster_domain`, `vsphere_user`, `vsphere_password`, `pull_secret`, `bootstrap_ignition_url`, `control_plane_ignition`, and `compute_ignition`. +There is an example terraform.tfvars file in this directory named terraform.tfvars.example. The example file is set up for use with the dev cluster running at vcsa.vmware.devcluster.openshift.com. At a minimum, you need to set values for the following variables. +* cluster_id +* cluster_domain +* vsphere_user +* vsphere_password +* bootstrap_ip +* control_plane_ips +* compute_ips +* pull_secret +* bootstrap_ignition_url +* control_plane_ignition +* compute_ignition The bootstrap ignition config must be placed in a location that will be accessible by the bootstrap machine. For example, you could store the bootstrap ignition config in a gist. -Initially, the `bootstrap_complete` variable must be false, the `bootstrap_ip` variable must be an empty string, and the `control_plane_ips variable must be an empty list. +For the IP addresses, you should have static IP addresses reserved for you. To secure your pull secret, you should remove the pull from the bootstrap ignition config and pass it as a variable to terraform. a) Create an ignition config without the pull secret via `jq 'del(.storage.files[] | select(.path=="/root/.docker/config.json"))' bootstrap.ign`. b) Extract the pull secret to pass to terraform via `jq '.storage.files[] | select(.path=="/root/.docker/config.json")' bootstrap.ign`. 4. Run `terraform init`. -5. Run `terraform apply -auto-approve`. +5. Ensure that you have you AWS profile set and a region specified. The installation will use create AWS route53 resources for routing to the OpenShift cluster. -6. Find the IP address of the bootstrap machine. -If you provided an extra user, you can use that user to log into the bootstrap machine via the vSphere web console. -Alternatively, you could iterate through the IP addresses in the 139.178.89.192/26 block looking for one that has the expected hostname, which is bootstrap-0.{cluster_domain}. For example, `ssh -i ~/.ssh/libra.pem -o StrictHostNameChecking=no -q core@139.178.89.199 hostname` +6. Run `terraform apply -auto-approve`. +This will create the OpenShift cluster -7. Update the terraform.tfvars file with the IP address of the bootstrap machine. +7. Run `openshift-install upi bootstrap-complete`. Wait for the bootstrapping to complete. -8. Run `terraform apply -auto-approve`. -From this point forward, route53 resources will be managed by terraform. You will need to have your AWS profile set and a region specified. +8. Run `terraform apply -auto-approve -var 'bootstrap_ip='`. +This will destroy the bootstrap VM. -9. Find the IP addresses of the control plane machines. See step 6 for examples of how to do this. The expected hostnames are control-plane-{0,1,2}.{cluster_domain}. The control plane machines will change their IP addresses once. You need the final IP addresses. If you happen to use the first set of IP addresses, you can later update the IP addresses in the terraform.tfvars file and re-run terraform. +9. Run `openshift-install upi finish`. Wait for the cluster install to finish. -10. Update the terraform.tfvars file with the IP addresses of the control plane machines. +10. Enjoy your new OpenShift cluster. -11. Run `terraform apply -auto-approve`. - -12. Run `openshift-install user-provided-infrastructure`. Wait for the bootstrapping to complete. -You *may* need to log into each of the control plane machines. It would seem that, for some reason, the etcd-member pod does not start until the machine is logged into. - -13. Update the terraform.tfvars file to set the `bootstrap_complete` variable to "true". - -14. Run `terraform apply -auto-approve`. - -15. Run `openshift-install user-provided-infrastructure finish`. Wait for the cluster install to finish. -Currently, the cluster install does not finish. There is an outstanding issue with the openshift-console operator not installing successfully. The cluster should still be usable save for the console, however. - -16. Enjoy your new OpenShift cluster. - -17. Run `terraform destroy -auto-approve`. +11. Run `terraform destroy -auto-approve`. diff --git a/upi/vsphere/machine/main.tf b/upi/vsphere/machine/main.tf index 01c85558cce..8c567dd0b1b 100644 --- a/upi/vsphere/machine/main.tf +++ b/upi/vsphere/machine/main.tf @@ -1,4 +1,7 @@ locals { + mask = "${element(split("/", var.machine_cidr), 1)}" + gw = "${cidrhost(var.machine_cidr,1)}" + ignition_encoded = "data:text/plain;charset=utf-8;base64,${base64encode(var.ignition)}" pull_secret_ignition = < Date: Thu, 28 Mar 2019 08:42:44 -0400 Subject: [PATCH 4/4] [WIP] vSphere UPI - Use a folder for virtual machines - Creates a vm folder - Virtual Machines are deployed into the folder created - Updated README.md --- upi/vsphere/folder/main.tf | 5 +++++ upi/vsphere/folder/output.tf | 3 +++ upi/vsphere/folder/variables.tf | 11 +++++++++++ upi/vsphere/machine/main.tf | 1 + upi/vsphere/machine/variables.tf | 4 ++++ upi/vsphere/main.tf | 11 +++++++++++ 6 files changed, 35 insertions(+) create mode 100644 upi/vsphere/folder/main.tf create mode 100644 upi/vsphere/folder/output.tf create mode 100644 upi/vsphere/folder/variables.tf diff --git a/upi/vsphere/folder/main.tf b/upi/vsphere/folder/main.tf new file mode 100644 index 00000000000..6f5605846f1 --- /dev/null +++ b/upi/vsphere/folder/main.tf @@ -0,0 +1,5 @@ +resource "vsphere_folder" "folder" { + path = "${var.path}" + type = "vm" + datacenter_id = "${var.datacenter_id}" +} diff --git a/upi/vsphere/folder/output.tf b/upi/vsphere/folder/output.tf new file mode 100644 index 00000000000..d20b194905c --- /dev/null +++ b/upi/vsphere/folder/output.tf @@ -0,0 +1,3 @@ +output "path" { + value = "${vsphere_folder.folder.path}" +} diff --git a/upi/vsphere/folder/variables.tf b/upi/vsphere/folder/variables.tf new file mode 100644 index 00000000000..60a466edd2a --- /dev/null +++ b/upi/vsphere/folder/variables.tf @@ -0,0 +1,11 @@ +variable "path" { + type = "string" +} + +variable "datacenter_id" { + type = "string" +} + +variable "vsphere_cluster" { + type = "string" +} diff --git a/upi/vsphere/machine/main.tf b/upi/vsphere/machine/main.tf index 8c567dd0b1b..0275da5651e 100644 --- a/upi/vsphere/machine/main.tf +++ b/upi/vsphere/machine/main.tf @@ -129,6 +129,7 @@ resource "vsphere_virtual_machine" "vm" { num_cpus = "4" memory = "8192" guest_id = "other26xLinux64Guest" + folder = "${var.folder_id}" network_interface { network_id = "${data.vsphere_network.network.id}" diff --git a/upi/vsphere/machine/variables.tf b/upi/vsphere/machine/variables.tf index 0dd998691a2..a3448d6a69b 100644 --- a/upi/vsphere/machine/variables.tf +++ b/upi/vsphere/machine/variables.tf @@ -16,6 +16,10 @@ variable "resource_pool_id" { type = "string" } +variable "folder_id" { + type = "string" +} + variable "datastore" { type = "string" } diff --git a/upi/vsphere/main.tf b/upi/vsphere/main.tf index 0c9fd4398dd..4bb5e803130 100644 --- a/upi/vsphere/main.tf +++ b/upi/vsphere/main.tf @@ -17,6 +17,14 @@ module "resource_pool" { vsphere_cluster = "${var.vsphere_cluster}" } +module "folder" { + source = "./folder" + + path = "${var.cluster_id}" + datacenter_id = "${data.vsphere_datacenter.dc.id}" + vsphere_cluster = "${var.vsphere_cluster}" +} + module "bootstrap" { source = "./machine" @@ -24,6 +32,7 @@ module "bootstrap" { ignition_url = "${var.bootstrap_ignition_url}" resource_pool_id = "${module.resource_pool.pool_id}" datastore = "${var.vsphere_datastore}" + folder_id = "${module.folder.path}" network = "${var.vm_network}" datacenter_id = "${data.vsphere_datacenter.dc.id}" template = "${var.vm_template}" @@ -42,6 +51,7 @@ module "control_plane" { name = "control-plane" ignition = "${var.control_plane_ignition}" resource_pool_id = "${module.resource_pool.pool_id}" + folder_id = "${module.folder.path}" datastore = "${var.vsphere_datastore}" network = "${var.vm_network}" datacenter_id = "${data.vsphere_datacenter.dc.id}" @@ -60,6 +70,7 @@ module "compute" { name = "compute" ignition = "${var.compute_ignition}" resource_pool_id = "${module.resource_pool.pool_id}" + folder_id = "${module.folder.path}" datastore = "${var.vsphere_datastore}" network = "${var.vm_network}" datacenter_id = "${data.vsphere_datacenter.dc.id}"