This video will cover using Crunchy Data as an HA Database for the Ansible Automation Platform
The presenter is Alex Dworjan
Github: https://github.com/shadowman-lab
Crunchy Data for Kubernetes: https://access.crunchydata.com/docume...
Crunchy Data for Ansible: https://www.crunchydata.com/solutions...
NOTE: Replace aap-controller with the name of your controller deployment, aapcluster with the name of your crunchy deployment,
Step 1: Install Crunchy Operator and create cluster (this creates 2 replicas with backup and streaming replication, change namespace if not using aap namespace)
apiVersion: postgres-operator.crunchydata.com/v1beta1
kind: PostgresCluster
metadata:
name: aapcluster
namespace: aap
spec:
shutdown: false
postgresVersion: 14
users:
name: automationcontroller
databases:
automationcontroller
instances:
replicas: 2
dataVolumeClaimSpec:
accessModes:
"ReadWriteOnce"
resources:
requests:
storage: 10Gi
backups:
pgbackrest:
repos:
name: repo1
schedules:
full: "0 1 * * 0"
incremental: "0 1 * * 1-6"
volume:
volumeClaimSpec:
accessModes:
"ReadWriteOnce"
resources:
requests:
storage: 1Gi
patroni:
dynamicConfiguration:
postgresql:
pg_hba:
"host all all all md5"
parameters:
max_parallel_workers: 2
max_worker_processes: 2
shared_buffers: 256MB
work_mem: 64MB
archive_timeout: 300
Step 2: Shut down AAP for migration (change the project if you aren't deploying into an AAP namespace)
oc project aap
oc patch AutomationController/aap-controller --type='merge' -p '{"spec":{"replicas":0}}'
oc scale deployment aap-controller-task --replicas=0
oc scale deployment aap-controller-web --replicas=0
Step3: Patch Crunchy Postgres for use with current postgres password
oc patch secret aapcluster-pguser-automationcontroller -p `echo '{"stringData":{"password":"'$(oc get secret aap-controller-postgres-configuration --template={{.data.password}} | base64 --decode)'","verifier":""}}'`
Step 4: Patch AAP Configuration to point to Crunchy HA Service
oc patch secret aap-controller-postgres-configuration -p `echo '{"stringData":{"host":"'$(oc get secret aapcluster-pguser-automationcontroller --template={{.data.host}} | base64 -d)'","type":"unmanaged"}}'`
Step 5: Migrate Data
oc exec -c database -it $(oc get pod -l postgres-operator.crunchydata.com/role=master -o name) -- bash -c "PGPASSWORD=$(oc get secret aap-controller-postgres-configuration -n aap --template={{.data.password}} | base64 --decode) pg_dump -U automationcontroller -h aap-controller-postgres-13 -p 5432 -d automationcontroller | psql -1 --set ON_ERROR_STOP=on -d automationcontroller"
Step 6: Remove AAP Operator database and Persistent Volume Claim
oc delete statefulset aap-controller-postgres-13
kubectl delete pvc postgres-13-aap-controller-postgres-13-0
Step 7: Start up AAP after migration
oc patch AutomationController/aap-controller --type='merge' -p '{"spec":{"replicas":1}}'
oc scale deployment aap-controller-task --replicas=1
oc scale deployment aap-controller-web --replicas=1