# Lab 2 -  AWX,AWX Operator Configurations & Deployments

### **Lab Objective**

In this lab we will learns how to deploy & configure AWX as a containers to K8s cluster.

### Deployment Steps

#### **Step 1: Prepare YML files for configurations.**

Basically, only three YML's file required to deploy the AWX onto our K8s cluster.

<figure><img src="/files/wN1NAoa1oaWJNcuQqXUA" alt=""><figcaption><p>Note: The YML files</p></figcaption></figure>

create <mark style="color:yellow;">`kustomization.yml`</mark> file with the following content:

```yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
  # Find the latest tag here: https://github.com/ansible/awx-operator/releases
  - github.com/ansible/awx-operator/config/default?ref=1.1.1 #change to any preference version

# Set the image tags to match the git version from above
images:
  - name: quay.io/ansible/awx-operator
    newTag: 1.1.1 #change to any preference version

# Specify a custom namespace in which to install AWX
namespace: awx
```

as you can see the version of AWX Operator is defined on `newTag` key as well as on the resources key.

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

```yaml
apiVersion: awx.ansible.com/v1beta1
kind: AWX
namespace: awx
metadata:
  name: awx-demo
spec:
  service_type: nodeport
  # default nodeport_port is 30080
  nodeport_port: 30000 #you may change this node port between 30000-32768
```

Here you will see minimal content definitions specified in the YML because AWX Operator has taken care the actual AWX deployment files.

#### **Step 2: Deploy the AWX Operator controller manager.**

Now, with all the k8s object config files in hand, we are going to execute it one by one,

Execute the build in <mark style="color:yellow;">kustomization.ym</mark><mark style="color:yellow;">**l**</mark>

```bash
$ kubectl apply -k .
```

<figure><img src="/files/sdRbM5bUT932IUWxloKU" alt=""><figcaption><p>Objects that has been created</p></figcaption></figure>

Once executed, AWX operator will deploy the following objects on k8s.

<figure><img src="/files/PcoqplO0DMiXSX8km2st" alt=""><figcaption><p>Deployment object</p></figcaption></figure>

<figure><img src="/files/VHDTPjmy0j3Wh980JC8V" alt=""><figcaption><p>Pod object</p></figcaption></figure>

<figure><img src="/files/7ZwRfkox80kmD1AFndja" alt=""><figcaption><p>Replica Sets object</p></figcaption></figure>

<figure><img src="/files/1Xo9Bl4sYTF6ugyQo1Dm" alt=""><figcaption><p>Services object</p></figcaption></figure>

<figure><img src="/files/DAtnStJL02N9o7tkVs4S" alt=""><figcaption><p>ConfigMap object</p></figcaption></figure>

Ensure that all AWX controllers manager objects are up and running,

<figure><img src="/files/WqU5yJbH3nAzHGqzYDRR" alt=""><figcaption></figcaption></figure>

#### Step 3: Deploy the AWX.

Now, this is where we want to execute our AWX deployment.&#x20;

Run<mark style="color:yellow;">`$ kubectl apply -f awx-demo.yml`</mark>

After the execution, we can see below additional objects has been created

<figure><img src="/files/YumBDg6Wnj5JtJYyQsmO" alt=""><figcaption><p>awx-demo and awx-demo-postgres pods created</p></figcaption></figure>

Notes, for the pods to get ready, it might take sometimes so we will just have to wait for a while.

<figure><img src="/files/RbA0t7tItIzypniNf0u2" alt=""><figcaption><p>awx-demo-postgres-13 stateful sets created</p></figcaption></figure>

<figure><img src="/files/X31n1W6ub9HPlkocl7jW" alt=""><figcaption><p>awx-demo-service &#x26; awx-demo-postgres-13 services has been added</p></figcaption></figure>

<figure><img src="/files/vm8OWJPwRPwVxn3tMgAu" alt=""><figcaption><p>awx-demo-awx-configmap created</p></figcaption></figure>

<figure><img src="/files/QZ2OzfVb8E66uYwp3D0y" alt=""><figcaption><p>the PVC for AWX</p></figcaption></figure>

Finally, ensure that all the required secrets has also been created during the deployment.

<figure><img src="/files/UHKHW3WSFiU3RWKzD7Mp" alt=""><figcaption><p>All the secrets </p></figcaption></figure>

**Step 4: Verify all the k8s object resources & connectivity to the service**

At this stage,  we will need to verify below resources has been created inside the `awx` namespace.

Below screenshots is from my end for your references.

<figure><img src="/files/J9tfGzkYQhKD6GakowlM" alt=""><figcaption></figcaption></figure>

**Step 5: Verify connectivity from the Service**

Now we have everythings up and running, we need to do final check and it can be done by the AWX API check.

**Run** `$ minikube service list`

<figure><img src="/files/k7kM71QrWfD9L7NxZPyl" alt=""><figcaption><p>Exposed service in Minikube</p></figcaption></figure>

Referring to above image, this is the URL that we will need to use to query the AWX Ping API's&#x20;

`AWX Service URL: http://192.168.39.154:30000`

To query the API, we can run

`$ curl -L -q http://192.168.39.154:30000/api/v2/ping 2>/dev/null`

or&#x20;

`$ curl -L -q $(minikube service awx-demo-service --url -n awx)/api/v2/ping 2>/dev/null`

We shall receives below response if everythings is good.

<figure><img src="/files/H9QHjBOKgbTYGjmgbBbD" alt=""><figcaption><p>Response from the Ping API's</p></figcaption></figure>

*\~End of Lab 2 - AWX,AWX Operator Configurations & Deployments\~*

[*Continue to Lab 3 - Ingress Networking & Connectivity via Nginx*](/devops-and-devsecops/kubernetes/poc-lab/awx-ansible-tower-deployment-on-kubernetes/lab-3-ingress-networking-and-connectivity-via-nginx.md)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://learn.farizizwan.com/devops-and-devsecops/kubernetes/poc-lab/awx-ansible-tower-deployment-on-kubernetes/lab-2-awx-awx-operator-configurations-and-deployments.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
