dcaputo-harmoni / open-balena-admin

Open Balena Admin
MIT License
90 stars 18 forks source link

Is it necessary to add configurations in haproxy.conf? #27

Open matiasAS opened 7 months ago

matiasAS commented 7 months ago

I do not understand this:

: IP address / hostname of open-balena-haproxy api.: IP address / hostname of open-balena-haproxy registry.: IP address / hostname of open-balena-haproxy vpn.: IP address / hostname of open-balena-haproxy s3.: IP address / hostname of open-balena-haproxy tunnel.: IP address / hostname of open-balena-haproxy admin.: IP address / hostname of open-balena-ui, or open-balena-admin-haproxy if using K8S ingress dashboard.: IP address / hostname of open-balena-ui, or open-balena-admin-haproxy if using K8S ingress postgrest.: IP address / hostname of open-balena-postgrest, or open-balena-admin-haproxy if using K8S ingress remote.: IP address / hostname of open-balena-remote, or open-balena-admin-haproxy if using K8S ingress Do I have to add configurations to open-balena's haproxy.conf? If so, can you give me the complete haproxy.conf file? If I enter admin. it results in error 503 Regards Matias
dcaputo-harmoni commented 7 months ago

No, you just need to set your dns settings on your hosting provider to point to those ip address / hostnames, which need to be publicly exposed.

matiasAS commented 7 months ago

@dcaputo-harmoni as this:

image

results: image image

matiasAS commented 7 months ago

@dcaputo-harmoni logs of openbalena-admin-postgrest-1 servuce;

28/Nov/2023:19:10:43 +0000: Attempting to reconnect to the database in 32 seconds... 28/Nov/2023:19:11:15 +0000: {"details":"invalid integer value \"xxxxxx@db.abcde.online:5432\" for connection option \"port\"\n","code":"","message":"Database connection error. Retrying the connection."}

Regards

dcaputo-harmoni commented 7 months ago

Just to confirm - there should be two haproxy instances in your environment, one for open-balena and one for open-balena-admin. The admin related domain names (admin, dashboard, postgrest, remote) should all be pointing to the open-balena-admin haproxy instance's public IP address / fqdn.

matiasAS commented 7 months ago

@dcaputo-harmoni I only have 1 instance of haproxy according to this:

image

matiasAS commented 7 months ago

@dcaputo-harmoni The service.yml file had the network defined twice and I had to modify it because I got an error:

version: "2.0"

services: ui:

docker exec -it y ejecutar npx update-browserslist-db@latest

extends:
  file: ./common.yml
  service: component
image: harmonidcaputo/open-balena-ui:${OPENBALENA_UI_VERSION_TAG}
depends_on:
  - postgrest
  - remote
environment:
  PORT: 8080
  OPEN_BALENA_JWT_SECRET: ${OPENBALENA_JWT_SECRET}
  OPEN_BALENA_S3_URL: https://s3.${OPENBALENA_HOST_NAME}
  OPEN_BALENA_S3_ACCESS_KEY: ${OPENBALENA_S3_ACCESS_KEY}
  OPEN_BALENA_S3_SECRET_KEY: ${OPENBALENA_S3_SECRET_KEY}
  REACT_APP_OPEN_BALENA_UI_URL: http://admin.${OPENBALENA_HOST_NAME}:8080
  REACT_APP_OPEN_BALENA_POSTGREST_URL: http://postgrest.${OPENBALENA_HOST_NAME}:8000
  REACT_APP_OPEN_BALENA_REMOTE_URL: http://remote.${OPENBALENA_HOST_NAME}:10000
  REACT_APP_OPEN_BALENA_API_URL: https://api.${OPENBALENA_HOST_NAME}
  REACT_APP_OPEN_BALENA_API_VERSION: ${OPENBALENA_API_VERSION_TAG}
ports:
  - "8080:8080"
networks:
  openbalena_default:
    aliases:
      - admin.${OPENBALENA_HOST_NAME}

remote: extends: file: ./common.yml service: component image: harmonidcaputo/open-balena-remote:${OPENBALENA_REMOTE_VERSION_TAG} environment: BALENARC_BALENA_URL: ${OPENBALENA_HOST_NAME} HOST_MODE: ${OPENBALENA_ADMIN_HOST_MODE} ports:

networks: openbalena_default: external: true

Also in the compose file change "docker-compose" to "docker compose" (remove the -)

It is the only thing that changes after doing the git clone of the repository

Openbalena and openbalena admin are on the same server

dcaputo-harmoni commented 7 months ago

If you aren't using a second haproxy instance, you will need to either reconfigure your existing haproxy instance to route to those containers based on the hostnames (i.e. remote.xyc.com goes to the open-balena-remote container) or make sure the open-balena-admin services each have their own public IP, and point the hostnames at those IP addresses.

matiasAS commented 7 months ago

@dcaputo-harmoni

That's what I said at the beginning, and why don't I have another instance of haproxy?

Can you give me the new updated haproxy.cfg file please?...or add it to the repository

matiasAS commented 7 months ago

@dcaputo-harmoni

or the other thing is that you add the haproxy service to docker compose.....so that everything works well, and there are no errors with other users of the openbalena community

dcaputo-harmoni commented 7 months ago

Everyone's networking setup is different (i.e. some people have multiple public IPs whcih would allow for multiple haproxy instances, others have one which would need it integrated with the open-balena instance, etc.), so it's hard to create a one-size-fits-all approach to this. I'd be interested in any solution you have; feel free to send in a PR to the repo and I will review. Just note that it should be generic enough to cover a wide range of setups. Because open-balena-admin is meant to run alongside open-balena, but doesn't actually modify anything within open-balena, including the open-balena-haproxy instance. So if you want to integrate it into the open-balena-haproxy instance, you would need to manually modify that config. A cleaner way to deploy all of this is to k8s using the helm scripts, which are linked in the main README page of the repo. This has all of the required configurations baked in, but obviously is a higher level of complexity than a traditional docker compose.

matiasAS commented 7 months ago

@dcaputo-harmoni

For me the unclear step to run openbalena-admin according to the readme is the definition of the domains:

: IP address / hostname of open-balena-haproxy api.: IP address / hostname of open-balena-haproxy registry.: IP address / hostname of open-balena-haproxy vpn.: IP address / hostname of open-balena-haproxy s3.: IP address / hostname of open-balena-haproxy tunnel.: IP address / hostname of open-balena-haproxy admin.: IP address / hostname of open-balena-ui, or open-balena-admin-haproxy if using K8S ingress dashboard.: IP address / hostname of open-balena-ui, or open-balena-admin-haproxy if using K8S ingress postgrest.: IP address / hostname of open-balena-postgrest, or open-balena-admin-haproxy if using K8S ingress remote.: IP address / hostname of open-balena-remote, or open-balena-admin-haproxy if using K8S ingress what I understand about that is to add the dns of each subdomain in my case in cloudflare and then run open-balena-admin/scripts/quickstart -j [OPENBALENA_JWT_SECRET] -v [OPENBALENA_API_VERSION_TAG] and open-balena/scripts/compose up -d If you have to modify haproxy.cfg of open-balena, a generic way that I would do would be to have the complete harpoxy.cfg in the repository (open-balena + open-balena-admin) to replace the haproxy.cfg and everything works. With the changes indicated above that I made it still doesn't work, and I ask you because I honestly don't know what I need to add for everything to work well. Do you speak Spanish?
dcaputo-harmoni commented 7 months ago

I'm sorry but I'm not able to support the docker-compose environment, we are using it in k8s and it works fine with the helm scripts. I know that others who have posted here have got it working with docker-compose so perhaps they can help you.

matiasAS commented 7 months ago

@dcaputo-harmoni

Can you give me the detailed step by step to execute everything using helm?

matiasAS commented 7 months ago

@dcaputo-harmoni

From what I see, is it changing everything or not? In that case, I prefer not to touch what already works.

Who has implemented it with docker compose?