Ansible AWX Operator on Ubuntu with MicroK8s

I wrote this up as the official Ansible AWX Operator docs contain instructions on using MiniKube, which is perfectly fine. When using Ubuntu, I’d prefer to stick with MicroK8s as it is set up as a snap install or an option when installing Ubuntu from a disk image. For these steps we are using the latest Ubuntu 21.10 Server and AWX-Operator 0.15.0.

Preparing for the AWX Install


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#Starting fresh if you did not select to install microk8s from the OS installer
sudo snap install microk8s --classic

#Enabling DNS and Storage modules for MicroK8s
microk8s enable storage dns

#Alias the kubectl command
echo "alias kubectl='microk8s.kubectl'" >> ~/.bash_aliases && source ~/.bash_aliases

#Symlink the microk8s.kubectl bin to kubectl. Typically you just
#alias this, however the AWX-Operator make step fails unless you do this
sudo ln -s /snap/bin/microk8s.kubectl /snap/bin/kubectl

#Your user will not be in the microk8s group. We will add it and reboot
#so that the user can run kubectl without sudo
sudo usermod -a -G microk8s $USER


#By default Ubuntu Server does not include the make package so let's install it
sudo apt install make

#Clone awx-operator repo and change the HEAD to 0.15.0
git clone https://github.com/ansible/awx-operator.git
cd awx-operator
git checkout 0.15.0

AWX Operator Install

This is pretty much covered by the official documentation here: https://github.com/ansible/awx-operator#basic-install


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
export NAMESPACE=awx-namespace
make deploy

#Create our awx.yml deployment file
cat > awx.yml <<EOF
---
apiVersion: awx.ansible.com/v1beta1
kind: AWX
metadata:
  name: awx
spec:
  service_type: nodeport
EOF

#Set default context to awx-namespace
kubectl config set-context --current --namespace=awx-namespace

#Deploy AWX and expose the service
kubectl apply -f ~/.awx.yml

#Monitor the deployment process
kubectl logs -f deployments/awx-operator-controller-manager -c awx-manager

#When deployment is done, ensure all pods are running
kubectl get pods

#If all pods are running find the port that AWX is running on and it should
#be accessible via the localhost or if this is a VM, the private IP
kubectl get services awx-service

#Don't forget to get your admin user password for login
kubectl get secret awx-demo-admin-password -o jsonpath="{.data.password}" | base64 --decode

Troubleshooting

awx-postgres-0 stuck in pending state
If you find that the awx-postgres-0 container is stuck in pending, it is likely that it is failing to get a persistent volume claim. This is because the ‘make deploy’ step was run without the storage module being enabled in MicroK8s. To resolve simply follow these steps


1
2
3
4
5
6
7
8
9
#Remove your awx pods
kubectl delete -f awx.yml
#Remove awx operator deployment
cd ~/awx-operator
make undeploy
#Re-Deploy the Operator
make deploy
#Once the deploy has completed, re-apply the awx pod
kubectl apply -f awx.yml

Leave a Reply

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