> For the complete documentation index, see [llms.txt](https://learn.farizizwan.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://learn.farizizwan.com/devops-and-devsecops/kubernetes/poc-lab/awx-ansible-tower-deployment-on-kubernetes/lab-3-ingress-networking-and-connectivity-via-nginx.md).

# Lab 3 -  Ingress Networking & Connectivity via Nginx

### **Lab Objective**

In this lab we will establish Ingress networking via Nginx Ingress Controller so we are able to access the AWX from the FQDN address.&#x20;

### Deployment Steps

**Step 1: Create Nginx Ingress**

Create <mark style="color:yellow;">`awx-nginx-ingress.yml`</mark>file with the following content

````yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: awx-ingress
  namespace: awx
spec:
  ingressClassName: nginx
  rules:
  - host: tower.home-cloud01.lab
    http:
      paths:
        - path: /
          pathType: Prefix
          backend:
            service:
              name: awx-instance-serivce
              port:
                number: 30000
```
````

**Step 2: Ensure Minikube has Nginx Ingress Classes**

`$ minikube addons enable ingress`

<figure><img src="https://4081356430-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfpkGw9BiJgzxmKhSpJNH%2Fuploads%2FOIcwL9hi3MoprlRKmQtf%2Fin%20class.png?alt=media&amp;token=02bbe377-e658-4dd7-8fa2-90b2ebe721f5" alt=""><figcaption><p>Once enable, we shall see nginx available in Ingress Classes</p></figcaption></figure>

**Step 3: Deploy Ingress Nginx.**

**Run below command,**

$ kubectl apply -f awx-nginx-ingress.yml

Above command will create below Ingress object

<figure><img src="https://4081356430-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfpkGw9BiJgzxmKhSpJNH%2Fuploads%2FuQt3iNLneruI4iHu19d9%2Fawx%20ing%20nginx.png?alt=media&amp;token=e41f72c5-63fd-4fc8-824a-03368c19ccc5" alt=""><figcaption><p>awx-nginx-ingress object created</p></figcaption></figure>

To see more details about our HTTP/HTTPS network routing, we shall be able to describe the object by running the following command.

`$ kubectl describe ingress-nginx`

<figure><img src="https://4081356430-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfpkGw9BiJgzxmKhSpJNH%2Fuploads%2FVAoyBNvPcMesfWXDDLN7%2Fdesc%20nginx.png?alt=media&amp;token=6898c66d-fb27-42c0-a40d-8186a198a696" alt=""><figcaption><p>More details can be seen when we describe the object</p></figcaption></figure>

As you can see on the above image, my specified subdomain tower.home-cloud01.lab was routed to the backend service - awx-nginx-service (the AWX service) on port 80.&#x20;

#### Step 4: Modify hosts file

We will need to modify hosts file in our host server.&#x20;

`$ kubectl get ingress awx-nginx-ingress -n awx | grep -v NAME | awk -F' ' '{print $4 " " $3 }' | sudo tee -a /etc/hosts`

Verify the host has been added into the `/etc/hosts` file

<figure><img src="https://4081356430-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfpkGw9BiJgzxmKhSpJNH%2Fuploads%2FNIXWyr4wkNRFX1PRKVxj%2Fhs.png?alt=media&amp;token=2b136403-fb1e-43b4-97bb-81f42deb0a7c" alt=""><figcaption><p>my /etc/hosts file</p></figcaption></figure>

**Step 5: Verify the connectivity.**

So now we have the Ingress setup for our network routes. Let's test the connection.

`$ curl -L -q http://tower.home-cloud01.lab/api/v2/ping 2>/dev/null`

If you get the same response as per the following image, then you are in a good conditions.

<figure><img src="https://4081356430-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfpkGw9BiJgzxmKhSpJNH%2Fuploads%2FjXJEFNqGMblG9knZKGI3%2Ffine.png?alt=media&amp;token=ea52fa56-cd2f-4907-a036-e91ddbef5b01" alt=""><figcaption><p>Ping response via the Ping API's</p></figcaption></figure>

**Congratulations!** Now you have the AWX up and runninng in your Kubernetes cluster.

Next we will explore on the Day 2 operations where we will access the AWX from the Web console.

*\~End of Lab 3 -* Ingress Networking & Connectivity via Ngin&#x78;*\~*

[*Continue to Lab 4: AWX Web Console & accessibility on LAN*](https://learn.farizizwan.com/devops-and-devsecops/kubernetes/poc-lab/awx-ansible-tower-deployment-on-kubernetes/lab-4-awx-web-console-and-accessibility-on-lan.md)
