-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: build and use temporary bastion for each vsphere CI test run (#850)
* ci: github action workflow to create vsphere bastion host * deprecate scripts that creates permanent bastion * ci: allow overriding bastion ssh port * ci: refactor scripts to create bastion host * test using airgapped bastion * ci: use temp bastion host for vsphere e2e tests * use datastore input from github action secrets * correct public key reference * update vsphre release flow to use temporary bastion * fix linter errors
- Loading branch information
Showing
12 changed files
with
180 additions
and
161 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,17 +59,36 @@ jobs: | |
with: | ||
ssh-private-key: ${{ secrets.SSH_BASTION_KEY_CONTENTS }} | ||
|
||
# configure git to access private repo hosting vsphere module mesosphere/vcenter-tools | ||
- name: Configure git to clone private registry from mesosphere org | ||
run: | | ||
git config --global url."https://git:${{ secrets.MESOSPHERECI_USER_TOKEN }}@github.com/mesosphere".insteadOf "https://github.com/mesosphere" | ||
git config --global url."https://${{ secrets.MESOSPHERECI_USER_TOKEN }}:[email protected]/mesosphere".insteadOf ssh://[email protected]/mesosphere | ||
- name: Build vSphere template for ${{ matrix.os }} with ${{ matrix.buildConfig }} configuration | ||
uses: magefile/mage-action@v2 | ||
with: | ||
version: latest | ||
args: runE2e "${{ matrix.os }}" "${{ matrix.buildConfig }}" ova false | ||
env: | ||
SSH_BASTION_KEY_CONTENTS: ${{ secrets.SSH_BASTION_KEY_CONTENTS }} | ||
SSH_BASTION_HOST: ${{ secrets.SSH_BASTION_HOST }} | ||
SSH_BASTION_USERNAME: ${{ secrets.SSH_BASTION_USERNAME }} | ||
SSH_BASTION_PUBLIC_KEY_CONTENTS: ${{ secrets.SSH_BASTION_PUBLIC_KEY_CONTENTS }} | ||
VSPHERE_USERNAME: ${{ secrets.VSPHERE_USERNAME }} | ||
VSPHERE_USER: ${{ secrets.VSPHERE_USERNAME }} # required for terraform | ||
VSPHERE_PASSWORD: ${{ secrets.VSPHERE_PASSWORD }} | ||
GITHUB_TOKEN: ${{ secrets.MESOSPHERECI_USER_TOKEN }} | ||
VSPHERE_SERVER: ${{ secrets.VSPHERE_SERVER }} | ||
VSPHERE_DATASTORE: ${{ secrets.VSPHERE_DATASTORE }} | ||
|
||
- name: Run make destroy to clean up failed tests | ||
if: ${{ always() }} | ||
run: make infra.vsphere.destroy || true | ||
env: | ||
SSH_BASTION_PUBLIC_KEY_CONTENTS: ${{ secrets.SSH_BASTION_PUBLIC_KEY_CONTENTS }} | ||
VSPHERE_USERNAME: ${{ secrets.VSPHERE_USERNAME }} | ||
VSPHERE_USER: ${{ secrets.VSPHERE_USERNAME }} # required for terraform | ||
VSPHERE_PASSWORD: ${{ secrets.VSPHERE_PASSWORD }} | ||
GITHUB_TOKEN: ${{ secrets.MESOSPHERECI_USER_TOKEN }} | ||
VSPHERE_SERVER: ${{ secrets.VSPHERE_SERVER }} | ||
VSPHERE_DATASTORE: ${{ secrets.VSPHERE_DATASTORE }} | ||
VSPHERE_DATACENTER: ${{ secrets.VSPHERE_DATACENTER }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,6 +66,12 @@ jobs: | |
uses: webfactory/[email protected] | ||
with: | ||
ssh-private-key: ${{ secrets.SSH_BASTION_KEY_CONTENTS }} | ||
|
||
# configure git to access private repo hosting vsphere module mesosphere/vcenter-tools | ||
- name: Configure git to clone private registry from mesosphere org | ||
run: | | ||
git config --global url."https://git:${{ secrets.MESOSPHERECI_USER_TOKEN }}@github.com/mesosphere".insteadOf "https://github.com/mesosphere" | ||
git config --global url."https://${{ secrets.MESOSPHERECI_USER_TOKEN }}:[email protected]/mesosphere".insteadOf ssh://[email protected]/mesosphere | ||
- name: Run E2E test for ${{ matrix.os }} with ${{ matrix.buildConfig }} configuration | ||
uses: magefile/mage-action@v2 | ||
|
@@ -74,11 +80,24 @@ jobs: | |
args: runE2e "${{ matrix.os }}" "${{ matrix.buildConfig }}" ova true | ||
env: | ||
SSH_BASTION_KEY_CONTENTS: ${{ secrets.SSH_BASTION_KEY_CONTENTS }} | ||
SSH_BASTION_HOST: ${{ secrets.SSH_BASTION_HOST }} | ||
SSH_BASTION_USERNAME: ${{ secrets.SSH_BASTION_USERNAME }} | ||
SSH_BASTION_PUBLIC_KEY_CONTENTS: ${{ secrets.SSH_BASTION_PUBLIC_KEY_CONTENTS }} | ||
VSPHERE_USERNAME: ${{ secrets.VSPHERE_USERNAME }} | ||
VSPHERE_USER: ${{ secrets.VSPHERE_USERNAME }} # required for terraform | ||
VSPHERE_PASSWORD: ${{ secrets.VSPHERE_PASSWORD }} | ||
GITHUB_TOKEN: ${{ secrets.MESOSPHERECI_USER_TOKEN }} | ||
VSPHERE_SERVER: ${{ secrets.VSPHERE_SERVER }} | ||
VSPHERE_DATASTORE: ${{ secrets.VSPHERE_DATASTORE }} | ||
VSPHERE_DATACENTER: ${{ secrets.VSPHERE_DATACENTER }} | ||
|
||
- name: Run make destroy to clean up failed tests | ||
if: ${{ always() }} | ||
run: make infra.vsphere.destroy || true | ||
env: | ||
SSH_BASTION_PUBLIC_KEY_CONTENTS: ${{ secrets.SSH_BASTION_PUBLIC_KEY_CONTENTS }} | ||
VSPHERE_USERNAME: ${{ secrets.VSPHERE_USERNAME }} | ||
VSPHERE_USER: ${{ secrets.VSPHERE_USERNAME }} # required for terraform | ||
VSPHERE_PASSWORD: ${{ secrets.VSPHERE_PASSWORD }} | ||
GITHUB_TOKEN: ${{ secrets.MESOSPHERECI_USER_TOKEN }} | ||
VSPHERE_SERVER: ${{ secrets.VSPHERE_SERVER }} | ||
VSPHERE_DATASTORE: ${{ secrets.VSPHERE_DATASTORE }} | ||
VSPHERE_DATACENTER: ${{ secrets.VSPHERE_DATACENTER }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,16 @@ | ||
#!/bin/bash | ||
set -eu | ||
# shellcheck disable=SC2001 | ||
echo "${SSH_BASTION_KEY_CONTENTS}" | sed 's/\\n/\n/g' >> vsphere-tests.pem | ||
chmod 600 vsphere-tests.pem | ||
|
||
SSH_BASTION_HOST="$("${TERRAFORM_BIN}" -chdir=.local/infra/vsphere output -raw bastion_node_ssh_nat_address)" | ||
export SSH_BASTION_HOST | ||
|
||
SSH_BASTION_PORT="$("${TERRAFORM_BIN}" -chdir=.local/infra/vsphere output -raw bastion_node_ssh_nat_port)" | ||
export SSH_BASTION_PORT | ||
|
||
SSH_BASTION_USERNAME="$("${TERRAFORM_BIN}" -chdir=.local/infra/vsphere output -raw bastion_node_ssh_user)" | ||
export SSH_BASTION_USERNAME | ||
|
||
"${ENVSUBST_ASSETS}"/envsubst < test/infra/vsphere/packer-vsphere-airgap.yaml.tmpl >> "$1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
resource "random_id" "build_id" { | ||
byte_length = 8 | ||
} | ||
module "bastion_node" { | ||
source = "github.com/mesosphere/vcenter-tools/modules/vmclone" | ||
|
||
node_name = "konvoy-image-builder-bastion-${random_id.build_id.hex}" | ||
ssh_public_key = file(var.ssh_public_key) | ||
|
||
datastore_name = var.datastore_name | ||
datastore_is_cluster = false | ||
vm_template_name = var.bastion_base_template | ||
resource_pool_name = var.resource_pool_name | ||
root_volume_size = var.root_volume_size #80 | ||
vsphere_folder = var.vsphere_folder | ||
ssh_user = var.ssh_user | ||
custom_attribute_owner = var.bastion_owner | ||
custom_attribute_expiration = "4h" | ||
vsphere_network = var.vsphere_network | ||
} | ||
|
||
output "bastion_node_ssh_user" { | ||
value = var.ssh_user | ||
} | ||
|
||
output "bastion_node_ssh_nat_address" { | ||
value = module.bastion_node.nat_address | ||
} | ||
|
||
output "bastion_node_ssh_nat_port" { | ||
value = module.bastion_node.nat_ssh_port | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.