This repo contains an Ansible playbook for deploying Postresql cluster DB with etcd and haproxy as load balancer. The app is distributed in a Docker container and can be deployed via Helm chart. Simple API in the app returns weather information from the database.
- Clone repo and
cd
into it. - Place the
kubeconfig
file in the master withstudent*
name pattern. - Add SSH public keys to hosts.
- Setup Ansible inventory:
- Fill internal IPs for etcd_cluster \ balancers (which will haproxy) \ master \ replica in inventory file
- Change
ansible_ssh_private_key_file=
to your private SSH key path for hosts.
- Setup credentials for the DB connection in
./vars/main.yml
-admin
as an example. - Run playbook -
ansible-playbook deploy_pgcluster.yml
- After successful Ansible Playbook execution, you will see a public IP for Haproxy.
- Setup Helm values in
./app/values.yalm
:- Change
PGID
,PGPASS
from step 5 to yours andPGIP
to Haproxy IP from step 7. - Change
DOTNET_ENVIRONMENT
toDevelopment
if you want see Swagger page on the$IP/swagger/index.html
- Change
- Deploy Helm chart in K8S:
helm --kubeconfig ./student*.yaml install app /app
- Run
./app/test-api.sh
to see an example API response from DB.