Skip to content

Matt Adam

Tech Blog

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

Tanzu Kubernetes Grid – Create an L7 Ingress with Avi

Posted on September 7, 2022September 14, 2022 by Matt Adam

If you’re following along in the guides for TKGm, this is the last step, deploying the L7 ingress with Avi. Please make sure to read the post about deploying the L4 Type LoadBalancer since it covers creating the k8s docker secret: Create an L4 Type LoadBalancer with Avi

Table of Contents

  • Enable Ingress in the management cluster
  • Deploy the Bluegreen Application
    • Create the ingress.yaml file
    • Apply the ingress.yaml file
    • Validation

Enable Ingress in the management cluster

The first step is to navigate back to the management cluster context and edit the adc. By default the ingress features are disabled in tkgm. So we’ll enable ingress on the management cluster, and it will redeploy the AKO instance onto each guest cluster. (Unless labels were used in earlier steps..)

kubectl config use-context management-cluster-1-admin@management-cluster-1
kubectl edit adc install-ako-for-all

Look for and replace the following lines. It’s a vi editor, so “i” to edit, and hit Escape then type “:wq” to save

### FIND ###
    ingress:
      defaultIngressController: false
      disableIngressClass: true

### Replace With ###
    ingress:
      defaultIngressController: true
      disableIngressClass: false
      serviceType: NodePort
      shardVSSize: SMALL

The above will force AKO pod to redeploy, you can see the new pod by running the following:

kubectl config use-context guest-cluster-1-admin@guest-cluster-1
kubectl get pods -n avi-system
kubectl logs ako-0 -n avi-system -f

Give it about a minute or so for the new AKO pod to come up, then proceed.

Deploy the Bluegreen Application

Create the ingress.yaml file

So in the example below this application actually can change color between blue and green, depending on which environment value you set for the variable “app_color” [blue|green]

---
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: alexfeig/bluegreen:latest
        ports:
        - containerPort: 5000
        env:
        - name: app_color
          value: "blue"
      imagePullSecrets:
      - name: regcred
---

---
apiVersion: v1
kind: Service
metadata:
  name: blue
spec:
  type: NodePort
  ports:
  - name: http
    port: 80
    targetPort: 5000
    protocol: TCP
  selector:
    app: blue

---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: blue
spec:
  rules:
  - host: blue.avi.home.lab
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: blue
            port:
              number: 80


As you can see in the example yaml above, we’re creating 3 different objects. A deployment for the application to run 2 pods, a service Type NodePort, and finally a path based ingress.

Apply the ingress.yaml file

Save the above to a file called ingress.yaml and run the following command to apply it:

kubectl apply -f ingress.yaml

Validation

You can see the new pods are created and are in a Running state.
Additionally the blue service has been created!
In Avi we can see the new VS has been created for the application blue.
And of course if your DNS is working and pointing avi.home.lab (or some equivelant) to the Avi DNS, then you should be able to resolve the application.

Leave a Reply Cancel reply

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

Recent Posts

  • Setting up the Kubernetes Dashboard
  • Running a DNS server in K3s
  • Raspberry Pi Kubernetes Cluster
  • Pod Routing: NodePort, ClusterIP, NodePortLocal
  • Configure Bootstrap VM for OpenShift and Install OpenShift with vSphere

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.

© 2023 Matt Adam | Powered by Minimalist Blog WordPress Theme