Skip to content

Matt Adam

Tech Blog

Menu
  • Home
  • Home Lab
    • Home Lab
    • Home Lab with NSX-T
  • Tanzu
    • Tanzu – TKGs (WCP)
  • Avi Kubernetes Operator (AKO)
  • About
  • Privacy Policy
Menu

Tanzu Kubernetes on vCenter 7 with NSX-T – Deploy an Application (Blue)

Posted on July 15, 2022July 15, 2022 by Matt Adam

This is really the final step in setting up TKGs, testing the deployment. We will create a simple 2 pod deployment and use the NSX as the load balancer.

Table of Contents

  • Deploy the Blue Application in Tanzu Guest Cluster
    • Login to the guest cluster and enable privileges
    • Create file blue-deployment-l4.yaml
    • Apply the blue-deployment-l4.yaml file
    • Validate the NSX Load Balancer
    • Test the Application

Deploy the Blue Application in Tanzu Guest Cluster

Login to the guest cluster and enable privileges

Run the following commands to login to the vSphere Tanzu cluster, and switch context to the new guest cluster that was created. By default Tanzu has a fair amount of Pod security, and we will be restricted in what we can create, unless we open up the access. Since this is a lab environment, it should not be an issue. The last command will essentially provide full access for creating services, deployments, pods, etc. More info: https://docs.vmware.com/en/VMware-vSphere/7.0/vmware-vsphere-with-tanzu/GUID-4CCDBB85-2770-4FB8-BF0E-5146B45C9543.html

kubectl vsphere login --vsphere-username administrator@vsphere.local --server=https://10.10.4.50 --insecure-skip-tls-verify --tanzu-kubernetes-cluster-namespace=dev --tanzu-kubernetes-cluster-name=tkg-cluster-01
kubectl config use-context tkg-cluster-01
kubectl create clusterrolebinding psp:authenticated --clusterrole=psp:vmware-system-privileged --group=system:authenticated

Create file blue-deployment-l4.yaml

Use nano/vi/vim or your favorite editor and create this file.

apiVersion: apps/v1
kind: Deployment
metadata:
  name: blue
spec:
  selector:
    matchLabels:
      app: blue
  replicas: 2
  template:
    metadata:
      labels:
        app: blue
    spec:
      containers:
      - name: blue
        image: mattadam07/bluegreen:latest
        ports:
        - containerPort: 5000
        env:
        - name: app_color
          value: "blue"
---
apiVersion: v1
kind: Service
metadata:
  name: blue
spec:
  type: LoadBalancer
  ports:
  - name: http
    port: 80
    targetPort: 5000
    protocol: TCP
  selector:
    app: blue

Apply the blue-deployment-l4.yaml file

kubectl apply -f blue-deployment-lb.yaml
deployment.apps/blue created
service/blue created

Run “kubectl get pods” to see the status. You will see the following if done correctly

deployment.apps/blue created
service/blue created
kubectl get pods
NAME                   READY   STATUS    RESTARTS   AGE
blue-c967796c6-p24kc   1/1     Running   0          76s
blue-c967796c6-sfk7s   1/1     Running   0          76s

Check the services and see if the LoadBalancer endpoint was created successfully. The IP 10.10.4.18 should now be accessible and you should be able to test it.

kubectl get services
NAME                                   TYPE           CLUSTER-IP    EXTERNAL-IP   PORT(S)          AGE
blue                                   LoadBalancer   10.96.1.2     10.10.1.3     80:31665/TCP     77s
tkg-cluster-01-control-plane-service   LoadBalancer   10.96.0.112   10.10.1.4     6443:30502/TCP   20m

Validate the NSX Load Balancer

Here is the load balancer.

Test the Application

And lastly let’s test the URL: http://10.10.1.3/

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recent Posts

  • ESXi Power Management Setting
  • AKO – L7 Ingress on vSphere with Kubernetes (WCP – TKGs) with NSX-T
  • Tanzu Kubernetes on vCenter 7 with NSX-T – Deploy an Application (Blue)
  • Tanzu Kubernetes on vCenter 7 – Deploy Supervisor Cluster (WCP) with NSX-T
  • Home Lab – Deploy vyos Router

About

My name is Matt Adam and I’m a Product Line Manager at VMware.

I support the NSX Advanced Load Balancer (Avi Networks) with a focus on containers and Kubernetes. I have a background in load balancing, automation, development, and public cloud.

© 2022 Matt Adam | Powered by Minimalist Blog WordPress Theme