Skip to content

(A) Basic PhotonOS Patterns

Brendan O'Connor edited this page Jan 24, 2024 · 32 revisions

Pattern A-01: The OVFtool Container

Prerequisites:

Step 1: using the master controller, navigate to the drop repo.

cd /usr/local/drop

Step 2: Verify the VMware-ovftool-4.4.3-18663434-lin.x86_64 bundle has been downloaded.

ls

Should return:

root@photon-machine [ /usr/local/drop ]# ls
VMware-ovftool-4.4.3-18663434-lin.x86_64.bundle

Step 3: build the ovftool container

cd /usr/local/e2e-patterns/photon/
sh build-e2e-pattern-ovftool.sh

Use the following syntax to test or run the ovftool

docker run ovftool --rm -it -v $PWD --help

Pattern A-02: The PowerCLI Container

Prerequisites:

Step 1: using the master controller, navigate to the /usr/local/e2e-patterns/photon repo.

cd /usr/local/e2e-patterns/photon

Step 2: build the powercli container.

sh build-e2e-pattern-pcli.sh

To run the PowerCLI container interactively, run the following:

docker run --rm -it vmware/powerclicore

To run a PowerShell script, run the following (replace sample.ps1 with appropriate script name):

docker run --rm --entrypoint="/usr/bin/pwsh" -v ${PWD}:/tmp vmware/powerclicore /tmp/sample.ps1

NOTE: all PowerShell scripts need to begin with #!/bin/sh otherwise you will receive exec format error from Docker. For example: sample.ps1

#!/bin/sh
echo "Hello World!"

Pattern A-03: The Terraform Container

Prerequisites:

Step 1: using the master controller, navigate to the /usr/local/e2e-patterns/photon repo.

cd /usr/local/e2e-patterns/photon

Step 2: build the terraform container.

sh build-e2ep-terraform.sh

To run the Terraform container interactively, run the following:

docker run -i -t hashicorp/terraform --help

Create main.tf file in a dedicated directory on the Photon appliance and use the following syntax to initialize:

docker  run  -v $(pwd):$(pwd) -w $(pwd) -i -t hashicorp/terraform init

Pattern A-04: Kubernetes

Prerequisites:

Step 1: using the master controller, navigate to the /usr/local/e2e-patterns/minikube repo.

cd /usr/local/e2e-patterns/minikube

Step 2: build the minikube pattern on the Master Controller (small scale) using the -p parameter.

python3 build-e2ep-k8.py -p

Or build the minikube pattern on its own Photon Controller using the -a parameter.

python3 build-e2ep-k8.py -a

Step 3: validate kubectl

kubectl --help

Pattern A-05: The Ansible Container

Prerequisites:

Step 1: using the master controller, navigate to the /usr/local/e2e-patterns/photon repo.

cd /usr/local/e2e-patterns/photon

Step 2: build the ansible container.

sh build-e2ep-ansible.sh

To run the ansible container interactively, run the following:

docker run -i -t alpinelinux/ansible ansible --help

Pattern A-06: Build Photon VM using OVFTool Container

Prerequisites:

  • A-01
  • Download PhotonOS OVA from here.
  • Upload the OVA to /usr/local/drop on the Master Controller.

Step 1: using the master controller, navigate to the /usr/local/e2e-patterns/photon repo:

cd /usr/local/e2e-patterns/photon

Step 2: deploy PhotonOS by running the following script

python3 build-e2ep-photon-with-ovftool.py VMNAME

Example:

python3 build-e2ep-photon-with-ovftool.py photonos-test-01

Pattern A-06A: Get VM IP Address using PowerCLI Container

Prereqisites:

Step 1: using the master controller, navigate to the /usr/local/e2e-patterns/photon repo:

cd /usr/local/e2e-patterns/photon

Step 2: get IP address by running the following script

python3 build-e2ep-get-vm-ip.py VMNAME

Example:

python3 build-e2ep-get-vm-ip.py photonos-test-01 

The IP Address for the provided virtual machine will appear in the _photonos.log.

Pattern A-06B: Change Default PhotonOS Password using PowerCLI Container

Prereqisites:

Step 1: using the master controller, navigate to the /usr/local/e2e-patterns/photon repo:

cd /usr/local/e2e-patterns/photon

Step 2: change the default password by running the following script

python3 build-e2ep-change-default-photonos-pw.py VMNAME NEWPASSWORD

Example:

python3 build-e2ep-change-default-photonos-pw.py photonos-test-01 VMware1VMware1

Pattern A-06C: Change VM IP Address using PowerCLI Container

Prerequisites:

Step 1: using the master controller, navigate to the /usr/local/e2e-patterns/photon repo:

cd /usr/local/e2e-patterns/photon

Step 2: change IP address by running the following script

python3 build-e2ep-change-photon-ip-address.py VMNAME IPADDRESS NETMASK DEFAULTGW

Example:

python3 build-e2ep-change-photon-ip-address.py photonos-test-01 172.16.0.85 255.255.255.0 172.16.0.1

Pattern A-06D: Run command over SSH to a remote Photon VM

Prerequisites:

Step 1: using the master controller, navigate to the /usr/local/e2e-patterns/photon repo:

cd /usr/local/e2e-patterns/photon

Step 2: run command locally using the following script

python3 build-e2ep-run-cmd-over-ssh.py "COMMAND" IPADDRESS USERNAME PASSWORD

Example:

python3 build-e2ep-run-cmd-over-ssh.py "mkdir /usr/local/TEST" 172.16.0.85 root VMware1VMware1

Pattern A-06E: Download script over SSH to a remote Photon VM

Prerequisites:

Step 1: using the master controller, navigate to the /usr/local/e2e-patterns/photon repo:

cd /usr/local/e2e-patterns/photon

Step 2: run command locally using the following script

python3 build-e2ep-download-file-over-ssh.py IPADDRESS USERNAME PASSWORD DOWNLOAD_URL TARGET_FILEPATH TARGET_FILENAME

Example:

python3 build-e2ep-download-file-over-ssh.py 172.16.0.85 root VMware1VMware1 https://raw.githubusercontent.com/boconnor2017/e2e-patterns/main/prep-photon.sh /usr/local/ test.sh

Pattern A-06F: Run script over SSH to a remote Photon VM

Prerequisites:

Step 1: using the master controller, navigate to the /usr/local/e2e-patterns/photon repo:

cd /usr/local/e2e-patterns/photon

Step 2: run remote script using the following script

python3 build-e2ep-run-file-over-ssh.py IPADDRESS USERNAME PASSWORD ENTRYPOINT SHSCRIPT

Example:

python3 build-e2ep-run-file-over-ssh.py  172.16.0.85 root VMware1VMware1 /usr/local/ test.sh

Pattern A-07: Build Pattern Node Controller (i.e. prepped photon vm)

Prerequisites:

Step 1: using the master controller, navigate to the /usr/local/e2e-patterns/photon repo:

cd /usr/local/e2e-patterns/photon

Step 2: build node controller using the following script

python3 build-e2ep-node-controller.py VMNAME

Example:

python3 build-e2ep-node-controller.py  node-test-01
Clone this wiki locally