Skip to content

Run ironic-api as WSGI when standalone with TLS capability#230

Merged
metal3-io-bot merged 1 commit intometal3-io:masterfrom
Nordix:ironic-api-behind-wsgi-nam
Mar 8, 2021
Merged

Run ironic-api as WSGI when standalone with TLS capability#230
metal3-io-bot merged 1 commit intometal3-io:masterfrom
Nordix:ironic-api-behind-wsgi-nam

Conversation

@namnx228
Copy link
Copy Markdown
Member

@namnx228 namnx228 commented Dec 1, 2020

This PR runs Ironic-api as a WSGI application on top of a fully-capable web server (Apache) and lets this Apache server takes care of TLS. In details, Ironic-api runs as a WSGI application on top of an Apache server. This web server handles the HTTPS connections between ironic-api and other components.
Related PRs:
metal3-io/baremetal-operator#728
metal3-io/ironic-inspector-image#70

@namnx228
Copy link
Copy Markdown
Member Author

namnx228 commented Dec 1, 2020

/assign @dtantsur
/cc @dhellmann
/cc @maelk
/cc @kashifest

@namnx228 namnx228 force-pushed the ironic-api-behind-wsgi-nam branch 2 times, most recently from d66a4ae to 03d3fc3 Compare December 1, 2020 11:41
@namnx228
Copy link
Copy Markdown
Member Author

namnx228 commented Dec 1, 2020

/test-integration

@namnx228
Copy link
Copy Markdown
Member Author

namnx228 commented Dec 1, 2020

/cc @zaneb
/cc @derekhiggins

@namnx228 namnx228 force-pushed the ironic-api-behind-wsgi-nam branch 3 times, most recently from 3cecfab to 758a1c7 Compare December 1, 2020 16:18
Comment thread README.md Outdated
Copy link
Copy Markdown
Member

@dtantsur dtantsur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missed an important bit (may explain why we need to keep the old approach around).

Comment thread runironic-api.sh Outdated
else
python3 -c 'import os; import sys; import jinja2; sys.stdout.write(jinja2.Template(sys.stdin.read()).render(env=os.environ))' < /etc/httpd-ironic-api.conf.j2 > /etc/httpd/conf.d/ironic.conf
sed -i "/Listen 80/c\#Listen 80" /etc/httpd/conf/httpd.conf
exec /usr/sbin/httpd -DFOREGROUND
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is already an httpd container here, let's not run several more instances of httpd

Copy link
Copy Markdown
Member Author

@namnx228 namnx228 Dec 2, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently, the PR adds 2 more httpd instance to the picture. If we avoid to add extra httpd instances and make use of the existing one, IMO there will be two problems:

  • Web server and WSGI application need to be on the same container. if we only have one httpd instance, we have to run Ironic-api on the existing httpd container.
  • In the PR, a dedicated instance of Apache server acts as a reverse proxy offloading TLS and forward http requests to the conductor. If the existing httpd container also becomes a reverse proxy, that means we are forcing the ironic-api and ironic-conductor to live on the same pod. This may reduce the flexibility of design we can choose for our system.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I think we can split conductor and httpd into different containers, and also make use of the existing httpd instance (used by IPA) to acts as a reverse proxy for the conductor. However, a httpd instance is needed to be in the ironic-api container since we run it as a WSGI application. Therefore, we need at least two httpd instance in the picture, and one instance needs to be in the same container as the ironic-api. WDYT @dtantsur ?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First, I'm not convinced that we should use httpd for the conductor. This is a setup nobody has ever used, and I'm not sure what the implications are. I'd leave it alone. I don't see a problem with having ironic-api in the httpd container, after all, this is how non-containerized deployments work. Having 2 httpd containers will raise memory requirements quite severely.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dtantsur The reason why httpd is used for the conductor is that it also takes care of offloading the encrypted traffic and forward the unencrypted traffic to the conductor. Since we put httpd and the conduct into one K8S pod, I think the unencrypted traffic doesn't hurt too much. The aim is to make Ironic get rid of handling TLS.

@namnx228 namnx228 force-pushed the ironic-api-behind-wsgi-nam branch 2 times, most recently from 4c61356 to e0f6659 Compare December 11, 2020 14:23
@namnx228 namnx228 changed the title Run ironic-api as WSGI when standalone with TLS capability WIP: Run ironic-api as WSGI when standalone with TLS capability Dec 11, 2020
@metal3-io-bot metal3-io-bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Dec 11, 2020
@namnx228 namnx228 force-pushed the ironic-api-behind-wsgi-nam branch from e0f6659 to 8360d7d Compare December 16, 2020 16:35
@metal3-io-bot metal3-io-bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Dec 17, 2020
@namnx228
Copy link
Copy Markdown
Member Author

@zaneb @stbenjam Could you please take a look at this PR?

Comment on lines +35 to +42
sed -i 's/^Listen .*$/Listen [::]:'"$HTTP_PORT"'/' /etc/httpd/conf/httpd.conf
sed -i -e 's|\(^[[:space:]]*\)\(DocumentRoot\)\(.*\)|\1\2 "/shared/html"|' \
-e 's|<Directory "/var/www/html">|<Directory "/shared/html">|' \
-e 's|<Directory "/var/www">|<Directory "/shared">|' /etc/httpd/conf/httpd.conf

# Log to std out/err
sed -i -e 's%^ \+CustomLog.*% CustomLog /dev/stderr combined%g' /etc/httpd/conf/httpd.conf
sed -i -e 's%^ErrorLog.*%ErrorLog /dev/stderr%g' /etc/httpd/conf/httpd.conf
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I like managing config files via sed, what if the config file changes just enough that the regex no longer matches?

Can we just ship a minimal /etc/httpd/conf/httpd.conf for this, possibly a jinja template?

Copy link
Copy Markdown
Member Author

@namnx228 namnx228 Feb 22, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I can do that, but should we do this in a separate PR? These sed commands already existed before, and I just move it from one place to another.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure that's fine, I didn't realize this was pre-existing.

Comment thread config/apache2-ironic-api.conf.j2 Outdated
Comment thread config/apache2-ironic-api.conf.j2 Outdated
Comment thread config/httpd-modules.conf
Comment thread scripts/configure-httpd-ipa.sh Outdated
@namnx228 namnx228 force-pushed the ironic-api-behind-wsgi-nam branch from e456ac3 to 0679edd Compare February 22, 2021 15:09
@namnx228
Copy link
Copy Markdown
Member Author

/test-integration
test-centos-integration

@namnx228
Copy link
Copy Markdown
Member Author

/test-centos-integration

1 similar comment
@namnx228
Copy link
Copy Markdown
Member Author

/test-centos-integration

@namnx228
Copy link
Copy Markdown
Member Author

@stbenjam Thank you for your comments. I have addressed all of them. Please take a look again.

Comment thread config/apache2-ironic-api.conf.j2 Outdated

Listen 6385

<VirtualHost {{ env.IRONIC_IP }}:6385>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should obey the LISTEN_ALL_INTERFACES env variable here. In the Ironic config, the logic is:

host_ip = {% if env.LISTEN_ALL_INTERFACES | lower == "true" %}::{% else %}{{ env.IRONIC_IP }}{% endif %}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh! I failed to get your point in the comment above. Now it is fixed. Thanks.

@stbenjam
Copy link
Copy Markdown
Member

Just one comment, please fix that but I think otherwise this good.

@namnx228 namnx228 force-pushed the ironic-api-behind-wsgi-nam branch from 0679edd to 2ca3197 Compare February 23, 2021 13:47
@namnx228
Copy link
Copy Markdown
Member Author

/test-integration
/test-centos-integration

@namnx228 namnx228 force-pushed the ironic-api-behind-wsgi-nam branch from 2ca3197 to 63e6163 Compare February 23, 2021 16:06
@namnx228
Copy link
Copy Markdown
Member Author

/test-integration
/test-centos-integration

@namnx228
Copy link
Copy Markdown
Member Author

/test-centos-integration

@namnx228
Copy link
Copy Markdown
Member Author

@stbenjam Thanks, the last comment has been fixed. PTAL

Comment thread config/apache2-ironic-api.conf.j2 Outdated
{% if env.LISTEN_ALL_INTERFACES | lower == "true" %}
<VirtualHost *:6385>
{% else %}
<VirtualHost {{ env.IRONIC_IP }}:6385>
Copy link
Copy Markdown
Member

@stbenjam stbenjam Mar 1, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! This is better. One small nit, if IRONIC_IP is IPv6, this won't get wrapped correctly, e.g it'd need to be [fd00::2]:6385. I think you can use the env.IRONIC_URL_HOST instead, which is provided by the ironic common.sh include.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean change env.IRONIC_IP to env.IRONIC_URL_HOST in line 18?

@namnx228 namnx228 force-pushed the ironic-api-behind-wsgi-nam branch from 63e6163 to d0db1d5 Compare March 2, 2021 09:43
@namnx228
Copy link
Copy Markdown
Member Author

namnx228 commented Mar 2, 2021

/test-integration
/test-centos-integration

@stbenjam
Copy link
Copy Markdown
Member

stbenjam commented Mar 2, 2021

/approve

@stbenjam
Copy link
Copy Markdown
Member

stbenjam commented Mar 2, 2021

/lgtm

@elfosardo Would you mind taking a look again?

@metal3-io-bot metal3-io-bot added the lgtm Indicates that a PR is ready to be merged. label Mar 2, 2021
@elfosardo
Copy link
Copy Markdown
Member

/assign @dtantsur

@metal3-io-bot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dtantsur, elfosardo, namnx228, stbenjam

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@metal3-io-bot metal3-io-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 8, 2021
@metal3-io-bot metal3-io-bot merged commit 216be3e into metal3-io:master Mar 8, 2021
@namnx228
Copy link
Copy Markdown
Member Author

namnx228 commented Mar 9, 2021

Thanks very much @dtantsur, @stbenjam, @elfosardo for your reviews and approval.

elfosardo pushed a commit to elfosardo/ironic-image that referenced this pull request Nov 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants