vitabaks / postgresql_cluster

PostgreSQL High-Availability Cluster (based on Patroni). Automating with Ansible.
https://postgresql-cluster.org
MIT License
1.83k stars 418 forks source link

GET http://localhost:8080/api/v1/environments net::ERR_CONNECTION_REFUSED #811

Open asntc opened 2 days ago

asntc commented 2 days ago

Hi @vitabaks, šŸ‘‹ thanks for this awesome project! just getting started and hoping to use this ... But currently getting the same error as described by @garry-t in: https://github.com/vitabaks/postgresql_cluster/issues/785#issuecomment-2465047315 Though the "fix" suggested in that thread has not worked for me ...

http://116.202.31.52/clusters (login with the $PG_CONSOLE_AUTHORIZATION_TOKEN worked, but nothing else)

image

Several errors in the Chrome DevTools Console similar to:

index-BcZ6gpvM.js:185 

       GET http://localhost:8080/api/v1/clusters?offset=0&limit=10&project_id=0&sort_by=-created_at net::ERR_CONNECTION_REFUSED

To initiate the console on Hetzner, ran the following:

docker run -d --name pg-console \
  --publish 80:80 \
  --publish 8080:8080 \
  --env PG_CONSOLE_API_URL=$PG_CONSOLE_API_URL \
  --env PG_CONSOLE_AUTHORIZATION_TOKEN=$PG_CONSOLE_AUTHORIZATION_TOKEN \
  --env PG_CONSOLE_DOCKER_IMAGE=vitabaks/postgresql_cluster:latest \
  --volume console_postgres:/var/lib/postgresql \
  --volume /var/run/docker.sock:/var/run/docker.sock \
  --volume /tmp/ansible:/tmp/ansible \
  --restart=unless-stopped \
  vitabaks/postgresql_cluster_console:2.0.0

Where the two environment variables used above are defined as:

export PG_CONSOLE_AUTHORIZATION_TOKEN=myawesomeauthtoken
export PG_CONSOLE_API_URL=http://116.202.31.52:8080/api/v1

Is there another place I should define the IP address for the API? šŸ¤·ā€ā™‚ļø What am I doing wrong? šŸ™ƒ Thanks! šŸ™

vitabaks commented 2 days ago

Hi @asntc Thank you for your feedback!

It looks like the address in the PG_CONSOLE_API_URL variable has not been redefined

try to launch the container like this:

docker run -d --name pg-console \
  --publish 80:80 \
  --publish 8080:8080 \
  --env PG_CONSOLE_API_URL=http://116.202.31.52:8080/api/v1 \
  --env PG_CONSOLE_AUTHORIZATION_TOKEN=myawesomeauthtoken \
  --env PG_CONSOLE_DOCKER_IMAGE=vitabaks/postgresql_cluster:latest \
  --volume console_postgres:/var/lib/postgresql \
  --volume /var/run/docker.sock:/var/run/docker.sock \
  --volume /tmp/ansible:/tmp/ansible \
  --restart=unless-stopped \
  vitabaks/postgresql_cluster_console:2.0.0

P.S. Since it is open-source, everyone can contribute. Feel free to create a PR if you know can help us get better.

asntc commented 2 days ago

Yeah, I had both vars hard-coded in the launch command before ... trying again ...

Deleted everything:

docker ps 

CONTAINER ID   IMAGE                                       COMMAND                  CREATED       STATUS       PORTS                                                                                    NAMES
96a0ca771b31   vitabaks/postgresql_cluster_console:2.0.0   "/usr/bin/supervisorā€¦"   2 hours ago   Up 2 hours   0.0.0.0:80->80/tcp, :::80->80/tcp, 0.0.0.0:8080->8080/tcp, :::8080->8080/tcp, 5432/tcp   pg-console

docker kill 96a0ca771b31
96a0ca771b31

docker rm -vf $(docker ps -aq)
96a0ca771b31

Deleted all images to make sure I'm starting from scratch with no history. ref: https://stackoverflow.com/questions/44785585/how-can-i-delete-all-local-docker-images

docker rmi -f $(docker images -aq)

Untagged: vitabaks/postgresql_cluster:latest
Untagged: vitabaks/postgresql_cluster@sha256:e6a0eb79191b49c1608951c000b9287507d74733c24b0a5957aef7a3611304c7
Deleted: sha256:0517c8800964508938f0948fe902c228d285923a5bc7bd676ed66c04263f4a4f
Deleted: sha256:cce819918581e1909bdcb8ce69e526e33aab63d8e651d030ef8937d6a9d48da8
Deleted: sha256:b0f8303850e136d97cedbf4c863b45a4e26c6baca308adfa716c5b0893a22365
Deleted: sha256:78e7b75933438e7089fafdc1217e3c0bc6419c472a262eaf8adffeade889adc7
Deleted: sha256:c3548211b8264f8bfa47a6727043a64f1791b82ac965a284a7ea187e971a95e2
Untagged: vitabaks/postgresql_cluster_console:2.0.0
Untagged: vitabaks/postgresql_cluster_console@sha256:328b235f70519e9e220b0970bb3bfbf7915dd1d80fd26e13105e7a505207825b
Deleted: sha256:bfda43f72e3c0c47bacdd2660fdc4575bf0d47d4053a122baa58b7249f877513
Deleted: sha256:6039fe2c2eaaf09a93e30194e530a42921eed45cef3b345faffeded05f37f3cc
Deleted: sha256:68410df5104b79a8442ae11a5c6df8eaa042f7137635dd97e811659f98526476
Deleted: sha256:61696999ec5521288a61671662d25e6cbacee2fd5bbebcfb617f6afe4fc75233
Deleted: sha256:d7206992cf134d72ca1a4f4d816986142ead2562fa88b87ed75e05defcab71d8
Deleted: sha256:1dc8d7c47d1958816a57d56acf24acaec33e5ddb568e4da9a5ea5696a23a797c
Deleted: sha256:dca823d03bf4903c136ac31783e0c1ec3ba9be40fbcbc656ce2e1f4d27e5a15f
Deleted: sha256:e1155830eed17e23dc1e3dfd541a69d9d455947dbc9c1cebb55c0a2705f00ba0
Deleted: sha256:fc2713214030d4b8814b28bfe3f1c1fdb6b06547794cb5917c2b257e5cefde56
Deleted: sha256:01a5eefca08e1630a612d472afd46f7422bf2a22b585c65e4b18b2a75823f90f
Deleted: sha256:376311081fb7a6105cb60547b0b43823a5e65205773af614e438ed365ce8775f
Deleted: sha256:f6ace3d35dc453f90cdc54c257b7f2d7cdbd6a7ec5b2b3a94808e22396567ed7
Deleted: sha256:e1c55fdd3a403ca00be66062fcea960fba0da729d2250ec72093192e56f99dc3
Deleted: sha256:dd03df0b7439455eeac0e25422c44e3e71432fed2df4a42520164cbfb522d9cd
Deleted: sha256:b04c2fbe93f80bd3a27acc7a3e498863590a5999b66fdcb42a0c3fda2b12bb87
Deleted: sha256:1e9a7e559f89fcf207554ee6fde0237503f2c32897ad258b6a29679fd0b2d42e
Deleted: sha256:8ece98d08913685cb3885c4f7a07b3e1dcb2a31aaccbd14844a14cafd83cda0f
Deleted: sha256:5875b996ef9ec366425b7e62c48b927cea1b43cef658610e159c67065c0701c4
Deleted: sha256:4e4f6869c995187845acc170d86de6aacee22b56120fdab68d6fc6511f63c60c
Deleted: sha256:54f8980ff145b49141846c66237a2e7870b9dcf8eb6fe6c6be13dc2d2d5158f2
Deleted: sha256:9853575bc4f955c5892dd64187538a6cd02dba6968eba9201854876a7a257034

My understanding is that this nuked everything on the VPS. šŸ¤ž

Then ran:

docker run -d --name pg-console \
  --publish 80:80 \
  --publish 8080:8080 \
  --env PG_CONSOLE_API_URL=http://116.202.31.52:8080/api/v1 \
  --env PG_CONSOLE_AUTHORIZATION_TOKEN=myawesomeauthtoken \
  --env PG_CONSOLE_DOCKER_IMAGE=vitabaks/postgresql_cluster:latest \
  --volume console_postgres:/var/lib/postgresql \
  --volume /var/run/docker.sock:/var/run/docker.sock \
  --volume /tmp/ansible:/tmp/ansible \
  --restart=unless-stopped \
  vitabaks/postgresql_cluster_console:2.0.0

Output:

vitabaks/postgresql_cluster_console:2.0.0
Unable to find image 'vitabaks/postgresql_cluster_console:2.0.0' locally
2.0.0: Pulling from vitabaks/postgresql_cluster_console
e4fff0779e6d: Pull complete 
57bfd8b087cd: Pull complete 
955fc5fe26b2: Pull complete 
8f50a2be0867: Pull complete 
29852a384601: Pull complete 
b4872c95011a: Pull complete 
4f5185938b7c: Pull complete 
c823d38a5c69: Pull complete 
274f428fb651: Pull complete 
865a6893f717: Pull complete 
32eca27339c3: Pull complete 
be9675fa3b92: Pull complete 
2e73748c94d7: Pull complete 
ab2c3e0a0b15: Pull complete 
9c47f04a9288: Pull complete 
b9c35426cdce: Pull complete 
5af543bbf7ca: Pull complete 
16faa38e41ac: Pull complete 
80773219b976: Pull complete 
bf014a24948a: Pull complete 
Digest: sha256:328b235f70519e9e220b0970bb3bfbf7915dd1d80fd26e13105e7a505207825b
Status: Downloaded newer image for vitabaks/postgresql_cluster_console:2.0.0
3bb2ed0a6d41d49031f20e9d2f44c000c5c9605423ffc540ce375ee692ea0377

Now run ps again and get:

docker ps

CONTAINER ID   IMAGE                                       COMMAND                  CREATED              STATUS              PORTS                                                                                    NAMES
3bb2ed0a6d41   vitabaks/postgresql_cluster_console:2.0.0   "/usr/bin/supervisorā€¦"   About a minute ago   Up About a minute   0.0.0.0:80->80/tcp, :::80->80/tcp, 0.0.0.0:8080->8080/tcp, :::8080->8080/tcp, 5432/tcp   pg-console

Then opened a different browser (Safari incognito to make sure I don't have any session saved):

image

Authenticated using the Auth Token:

image

Opened Dev Tools in Safari:

image

Don't appear to have the same errors anymore. šŸ¤ž Will report back if I have any issues. šŸ“ But for now it looks like it's working. šŸŽ‰

P.S. I'm recording a screencast of the setup. šŸ“ŗ That's why I was attempting to use Environment Variables to not show the Auth Token ... šŸ”‘ šŸ™ˆ But I will just blur them in the edit. šŸ˜‰

vitabaks commented 2 days ago

@asntc I couldnā€™t resist diving into the related issue and sharing my thoughts:

This gives us confidence that the project is maintained and we are making a good choice to use it.

This project is not just maintainedā€”itā€™s gaining significant momentum!

We have ambitious plans to transform it into a true alternative to cloud-managed databases. This tool, proven in production over the years, is evolving into what I call an ā€œautomated self-managed database.ā€ With high-quality automation, it will be as easy to maintain as Managed Postgres, while remaining open-source and completely free out of the box.

I an expert in Postgres with strong automation skills, Iā€™ve made great progress. However, Iā€™m not a Frontend/Backend developer, so Iā€™m actively looking for companies willing to support the projectā€”either by helping implement these ambitious plans (and there are many!) or by sponsoring so we can bring on developers.

I firmly believe open source can create incredible opportunities. It just takes the right people to make it happen!