#!/bin/bash
set -e
echo "--- 1. Installing K3s (Lightweight Kubernetes) ---"
# Install K3s and make the config readable for the current user
curl -sfL https://get.k3s.io | sh -s - --write-kubeconfig-mode 644
# Setup Kubeconfig for the current user
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. Creating AWX Namespace ---"
kubectl create namespace awx --dry-run=client -o yaml | kubectl apply -f -
echo "--- 3. Deploying AWX Operator via Kustomize ---"
# Create a temporary directory for 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 apply -k .
echo "Waiting for Operator to be Ready (this can take 2 mins)..."
kubectl rollout status deployment/awx-operator-controller-manager -n awx --timeout=300s
echo "--- 4. Creating AWX Instance (Tuned for t2.large) ---"
cat <<EOF > awx-instance.yaml
apiVersion: awx.ansible.com/v1beta1
kind: AWX
metadata:
name: awx-demo
namespace: awx
spec:
service_type: nodeport
# Resource tuning to ensure the 4/4 status on 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"
# Extra time for the task engine to wake up
task_readiness_timeout: 120
EOF
kubectl apply -f awx-instance.yaml -n awx
echo "------------------------------------------------------------"
echo "INSTALLATION COMPLETE!"
echo "1. Watch the pods: kubectl get pods -n awx -w"
echo "2. Once 'task' pod is 4/4, run this for your password:"
echo " kubectl get secret awx-demo-admin-password -n awx -o jsonpath='{.data.password}' | base64 --decode; echo"
echo "3. Find your Port:"
echo " kubectl get svc -n awx awx-demo-service"
echo "------------------------------------------------------------"
enter the below for the password
kubectl get secret awx-demo-admin-password -n awx -o jsonpath="{.data.password}" | base64 --decode; echo