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
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