-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: add packer, and govc files (#20)
* docs: add packer and govc files * docs: update readme * Update edge-native/vmware/README.md * docs: update the dockerfile * docs: initial commit * docs: replace PACKER_DEST var in the Dockerfile * docs: rename edge-native to edge * docs: update Dockerfile * docs: separate out manifest * docs: add readme * docs: typo * docs: merge prereqs and requirements * docs: update readme * Update terraform/edge-tf/profile.tf * docs: remove terraform * docs: remove edge-tf
- Loading branch information
Showing
12 changed files
with
441 additions
and
3 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
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 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,77 @@ | ||
# Overview | ||
This directory contains the files referenced in the [Deploy an Edge Cluster on VMware](https://docs.spectrocloud.com/clusters/edge/deploy-cluster) tutorial. Use the files in this directory with the tutorial. The following code block shows the list of files. | ||
|
||
|
||
```bash | ||
. | ||
└── vmware | ||
├── README.md | ||
├── clone_vm_template | ||
│ ├── delete-edge-host.sh # Deletes the VMs | ||
│ ├── deploy-edge-host.sh # Provisions the VMs | ||
│ └── setenv.sh # Defines the GOVC environment variables | ||
└── packer | ||
├── build.pkr.hcl # Packer build script | ||
├── meta-data # Sample template | ||
├── user-data # Sample template | ||
└── vsphere.hcl # Contains the VM template name, VM configuration, and ISO file name | ||
``` | ||
|
||
|
||
The **vmware/packer/** folder contains the Packer code responsible for creating a VM template in VMWare vCenter from the Edge installer ISO image. Here is a brief description of files present in this folder: | ||
|
||
- **build.pkr.hcl** is the Packer build script. | ||
|
||
- **vsphere.hcl** defines the VM template name, VM configuration, and ISO file name to use. The VM configuration conforms to the [minimum device requirements](https://docs.spectrocloud.com/clusters/edge/architecture/#minimumdevicerequirements). | ||
|
||
- **meta-data** and **user-data** are sample template files. These file are optional for the build process. | ||
|
||
|
||
The **vmware/clone_vm_template** folder contains the shell scripts containing GOVC command line instructions. Here is a brief description of the files present in this folder: | ||
|
||
- **delete-edge-host.sh** provisions the VMs | ||
|
||
- **deploy-edge-host.sh** deletes the VMs. | ||
|
||
- **setenv.sh** defines the GOVC environment variables, the number of VMs, a prefix string for the VM name, and the VM template name. | ||
|
||
# Dependencies | ||
Your environment must have Packer and GOVC installed. The tutorials container comes with these dependencies pre-installed. If you are not using the tutorials container, you must install these dependencies on your machine. Here are the instructions to install these on a Linux machine. | ||
|
||
To install Packer, refer to these official [instructions](https://developer.hashicorp.com/packer/tutorials/docker-get-started/get-started-install-cli). | ||
|
||
To install GOVC, you must first install Go using the following instructions: | ||
```bash | ||
wget https://go.dev/dl/go1.20.5.linux-amd64.tar.gz | ||
sudo tar -C /usr/local -xzf go1.20.5.linux-amd64.tar.gz | ||
export PATH=$PATH:/usr/local/go/bin | ||
go version | ||
``` | ||
After installing Go, you can install [GOVC CLI utility](https://github.com/vmware/govmomi/tree/main/govc) and `xorriso` dependency as: | ||
```bash | ||
curl -L -o - "https://github.com/vmware/govmomi/releases/latest/download/govc_$(uname -s)_$(uname -m).tar.gz" | tar -C /usr/local/bin -xvzf - govc | ||
sudo apt-get install -y xorriso | ||
``` | ||
|
||
|
||
# Prerequisites | ||
To use the Packer and GOVC files, you need the following VMWare permissions: | ||
|
||
```bash | ||
Datastore.AllocateSpace | ||
Host.Config.AdvancedConfig | ||
Host.Config.NetService | ||
Host.Config.Network | ||
Network.Assign | ||
System.Anonymous | ||
System.Read | ||
System.View | ||
VApp.Import | ||
VirtualMachine.Config.AddNewDisk | ||
VirtualMachine.Config.AdvancedConfig | ||
``` | ||
|
||
You will need the VMWare vCenter server URL, login credentials, and names of the data center, destination datastore, resource pool, destination folder (not on Datastore, on the vSphere logical view), cluster, and DHCP enabled network to be assigned to the VM template. | ||
|
||
|
||
Refer to the [Deploy an Edge Cluster on VMware](https://docs.spectrocloud.com/clusters/edge/deploy-cluster) tutorial to learn how to use Packer and GOVC files present in this folder. |
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,22 @@ | ||
#!/bin/bash | ||
|
||
source ./setenv.sh | ||
|
||
set -o errexit | ||
set -o nounset | ||
set -o pipefail | ||
|
||
vm_array=( $(seq 1 $NO_OF_VMS ) ) | ||
|
||
|
||
echo "Cleaning Previous VMs on vSphere" | ||
|
||
for VM in ${vm_array[@]}; | ||
do | ||
echo "Getting UUID $VM_PREFIX-$VM" | ||
UUID=$(govc vm.info $VM_PREFIX-$VM | grep UUID: | sed "s/.* //" | sed "s/-//g") | ||
if govc vm.destroy $VM_PREFIX-$VM #> /dev/null 2>&1 | ||
then | ||
echo "Deleted $VM_PREFIX-$VM" | ||
fi | ||
done |
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,33 @@ | ||
#!/bin/bash | ||
|
||
source ./setenv.sh | ||
|
||
set -o errexit | ||
set -o nounset | ||
set -o pipefail | ||
|
||
vm_array=( $(seq 1 $NO_OF_VMS ) ) | ||
|
||
|
||
for VM in ${vm_array[@]}; | ||
do | ||
if govc vm.clone -link=true -m 8000 -on=false -vm $GOVC_FOLDER/$INSTALLER_TEMPLATE $VM_PREFIX-$VM | ||
then | ||
echo "Cloned VM $VM_PREFIX-$VM" | ||
else | ||
echo "Failed to clone VM $VM_PREFIX-$VM" | ||
fi | ||
|
||
echo "Powering on VM $VM_PREFIX-$VM" | ||
if ! govc vm.power -on=true -wait=false $VM_PREFIX-$VM | ||
then | ||
echo "Failed to power on VM $VM_PREFIX-$VM" | ||
fi | ||
|
||
echo "Getting UUID $VM_PREFIX-$VM" | ||
# govc vm.info got uuid with middle ending, need to convert the first 3 components | ||
u=$(govc vm.info $VM_PREFIX-$VM | grep UUID: | sed "s/.* //" | sed "s/-//g") | ||
UUID=${u:6:2}${u:4:2}${u:2:2}${u:0:2}${u:10:2}${u:8:2}${u:14:2}${u:12:2}${u:16} | ||
echo "Edge Host ID VM $VM_PREFIX-$VM : edge-$UUID" | ||
done | ||
|
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,21 @@ | ||
#!/bin/bash | ||
# Number of VMs to provision | ||
export NO_OF_VMS=3 | ||
export VM_PREFIX="demo" | ||
export INSTALLER_TEMPLATE="palette-edge-template" | ||
|
||
################################################## | ||
#### DO NOT MODIFY BELOW HERE #################### | ||
################################################## | ||
|
||
# GOVC Properties | ||
# vCenter Endpoint | ||
export GOVC_URL="https://${vcenter_server}" # Use HTTPS. For example, https://vcenter.company.com | ||
export GOVC_USERNAME="${vcenter_username}" | ||
export GOVC_PASSWORD="${vcenter_password}" | ||
export GOVC_INSECURE=1 #1 if insecure | ||
export GOVC_DATACENTER="${vcenter_datacenter}" | ||
export GOVC_DATASTORE="${vcenter_datastore}" | ||
export GOVC_NETWORK="${vcenter_network}" | ||
export GOVC_RESOURCE_POOL="${vcenter_resource_pool}" | ||
export GOVC_FOLDER="${vcenter_folder}" |
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,21 @@ | ||
#!/bin/bash | ||
export vcenter_server="Enter a value" # Example: vcenter.spectrocloud.dev | ||
export vcenter_username="Enter a value" | ||
export vcenter_password="Enter a value" | ||
export vcenter_datacenter="Enter a value" | ||
export vcenter_datastore="Enter a value" | ||
export vcenter_resource_pool="Enter a value" | ||
export vcenter_folder="Enter a value" | ||
export vcenter_cluster="Enter a value" | ||
export vcenter_network="Enter a value" | ||
|
||
|
||
export PKR_VAR_vcenter_server=${vcenter_server} | ||
export PKR_VAR_vcenter_username=${vcenter_username} | ||
export PKR_VAR_vcenter_password=${vcenter_password} | ||
export PKR_VAR_vcenter_datacenter=${vcenter_datacenter} | ||
export PKR_VAR_vcenter_datastore=${vcenter_datastore} | ||
export PKR_VAR_vcenter_resource_pool=${vcenter_resource_pool} | ||
export PKR_VAR_vcenter_folder=${vcenter_folder} | ||
export PKR_VAR_vcenter_cluster=${vcenter_cluster} | ||
export PKR_VAR_vcenter_network=${vcenter_network} |
Oops, something went wrong.