How to Install Ansible AWX on Kubernetes Minikube

Hello Geeks, I hope you are aware about Ansible AWX, if not then Ansible AWX is a Web based GUI tool for managing ansible playbooks. There are lot of other features of AWX apart from execution of Ansible playbooks like source management integration, logging RBAC and more.

In other words, we can say Ansible AWX is considered as an upstream project of Red HAT Ansible Tower. From AWX version 18.x and onwards, installation focus is moved from docker to Kubernetes. So, in this article, we will cover the step by step Ansible AWX Installation on Kubernetes Minikube.

I am assuming Minikube is already installed on your Linux system. If not, then use below URL:

Note: Make sure you start your minikube cluster with enough resources (at least 4 vCPU and 8 GB RAM) , in my case I have started minikube with following resources and options.

$ minikube start --addons=ingress --cpus=4 --cni=flannel --install-addons=true --kubernetes-version=stable --memory=8g

Verify the Minikube Cluster Installation

Run following commands to verify the minikube installation and cluster status,

$ minikube status
$ kubectl cluster-info
$ kubectl get nodes

Output of above commands should look like below:

Minikube-Installation-Cluster-Check

Perfect, above confirms that minikube has been installed and started successfully. Let’s move to AWX installation steps.

Step 1) Install AWX Operator

To install AWX operator, execute the following kubectl command,

$ kubectl apply -f https://raw.githubusercontent.com/ansible/awx-operator/0.12.0/deploy/awx-operator.yaml

Output

Install-AWX-Operator-kubectl-command

Run below command to confirm whether AWX operator’s pod is started or not. If not started then wait for couple of minutes as it takes time,

[email protected]:~$ kubectl get pods
NAME                           READY   STATUS    RESTARTS   AGE
awx-operator-79bc95f78-pb7tz   1/1     Running   0          5m23s
[email protected]:~$

Step 2) Create AWX Instance yaml file

Create ansible-awx.yml file with the following contents

$ vi ansible-awx.yml
---
apiVersion: awx.ansible.com/v1beta1
kind: AWX
metadata:
  name: ansible-awx
spec:
  service_type: nodeport
  ingress_type: none
  hostname: ansible-awx.example.com

save and quit the file.

Step 3) Deploy Ansible AWX Instance

Now, let’s deploy AWX instance in our cluster by executing below command,

[email protected]:~$ kubectl apply -f ansible-awx.yml
awx.awx.ansible.com/ansible-awx created
[email protected]:~$

Above will create a deployment with a name ’ansible-awx’ and this deployment will have two pods and services.

After couple of minutes, Ansible AWX will be deployed and in case you wish to monitor installation logs then use below command,

$ kubectl logs -f deployment/awx-operator

Run below command to verify the status of AWX Pods,

[email protected]:~$ kubectl get pods -l "app.kubernetes.io/managed-by=awx-operator"
NAME                           READY   STATUS    RESTARTS   AGE
ansible-awx-5ddfccf664-vrdq2   4/4     Running   0          7m40s
ansible-awx-postgres-0         1/1     Running   0          8m24s
[email protected]:~$

Run following command to view the service status,

[email protected]:~$ kubectl get svc -l "app.kubernetes.io/managed-by=awx-operator"
NAME                   TYPE        CLUSTER-IP     EXTERNAL-IP   PORT(S)        AGE
ansible-awx-postgres   ClusterIP   None           <none>        5432/TCP       8m31s
ansible-awx-service    NodePort    10.97.206.89   <none>        80:32483/TCP   7m55s
[email protected]:~$

Please make a note of node port of ‘ansible-awx-service’, we will be using it later for port forwarding.

Step 4) Access AWX Portal via tunneling

To access AWX portal outside of minikube cluster, we must configure the tunneling, run

[email protected]:~$ nohup minikube tunnel &
[3] 35709
[email protected]:~$
[email protected]:~$ kubectl get svc ansible-awx-service
NAME                  TYPE       CLUSTER-IP     EXTERNAL-IP   PORT(S)        AGE
ansible-awx-service   NodePort   10.97.206.89   <none>        80:32483/TCP   90m
[email protected]:~$

Set the port forwarding in such a way that, if the request is coming on minikube IP on node port ‘32483’ then it should be redirected to port 80 of awx pod.

[email protected]:~$ kubectl port-forward svc/ansible-awx-service --address 0.0.0.0 32483:80 &> /dev/null &
[4] 46686
[email protected]:~$

Now try to access AWX portal from the web browser by using minikube ip address and node port 32483

http://<minikube-ip>:<node-port>

Access-Ansible-AWX-Portal-Minikube

To get the credentials, go back to terminal and run beneath command.

[email protected]:~$ kubectl get secret ansible-awx-admin-password -o jsonpath="{.data.password}" | base64 --decode
PWrwGWBFCmpd1b47DJffCtK5SqYGzxXF
[email protected]:~$

Use the username as ‘admin’ and the password as the output of above command, after entering the credentials we will get following dashboard

AWX-Dashboard-minikube

Great, above confirms that Ansible AWX is installed successfully on Kubernetes minikube. That’s all from this article. I hope you have found it informative and in case you have any queries, feel free to write us in below comments section.

Read Also : How to Run and Schedule Ansible Playbook Using AWX GUI

4 thoughts on “How to Install Ansible AWX on Kubernetes Minikube”

  1. Hello,

    I have followed the commands and installed AWX but cannot get UI on the browser. I can telnet on the server but not from outside the server. Can you help me with what might be wrong?

    Thanks

    1. Hi Krishna,

      I would suggest check whether tunneling and port-formatting is configured correctly or not.
      Apart from this also check status of AWX pods.

  2. Hi,
    This is a spot on guide. Thank you. Are there any specific options, so this will start automatically after the server reboot?

    1. Hi Bogdan,
      By default there is no specific option to start the Minikube cluster automatically after the reboot.
      We have to manually start the cluster post reboot.

Leave a Reply

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