I'll assume you have a running kubernetes cluster with:
First, create the namespace, operatorgroup and subscription for the awx-operator:
[ 19:37:49 ] - archy ~/kubernetes/awx> cat << EOF >> 0-awx-operator.yml
---
apiVersion: v1
kind: Namespace
metadata:
name: awx
...
---
apiVersion: operators.coreos.com/v1
kind: OperatorGroup
metadata:
name: operatorgroup
namespace: awx
spec:
targetNamespaces:
- awx
...
---
apiVersion: operators.coreos.com/v1alpha1
kind: Subscription
metadata:
name: awx
namespace: awx
spec:
channel: alpha
name: awx-operator
source: operatorhubio-catalog
sourceNamespace: olm
...
EOF
Apply the manifest using kubectl:
[ 19:38:52 ] - archy ~/kubernetes/awx> kubectl apply -f 0-awx-operator.yml
Wait until the operator is installed. You can check the status using this command:
[ 19:39:02 ] - archy ~/kubernetes/awx> kubectl -n awx -o wide get csv
OPTIONAL: create a pre-defined awx admin password. If this is not defined, a randomly generated one will be used.
[ 19:40:17 ] - archy ~/kubernetes/awx> cat << EOF >> 1-awx-admin-password.yml
---
apiVersion: v1
kind: Secret
metadata:
name: awx-homelab-admin-password
namespace: awx
stringData:
password: mysupersecretawxhomelabpassword
...
EOF
Apply the manifest to kubernetes using kubectl:
[ 19:41:06 ] - archy ~/kubernetes/awx> kubectl -n awx apply -f 1-awx-admin-password.yml
All that's left is to create the deployment of the actual awx instance. I will use a loadbalancer service type since I've got metallb installed on my cluster:
[ 19:42:28 ] - archy ~/kubernetes/awx> cat << EOF >> 2-awx-deployment.yml
---
apiVersion: awx.ansible.com/v1beta1
kind: AWX
metadata:
name: awx-homelab
spec:
admin_user: root
admin_email: admins@archyslife.lan
admin_password_secret: awx-homelab-admin-password
image: quay.io/ansible/awx
image_version: 21.10.2
service_type: LoadBalancer
loadbalancer_port: 80
loadbalancer_protocol: http
ingress_type: none
...
EOF
Apply the manifest to kubernetes using kubectl:
[ 19:42:45 ] - archy ~/kubernetes/awx> kubectl -n awx apply -f 2-awx-deployment.yml
Now the awx deployment and your new awx instance will be deployed using the operator.
You can check in on the status of the deployment by inspecting the logs of each container in the pod:
[ 19:45:20 ] - archy ~/kubernetes/awx> kubectl -n awx logs pods/awx-homelab-pods/awx-test-5ffc485f98-g4927 -c awx-homelab-task -f
[ 19:45:25 ] - archy ~/kubernetes/awx> kubectl -n awx logs pods/awx-homelab-pods/awx-test-5ffc485f98-g4927 -c awx-homelab-web -f
After the deployment routine has finished its setup, you should be able to reach the awx-instance using the port / ip / hostname you've provided in the awx-deployment.
Comments
Post a Comment