Move co-located containers onto shared foreman-core-network - #728
Move co-located containers onto shared foreman-core-network#728Alleny244 wants to merge 1 commit into
Conversation
c6c2b37 to
de1fe85
Compare
6bf8eb0 to
a7edb41
Compare
|
Here's two other ideas:
The
|
I’ll go with PostgreSQL on both networks here. Putting all containers on the same network would require broader changes, so a separate PR would be right? |
3b4d9d7 to
6f86341
Compare
Yes and no, you are ultimately trying to solve this broader problem of running only what's needed on the public interface. I'd rather us solve the architecture question than patch it and change it again right after. I was reading on how |
Yeah, makes sense. I’ll look into the single network approach and see how we can handle the startup ordering. |
Should I reuse the existing iop-core-network or create a new general purpose network ( if naming conventions are being looked into) for the containers |
New general purpose network name that is more descriptive. |
| # Optional parameters - can use defaults. | ||
| # Use 127.0.0.1: Postgres is published on IPv4 only (not ::1), and TCP | ||
| # requires a password now that it is no longer on host networking. | ||
| iop_fdw_database_host: "127.0.0.1" |
There was a problem hiding this comment.
The iop.md architecture diagram (mermaid) still draws Postgres under "Host System", outside the iop-core-network subgraph, while the prose now says Postgres is reached via postgresql:5432 on that network.
Should we update that as well?
There was a problem hiding this comment.
Yeah, it's updated now
There was a problem hiding this comment.
Why do some places use 127.0.0.1 and others use postgresql ?
There was a problem hiding this comment.
@Alleny244 this should be addressed, as you use both in IOP.md:
flowchart LR
Ansible["Ansible / tests on host"] -->|"127.0.0.1:5432<br/>published"| PG
Apps["Foreman, Pulp, IOP apps"] -->|"postgresql:5432<br/>bridge DNS"| PG
FDW["postgres_fdw inside PG"] -->|"127.0.0.1:5432<br/>container loopback"| PG
PG[(postgresql container)]
There was a problem hiding this comment.
Thanks, addressed this in the docs. The difference is the network context: host-side Ansible/tests use the published 127.0.0.1:5432, while the app containers use postgresql:5432 through the bridge. The FDW runs inside the PostgreSQL container, so its 127.0.0.1 refers to the PostgreSQL container itself. I’ve added a note and linked the “PostgreSQL from three vantage points” section.
6f86341 to
d65b220
Compare
5c5760a to
456b6e3
Compare
|
Can you introduce a new document that lays out the architecture of the network? Take a look at #771 as I'd like it to go into that folder structure. |
Sure I ll take a look into that and formulate one |
0e55232 to
4c367a1
Compare
|
One thing that I noticed was , TLS issue affects both Candlepin and IOP: their certs are issued for candlepin / iop-core-gateway, but deploy-dev Foreman connects via localhost. Currently we are using those hostnames instead of localhost so hostname verification succeeds for production. For the host Foreman, I guess we’d also need to add both names to /etc/hosts pointing to 127.0.0.1 for TLS |
fab18cb to
8766272
Compare
For devel setup, could the certificates be issued for localhost as they are today? |
8766272 to
6961194
Compare
Yeah it is covered now. The Candlepin and IOP certs include both the container names (candlepin / iop-core-gateway) and localhost as SANs. So production can connect using the container names, while devel setup can continue using localhost (no /etc/hosts changes are needed) |
6961194 to
142b2ad
Compare
stejskalleos
left a comment
There was a problem hiding this comment.
Some things has to be addressed before we can merge.
Also, the failing CI:
TASK [pre_install : Install other dependencies] ********************************
[ERROR]: Task failed: Module failed: Depsolve Error occurred:
Problem: package python3.12-pyOpenSSL-26.2.0-2.el10.noarch from pulpcore requires (python3.12dist(cryptography) < 49~~ with python3.12dist(cryptography) >= 46), but none of the providers can be installed
- package python3.12-requests-2.33.1-3.el10.noarch from pulpcore requires python3.12-pyOpenSSL >= 0.14, but none of the providers can be installed
- cannot install both python3-cryptography-49.0.0-1.el10.x86_64 from baseos and python3-cryptography-48.0.0-3.el10.x86_64 from baseos
- package python3-cryptography-49.0.0-1.el10.x86_64 from baseos obsoletes python3.12-cryptography < 49.0.0-1.el10 provided by python3.12-cryptography-46.0.7-3.el10.x86_64 from pulpcore
-
do we track it somewhere? Or is there a fix / person working on it?
| # Optional parameters - can use defaults. | ||
| # Use 127.0.0.1: Postgres is published on IPv4 only (not ::1), and TCP | ||
| # requires a password now that it is no longer on host networking. | ||
| iop_fdw_database_host: "127.0.0.1" |
There was a problem hiding this comment.
@Alleny244 this should be addressed, as you use both in IOP.md:
flowchart LR
Ansible["Ansible / tests on host"] -->|"127.0.0.1:5432<br/>published"| PG
Apps["Foreman, Pulp, IOP apps"] -->|"postgresql:5432<br/>bridge DNS"| PG
FDW["postgres_fdw inside PG"] -->|"127.0.0.1:5432<br/>container loopback"| PG
PG[(postgresql container)]
| "podman exec foreman curl --cacert /etc/foreman/katello-default-ca.crt" | ||
| "--silent --output /dev/null https://candlepin:23443/candlepin/status" |
There was a problem hiding this comment.
| "podman exec foreman curl --cacert /etc/foreman/katello-default-ca.crt" | |
| "--silent --output /dev/null https://candlepin:23443/candlepin/status" | |
| "podman exec foreman curl --cacert /etc/foreman/katello-default-ca.crt " | |
| "--silent --output /dev/null https://candlepin:23443/candlepin/status" |
missing space, this can't work IMO
There was a problem hiding this comment.
yeah, thanks, have added the space
| server.run( | ||
| f"curl --cacert {certificates['ca_certificate']} --silent --output /dev/null " | ||
| f"https://localhost:23443/candlepin/status" | ||
| f"podman exec foreman curl --cacert {certificates['ca_certificate']} " |
There was a problem hiding this comment.
From AI:
certificates['ca_certificate'] resolves to a host-side path (rendered from src/vars/certificates.yml, e.g.,/var/lib/foremanctl/certs/certs/ca.crt), but this is run with podman exec foreman, i.e., inside the foreman container's filesystem, where that path doesn't exist.
The sibling test test_candlepin_status correctly uses the in-container path /etc/foreman/katello-default-ca.crt — this one should too.
| foreman_database_host: "{{ database_host }}" | ||
| candlepin_database_host: "{{ database_host }}" | ||
| pulp_database_host: "{{ database_host }}" | ||
| when: database_mode == 'external' |
There was a problem hiding this comment.
Why is this needed here now? If the user provides the parameter this should cascade to modifying these in the src/vars/database.yml file.
There was a problem hiding this comment.
yeah agreed, have moved it back to the database.yml file
| - name: Set external database hosts | ||
| ansible.builtin.set_fact: | ||
| pulp_database_host: "{{ database_host }}" | ||
| when: database_mode == 'external' |
There was a problem hiding this comment.
We do not support external database with the deploy-proxy action.
| candlepin_ca_certificate: "{{ ca_certificate }}" | ||
| candlepin_tomcat_key: "{{ localhost_key }}" | ||
| candlepin_tomcat_certificate: "{{ localhost_certificate }}" | ||
| candlepin_tomcat_key: "{{ candlepin_key }}" |
There was a problem hiding this comment.
Trying to remember why we set any of these certificate things here and not in src/vars/certificates.yaml.
| localhost_client_key: "{{ certificates_ca_directory }}/private/localhost-client.key" | ||
| localhost_client_certificate: "{{ certificates_ca_directory }}/certs/localhost-client.crt" | ||
| candlepin_key: "{{ certificates_ca_directory }}/private/candlepin.key" | ||
| candlepin_certificate: "{{ certificates_ca_directory }}/certs/candlepin.crt" |
There was a problem hiding this comment.
I think these are a bit confusing to name this way and not use tomcat in the name. Since these are for tomcat whereas Candlepin itself does get key/cert that are CAs for it's other use cases. I would align on tomcat naming. And see https://github.com/theforeman/foremanctl/pull/728/changes#r3872587738 I think we need some alignment of certs vars into the same file.
There was a problem hiding this comment.
yeahh, makes sense have made the change
| postgresql_admin_password_file: "{{ obsah_state_path }}/postgresql-admin-password" | ||
| postgresql_admin_password: "{{ lookup('ansible.builtin.password', postgresql_admin_password_file, chars=['ascii_letters', 'digits']) }}" | ||
|
|
||
| candlepin_database_host: "{{ database_host }}" |
There was a problem hiding this comment.
Those variables used to point to localhost but with new shared network I thought of keep them under their respective roles default variables, but based on this feedback(#728 (comment)) I think it is better to have it in the initial place itself
| @@ -1,5 +1,5 @@ | |||
| --- | |||
| database_host: localhost | |||
| database_host: 127.0.0.1 | |||
There was a problem hiding this comment.
I would have thought this would be postgresql now?
There was a problem hiding this comment.
Shouldn't this stay as 127.0.0.1? database_host is used for host side tasks(login_host, pg_isready), while the containers use their own *_database_host defaults with postgresql on foreman-core-network.
There was a problem hiding this comment.
That is a fair question as database_host now has two meanings with this change. I believe it should mean "this is the host that services find that database at". In an external database scenario, this should represent the host of the external database. I would turn it around then, and consider if a new variable is needed to represent the host where database tooling connects to.
There was a problem hiding this comment.
Maybe like database_management_host ?
There was a problem hiding this comment.
Yup, this makes sense. database_host should represent the host that the services connect to, and we can use database_management_host for host side database tooling. I ll update the pr
142b2ad to
ecd85ee
Compare
stejskalleos
left a comment
There was a problem hiding this comment.
My comments have been addressed; running foremanctl deploy works fine, and CI is green.
🍏 LGTM from my side, waiting for @ehelms for final ack
ecd85ee to
5ede7ef
Compare
Problem Statement
Embedded PostgreSQL defaults to
listen_addresses = '*', exposing port5432on public interfaces when containers use host networking.https://redhat.atlassian.net/browse/SAT-48503
Changes
foreman-core-network(10.130.0.0/24) via theforeman_core_networkrole, created early in deploy.postgresql,valkey,candlepin,iop-core-gateway).127.0.0.1:5432,127.0.0.1:6379, Candlepin/IOP gateway ports) so ports are not exposed on0.0.0.0/ public interfaces.iop_network/iop-core-network; IOP usesforeman-core-network.foreman_proxyon host networking (edge/DHCP/DNS/TFTP/REX).0.0.0.0:5432/[::]:5432(and equivalent for Valkey).Tests
Checklist
docs/iop.md)