Supervisor with "NSX + CTGW/Edge/T0"
This section describes the procedures for deploying an application (VMs/K8s) into the VKS Namespace utilizing an "NSX + CTGW/Edge/T0" architecture inside a vSphere environment.
- Deploy App (VMs)
- Deploy App (K8s)
Deploy App (K8s)
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 + Pods)
Connect to the K8s Cluster
See Connect to the K8s Cluster
(Optional) Create a Namespace in the K8s Cluster
Create a Namespace if you want to deploy the application (pod) in a specific K8s Cluster Namespace (not default).
kubectl create namespace ns1
Output example
PS C:\Users\Administrator\Documents> kubectl create namespace ns1
namespace/ns1 created
Allow the deployment of applications in the Namespace.
kubectl label ns ns1 pod-security.kubernetes.io/enforce=baseline
Output example
PS C:\Users\Administrator\Documents> kubectl label ns ns1 pod-security.kubernetes.io/enforce=baseline
namespace/ns1 labeled
Create application (LB + 2 Pods apache) yaml file
Create file "apache-k8s.yaml"
apache-k8s.yaml file
apiVersion: v1
kind: Service
metadata:
name: apache-vip-service
namespace: ns1
spec:
type: LoadBalancer
ports:
- port: 80
targetPort: 8080
protocol: TCP
selector:
app: apache-web
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: apache-deployment
namespace: ns1
spec:
replicas: 2
selector:
matchLabels:
app: apache-web
template:
metadata:
labels:
app: apache-web
spec:
containers:
- name: apache
image: public.ecr.aws/docker/library/httpd:2.4
ports:
- containerPort: 8080
protocol: TCP
# Intercept startup to write the file, THEN start Apache
command: ["/bin/sh", "-c"]
args:
- 'sed -i "s/Listen 80/Listen 8080/g" /usr/local/apache2/conf/httpd.conf && echo "<h1>It works - Pod: $HOSTNAME</h1>" > /usr/local/apache2/htdocs/index.html && httpd-foreground'
Deploy the application (LB + 2 Pods apache)
kubectl apply -f apache-k8s.yaml
Output example
PS C:\Users\Administrator\Documents> kubectl apply -f apache-k8s.yaml
service/apache-vip-service created
deployment.apps/apache-deployment created
Validate deployment of the application (LB + 2 Pods apache)
-
Check application VIP
kubectl get service apache-vip-service -n ns1Output example
PS C:\Users\Administrator\Documents> kubectl get service apache-vip-service -n ns1 NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE apache-vip-service LoadBalancer 10.101.142.113 10.150.0.9 80:30869/TCP 53s -
Check application Pods
kubectl get pods -n ns1Output example
PS C:\Users\Administrator\Documents> kubectl get pods -n ns1 NAME READY STATUS RESTARTS AGE apache-deployment-58bf9564f6-57zdv 1/1 Running 0 28s apache-deployment-58bf9564f6-fmll8 1/1 Running 0 28s
Access the application (LB + 2 Pods apache)
curl http://10.150.0.9
Output example
PS C:\Users\Administrator\Documents> curl http://10.150.0.9
<h1>It works - Pod: apache-deployment-58bf9564f6-fmll8</h1>
PS C:\Users\Administrator\Documents> curl http://10.150.0.9
<h1>It works - Pod: apache-deployment-58bf9564f6-57zdv</h1>
The external load balancer (NSX) load balances (round-robin mode) to the Worker Nodes. Then, each Worker Node load balances to the Apache pods (random). So, to validate the load balancing to the different Apache pods, run the curl command multiple times.

