Skip to content

AWX (Ansible): 3. AWX update steps after 17.0.0 - minicube

instaling minikube k8s.

curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
sudo install minikube-linux-amd64 /usr/local/bin/minikube
sudo usermod -aG docker $USER && newgrp docker

minikube start --cpus=4 --memory=8g --addons=ingress --disk-size=50g

alias kubectl="minikube kubectl --"
minikube kubectl -- get po -A
//minikube dashboard //this is available if you do it in the host. otherwise, dont work.

The new way of installing AWX is using awx-operator, which is somehow a set of the playbook with instructions to create and build AWX.

also, good think is to create a permanent shortcut: nano ~/.bashrc alias kubectl="minikube kubectl --" source ~/.bashrc


So we don't have to keep repeating -n awx, let's set the current namespace for kubectl: kubectl config set-context --current --namespace=awx


nano kustomization.yaml

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
  # Find the latest tag here: https://github.com/ansible/awx-operator/releases
  - github.com/ansible/awx-operator/config/default?ref=2.5.3
  - awx.yaml
# Set the image tags to match the git version from above
images:
  - name: quay.io/ansible/awx-operator
    newTag: 2.5.3

# Specify a custom namespace in which to install AWX
namespace: awx

kubectl apply -k .

nano awx.yaml this step with the secret is very important. the secret_key is used for un-encrypt Credentials. If this secret differs from the old db the project host credentials will not work.

---
   apiVersion: awx.ansible.com/v1beta1
   kind: AWX
   metadata:
    name: awx
   spec:
    service_type: nodeport
    nodeport_port: 30080
    secret_key_secret: custom-awx-secret-key
---

   apiVersion: v1
   kind: Secret
   metadata:
    name: custom-awx-secret-key
    namespace: awx
   stringData:
    secret_key: awxsecret

to run the configurations: kubectl apply -k . kubectl get pods kubectl logs -f deployments/awx-operator-controller-manager -c awx-manager for exposing the port: kubectl port-forward svc/awx-service --address 0.0.0.0 30886:80

this is no need, any more.
commands need because after restarting the host, on startup kubernetis didn't has auto start.
alias kubectl="minikube kubectl --"

kubectl config set-context --current --namespace=awx
minikube start
kubectl get pods -n awx
kubectl port-forward svc/awx-service --address 0.0.0.0 30886:80

Backup and restore. backup: on the awx docker env. On the active docker awx-postgres docker ps docker exec -it %postgresql-container-name% /bin/bash cd /var/lib/posgtgresql/data/ pg_dump -U awx > backup.sql exit from container. go to the postgres external data. for the awx-17v it is in cd ~/.awx/pgdocker/12/data maybe you will need sudo/root access. there we will find the exported db. copy to desktop and make chmod 777 backup.sql


scp backup-17-10-2023.sql username@ip:./


prepare the database from minicube

after you have running awx stop the kubernetes pods kubectl get pods stop pods. (if you see some error try to enter the command by typing.) kubectl scale deployment awx-operator-controller-manager --replicas=0  kubectl scale deployment awx-web --replicas=0 kubectl scale deployment awx-task --replicas=0 kubectl get pods if the commands work well here you will only see the postgres pod -- $kubectl2 scale deployment awx-operator-controller-manager --replicas=0 -n awx $kubectl2 scale deployment awx-web --replicas=0 -n awx $kubectl2 scale deployment awx-task --replicas=0 -n awx

-- after that delete the data in: /var/lib/docker/volumes/minikube/_data/hostpath-provisioner/awx/postgres-13-awx-postgres-13-0/data

kubectl get pods kubectl exec -it awx-postgres-13-0 bash -n=awx psql -U awx -d postgres \l to see all databases DROP DATABASE awx; \l now you will see that awx database is deleted. CREATE DATABASE awx; \l after creating you will see aggen. if database is re-created exit the container,


to restore the backup use: kubectl -n awx exec -i awx-postgres-13-0 -- psql -U awx < backup2023ace.sql you will see some data restore actions. also you can check if the database tables, rules are created. kubectl exec -it awx-postgres-13-0 bash -n=awx psql -U awx \d exit the pod


after restore backup, turn on the pods.

kubectl scale deployment awx-operator-controller-manager --replicas=1 kubectl scale deployment awx-web --replicas=1 kubectl scale deployment awx-task --replicas=1

-- $kubectl2 scale deployment awx-operator-controller-manager --replicas=1 -n awx $kubectl2 scale deployment awx-web --replicas=1 -n awx $kubectl2 scale deployment awx-task --replicas=1 -n awx

--

and in the folder you create: kustomization.yaml, awx.yaml kubectl apply -k . to check if the pods are created and is no any error try kubectl get pod if you see some delay or the pods are stuck in creating or init try: kubectl describe name-pod -n awx

if everything is ok expose the port. kubectl port-forward svc/awx-service --address 0.0.0.0 30886:80

to check the logs. kubectl logs -f deployments/awx-operator-controller-manager -c awx-manager kubectl logs -f awx-%podname% -c awx-web -n=awx

after this step data is same as old db.


because Kubernetes didn't has auto start on reboot we will need to create some service for starting the cluster.



Subpages