#!/bin/bash
set -e
echo "--- 1. Installing K3s ---"
curl -sfL https://get.k3s.io | sh -s - --write-kubeconfig-mode 644
# Setup Kubeconfig
mkdir -p $HOME/.kube
sudo cp /etc/rancher/k3s/k3s.yaml $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
echo "Waiting for K3s Node to be Ready..."
until kubectl get nodes | grep -q "Ready"; do sleep 5; done
echo "--- 2. Deploying AWX Operator via Kustomize ---"
mkdir -p ~/awx-deploy && cd ~/awx-deploy
cat <<EOF > kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- github.com/ansible/awx-operator/config/default?ref=2.19.1
images:
- name: quay.io/ansible/awx-operator
newTag: 2.19.1
namespace: awx
EOF
kubectl create namespace awx
kubectl apply -k .
echo "Waiting for Operator (approx 2 mins)..."
kubectl rollout status deployment/awx-operator-controller-manager -n awx --timeout=300s
echo "--- 3. Creating AWX Instance ---"
cat <<EOF > awx-instance.yaml
apiVersion: awx.ansible.com/v1beta1
kind: AWX
metadata:
name: awx-demo
namespace: awx
spec:
service_type: nodeport
# Resource tuning for t2.large
web_resource_requirements:
requests:
cpu: "250m"
memory: "1Gi"
limits:
cpu: "500m"
memory: "2Gi"
task_resource_requirements:
requests:
cpu: "500m"
memory: "1Gi"
limits:
cpu: "1000m"
memory: "2Gi"
postgres_resource_requirements:
requests:
cpu: "200m"
memory: "512Mi"
# Increased timeout for first-time database initialization
task_readiness_timeout: 120
EOF
kubectl apply -f awx-instance.yaml -n awx
echo "------------------------------------------------------------"
echo "CLEAN INSTALLATION COMPLETE"
echo "Watch pods until task is 4/4: kubectl get pods -n awx -w"
echo "------------------------------------------------------------"
enter the below for the password
kubectl get secret awx-demo-admin-password -n awx -o jsonpath="{.data.password}" | base64 --decode; echo