Install AWX on k8s
Yet another article on how-to install AWX on k8s? No. There are many good articles already available on how to install AWX on k8s. I used the ones listed below for my installation. This article is a note describing the steps I followed to install AWX on my local k8s cluster.
- [French] Ansible - Installer AWX sur un cluster Kubernetes
- Install Ansible AWX on Kubernetes
- How To Run Ansible AWX on Kubernetes / OpenShift Cluster
Environment:
Component | Version | Note |
---|---|---|
k8s | 1.26.2 | k8s cluster (2 nodes) running on my laptop (see my article for installation) |
1 - Get AWX
git clone https://github.com/ansible/awx-operator.git
cd awx-operator
2 - Install the AWX operator
export NAMESPACE=awx
export RELEASE_TAG=`curl -s https://api.github.com/repos/ansible/awx-operator/releases/latest | grep tag_name | cut -d '"' -f 4`
kubectl create ns ${NAMESPACE}
kubectl config set-context --current --namespace=$NAMESPACE
git checkout $RELEASE_TAG
3 - Prepare PersistentVolumes
First check that you have defined a default storageclass:
✗ kubectl get storageclass
NAME PROVISIONER RECLAIMPOLICY VOLUMEBINDINGMODE ALLOWVOLUMEEXPANSION AGE
local-storage (default) kubernetes.io/no-provisioner Retain WaitForFirstConsumer false 22d
If not use this command to set to default:
kubectl patch storageclass local-storage -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'
I created two PersistentVolume:
---
apiVersion: v1
kind: PersistentVolume
metadata:
name: awx-postgres-13-volume
spec:
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Retain
capacity:
storage: 8Gi
storageClassName: local-storage
hostPath:
path: /data/volumes/postgres-13
---
apiVersion: v1
kind: PersistentVolume
metadata:
name: awx-projects-volume
spec:
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Retain
capacity:
storage: 2Gi
storageClassName: local-storage
hostPath:
path: /data/volumes/projects
4 - Create a AWX server
---
apiVersion: awx.ansible.com/v1beta1
kind: AWX
metadata:
name: awx
spec:
postgres_configuration_secret: awx-postgres-configuration
postgres_storage_class: local-storage
postgres_storage_requirements:
requests:
storage: 8Gi
projects_persistence: true
service_type: nodeport
I choose to have a nodeport to access the AWX console. Check that all the pods are running.
✗ kubectl get pods -n awx
NAME READY STATUS RESTARTS AGE
awx-operator-controller-manager-57867569c4-w6lw9 2/2 Running 2 (147m ago) 18h
awx-postgres-13-0 1/1 Running 1 (147m ago) 17h
awx-task-bc5697fc6-stzgq 4/4 Running 4 (147m ago) 18h
awx-web-6f785f6cd6-rxprj 3/3 Running 3 (147m ago) 18h
✗ kubectl get service -n awx
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
awx-operator-controller-manager-metrics-service ClusterIP 10.97.204.159 <none> 8443/TCP 18h
awx-postgres-13 ClusterIP None <none> 5432/TCP 18h
awx-service NodePort 10.106.206.128 <none> 80:31651/TCP 18h
Get the admin password:
✗ kubectl get secret awx-admin-password -o go-template='\n'
password: 9wvjCf726QyZeNJ79DLzxeOQDpWlxsY7
and connect to the console ( http://192.168.56.3:31651/ in my case). AWX is up and running!