Supervisor with "NSX + DTGW/VNA"
This section describes the procedures for deploying an application (VMs/K8s) into the VKS Namespace utilizing an "NSX + DTGW/VNA" architecture inside a vSphere environment.
- Deploy App (VMs)
- Deploy App (K8s)
Deploy App (VMs)
Client Operating System
While the command outputs below are captured from a Windows client, the vcf and kubectl CLI tools operate identically across Linux and macOS environments.
Deploy a Full Application (Load Balancer + VMs)
Connect to Supervisor Namespace
Create application (LB + 2 VMs apache) yaml file
Create file "my-web-farm.yaml"
my-web-farm.yaml file
apiVersion: v1
kind: Secret
metadata:
name: ubuntu-cloud-init
namespace: demo-space
stringData:
user-data: |
#cloud-config
package_update: true
packages:
- apache2
- unzip
- open-vm-tools
- net-tools
- php
- libapache2-mod-php
# Create the user and add to sudo group
users:
- default
- name: demouser
groups: sudo
shell: /bin/bash
lock_passwd: false
# Set the plain-text password and prevent it from expiring immediately
chpasswd:
list: |
demouser:VMware123!VMware123!
expire: false
# Allow password authentication over SSH
ssh_pwauth: true
# Overwrite the default Apache page to show the VM hostname
runcmd:
- echo "<h1>Hello from $(hostname)</h1>" > /var/www/html/index.html
- systemctl enable --now apache2
- iptables -I INPUT 1 -p tcp --dport 80 -j ACCEPT
---
apiVersion: vmoperator.vmware.com/v1alpha5
kind: VirtualMachine
metadata:
name: web-vm-1
namespace: demo-space
labels:
app: web-pool # <-- The label tying it to the Load Balancer
spec:
className: best-effort-small
imageName: noble-server-cloudimg-amd64
storageClass: vsan-default-storage-policy
powerState: PoweredOn
bootstrap:
cloudInit:
rawCloudConfig:
name: ubuntu-cloud-init
key: user-data
---
apiVersion: vmoperator.vmware.com/v1alpha5
kind: VirtualMachine
metadata:
name: web-vm-2
namespace: demo-space
labels:
app: web-pool # <-- The label tying it to the Load Balancer
spec:
className: best-effort-small
imageName: noble-server-cloudimg-amd64
storageClass: vsan-default-storage-policy
powerState: PoweredOn
bootstrap:
cloudInit:
rawCloudConfig:
name: ubuntu-cloud-init
key: user-data
---
apiVersion: vmoperator.vmware.com/v1alpha5
kind: VirtualMachineService
metadata:
name: web-lb-vip
namespace: demo-space
spec:
type: LoadBalancer
ports:
- name: http
port: 80
targetPort: 80
protocol: TCP
selector:
app: web-pool
Deploy the application (LB + 2 VMs apache)
kubectl apply -f my-web-farm.yaml
Output example
PS C:\Users\Administrator\Documents> kubectl apply -f my-web-vm.yaml
secret/ubuntu-cloud-init created
virtualmachine.vmoperator.vmware.com/web-vm-1 created
virtualmachine.vmoperator.vmware.com/web-vm-2 created
virtualmachineservice.vmoperator.vmware.com/web-lb-vip created
Validate deployment of the application (LB + 2 VMs apache)
-
Check application VIP
kubectl get service web-lb-vipOutput example
PS C:\Users\Administrator\Documents> kubectl get service web-lb-vip NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE web-lb-vip LoadBalancer 172.29.143.82 10.1.7.137 80/TCP 24sLoad Balancer VM pool status
The Load Balancer does not offer VM pool member healthchecks.
If the VM or the application within the VM crashes, the load balancer will still use that member. -
Check application VMs
kubectl get virtualmachines -o wideOutput example
PS C:\Users\Administrator\Documents> kubectl get virtualmachines -o wide NAME POWER-STATE CLASS IMAGE PRIMARY-IP4 AGE web-vm-1 PoweredOn best-effort-small vmi-4143a3379f59e4a48 172.30.0.3 46s web-vm-2 PoweredOn best-effort-small vmi-4143a3379f59e4a48 172.30.0.4 46
Access the application (LB + 2 VMs apache)
curl http://10.1.7.137
Output example
PS C:\Users\Administrator\Documents> curl http://10.1.7.137
<h1>Hello from web-vm-1</h1>
PS C:\Users\Administrator\Documents> curl http://10.1.7.137
<h1>Hello from web-vm-2</h1>

