-
Notifications
You must be signed in to change notification settings - Fork 0
Add support for vsphere on robotest #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,3 +25,4 @@ tf/ | |
| # build artifacts | ||
| version.go | ||
| build/ | ||
| .idea | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| #!/bin/bash | ||
| # | ||
| # Copyright 2020 Gravitational, Inc. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| # | ||
| # VM bootstrap script for CentOS/RHEL | ||
| # | ||
|
|
||
| sudo sysctl -w net.bridge.bridge-nf-call-iptables=1 | ||
| sudo sysctl -w net.bridge.bridge-nf-call-ip6tables=1 | ||
| echo 'net.bridge.bridge-nf-call-iptables = 1' | sudo tee -a /etc/sysctl.conf | ||
| echo 'net.bridge.bridge-nf-call-ip6tables = 1' | sudo tee -a /etc/sysctl.conf | ||
| sudo sysctl -system | ||
| echo "Done" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| variable "vsphere_user" { | ||
| description = "vSphere username" | ||
| type = string | ||
| } | ||
|
|
||
| variable "vsphere_password" { | ||
| description = "vSphere password" | ||
| type = string | ||
| } | ||
|
|
||
| variable "vsphere_server" { | ||
| description = "vSphere server" | ||
| type = string | ||
| } | ||
|
|
||
| variable "datacenter" { | ||
| description = "The vSphere datacenter where resources will be created" | ||
| type = string | ||
| } | ||
|
|
||
| variable "cluster" { | ||
| description = "The vSphere cluster where resources will be created" | ||
| type = string | ||
| } | ||
|
|
||
| variable "datastore" { | ||
| description = "The vSphere datastore where VM disks will be stored" | ||
| type = string | ||
| } | ||
|
|
||
| variable "vm_folder" { | ||
| description = "The vSphere folder where VMs will be created" | ||
| type = string | ||
| } | ||
|
|
||
| variable "network" { | ||
| description = "Network for VM NIC." | ||
| type = string | ||
| } | ||
|
|
||
| variable "template" { | ||
| description = "Template to clone VMs from" | ||
| type = string | ||
| } | ||
|
|
||
| variable "node_tag" { | ||
| description = "vSphere-friendly cluster name to use as a prefix for resources." | ||
| type = string | ||
| } | ||
|
|
||
| variable "vm_type" { | ||
| description = "Type of VM to provision" | ||
| type = string | ||
| } | ||
|
|
||
| variable "os_user" { | ||
| description = "SSH user to login onto nodes" | ||
| type = string | ||
| } | ||
|
|
||
| variable "ssh_pub_key_path" { | ||
| description = "Path to the public SSH key." | ||
| type = string | ||
| } | ||
|
|
||
| variable "nodes" { | ||
| description = "Number of nodes to provision" | ||
| type = number | ||
| default = 1 | ||
| } | ||
|
|
||
| provider "vsphere" { | ||
| user = var.vsphere_user | ||
| password = var.vsphere_password | ||
| vsphere_server = var.vsphere_server | ||
|
|
||
| allow_unverified_ssl = true | ||
| } | ||
|
|
||
| data "vsphere_datacenter" "dc" { | ||
| name = var.datacenter | ||
| } | ||
|
|
||
| data "vsphere_compute_cluster" "cluster" { | ||
| name = var.cluster | ||
| datacenter_id = data.vsphere_datacenter.dc.id | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| # | ||
| # Network | ||
| # | ||
|
|
||
| data "vsphere_network" "network" { | ||
| name = var.network | ||
| datacenter_id = data.vsphere_datacenter.dc.id | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| # | ||
| # Virtual Machine node | ||
| # | ||
|
|
||
| resource "vsphere_virtual_machine" "node" { | ||
| #TODO: Move to vars!! | ||
| guest_id = "rhel7_64Guest" | ||
| count = var.nodes | ||
| name = "${var.node_tag}-node-${count.index}" | ||
| folder = var.vm_folder | ||
|
|
||
| resource_pool_id = data.vsphere_compute_cluster.cluster.resource_pool_id | ||
|
|
||
| num_cpus = 4 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why 4? Is there some component which requires this many minimum cpus? |
||
| memory = 8192 | ||
|
|
||
| network_interface { | ||
| network_id = data.vsphere_network.network.id | ||
| } | ||
|
|
||
| disk { | ||
| label = "disk0" | ||
| size = 64 | ||
| thin_provisioned = false #TODO(ag): Update the template to true and change here | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: jira please. which template? |
||
| } | ||
|
|
||
| clone { | ||
| template_uuid = data.vsphere_virtual_machine.template.id | ||
|
|
||
| } | ||
|
|
||
| extra_config = { | ||
| "guestinfo.ssh_user" = var.os_user | ||
| "guestinfo.ssh_public_key_data" = file(var.ssh_pub_key_path) | ||
| } | ||
| } | ||
|
|
||
| data "vsphere_datastore" "datastore" { | ||
| name = var.datastore | ||
| datacenter_id = data.vsphere_datacenter.dc.id | ||
| } | ||
|
|
||
| data "vsphere_virtual_machine" "template" { | ||
| name = var.template | ||
| datacenter_id = data.vsphere_datacenter.dc.id | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| # | ||
| # OS configuration | ||
| # | ||
|
|
||
| variable "oss" { | ||
| description = "Map of supported Linux distributions" | ||
| type = "map" | ||
|
|
||
| default = { | ||
| "redhat:7.9" = "toTemplate1" | ||
| "redhat7.9" = "toTemplate1" | ||
| } | ||
| } | ||
|
|
||
| #variable "os" { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove? |
||
| # description = "Map of supported Linux distributions" | ||
| # type = "map" | ||
| # | ||
| # default = { | ||
| # "redhat:7.9" = "toTemplate1" | ||
| # "redhat7.9" = "toTemplate1" | ||
| # } | ||
| #} | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| # | ||
| # Output Variables | ||
| # | ||
|
|
||
| output "private_ips" { | ||
| value = vsphere_virtual_machine.node.*.default_ip_address | ||
| } | ||
|
|
||
| output "public_ips" { | ||
| value = vsphere_virtual_machine.node.*.default_ip_address | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| terraform { | ||
| required_version = ">= 0.12" | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,7 +11,7 @@ | |
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| FROM quay.io/gravitational/debian-venti:go1.16.6-buster | ||
| FROM quay.io/gravitational/debian-venti:go1.17.5-stretch | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we change the repo right now itself? We have put those in our gcr right? |
||
|
|
||
| ARG UID | ||
| ARG GID | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,7 +11,7 @@ | |
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| FROM quay.io/gravitational/debian-grande:stretch | ||
| FROM quay.io/gravitational/debian-grande:buster | ||
|
|
||
| ARG TERRAFORM_VERSION | ||
| ARG CHROMEDRIVER_VERSION | ||
|
|
@@ -59,6 +59,10 @@ RUN mkdir -p /robotest | |
| WORKDIR /robotest | ||
| COPY entrypoint.sh /entrypoint.sh | ||
| COPY build/robotest-e2e /usr/bin/robotest-e2e | ||
| COPY polaris.pub /robotest/polaris.pub | ||
| COPY polaris.pem /robotest/polaris.pem | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the path of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, is this the same polaris.pem, or a new one. I think it might be better to use a different one here. |
||
| RUN chmod 0644 /robotest/polaris.pem | ||
| #TODO: Change the user on the template and the SSH keys. polaris is not meant for this | ||
|
|
||
| RUN chmod +x /usr/bin/robotest-e2e && \ | ||
| chmod +x /entrypoint.sh | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a jira?