Skip to content

Move config files into the container#102

Closed
ekohl wants to merge 2 commits intotheforeman:masterfrom
ekohl:move-config-file-into-container
Closed

Move config files into the container#102
ekohl wants to merge 2 commits intotheforeman:masterfrom
ekohl:move-config-file-into-container

Conversation

@ekohl
Copy link
Copy Markdown
Member

@ekohl ekohl commented Mar 6, 2025

This is an experiment to move configuration files into the container and only replace environment variables.

It creates a file to start the container where it creates all the needed files based on templates and environment variables. If the file already exists, it won't be overwritten. This allows bypassing the template.

This is a potential first step towards #68.

@ekohl ekohl force-pushed the move-config-file-into-container branch from 6363ecc to db3197a Compare March 6, 2025 17:51
RUN dnf -y update && \
dnf clean all
RUN dnf -y --nodocs install \
gettext \
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.

This provides envsubst. On Fedora 41 it's split off into gettext-envsubst so I think it'll be the same on EL10.

<acceptors>
<acceptor name="in-vm">vm://0</acceptor>
<acceptor name="stomp">tcp://localhost:61613?protocols=STOMP;useEpoll=false;sslEnabled=true;trustStorePath=/etc/candlepin/certs/truststore;trustStorePassword={{ candlepin_keystore_password }};keyStorePath=/etc/candlepin/certs/keystore;keyStorePassword={{ candlepin_keystore_password }};needClientAuth=true</acceptor>
<acceptor name="stomp">tcp://localhost:61613?protocols=STOMP;useEpoll=false;sslEnabled=true;trustStorePath=/etc/candlepin/certs/truststore;trustStorePassword=${CANDLEPIN_KEYSTORE_PASSWORD};keyStorePath=/etc/candlepin/certs/keystore;keyStorePassword=${CANDLEPIN_KEYSTORE_PASSWORD};needClientAuth=true</acceptor>
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.

I think https://activemq.apache.org/components/artemis/documentation/latest/configuring-transports.html#configuring-netty-ssl is the relevant documentation and I don't see a keystorePasswordFile option (or similar).

It does mention you can provide the javax.net.ssl.keyStorePassword system property as well. I wonder if Candlepin can reuse that same value. Perhaps we can end up with providing one big properties file with all secrets. Even if we don't directly expose that but still template it, it could be interesting to separate it out.

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.

I'd like to expand this file to also document expected file paths or perhaps also introduce CANDLEPIN_TRUSTSTORE_PATH which can get a default value. Then it becomes introspectable.


for template in /etc/candlepin/*.tpl ; do
destination=$(basename "$template" .tpl)
if [[ ! -f "$destination" ]] ; then
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.

This was intended to allow overrides but now I realize it may be created during container creation

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.

At least broker.xml isn't

@ekohl ekohl force-pushed the move-config-file-into-container branch 2 times, most recently from d4e419c to 8c10029 Compare March 7, 2025 10:06
@ekohl ekohl requested review from ehelms and evgeni and removed request for ehelms March 7, 2025 10:08
@ekohl
Copy link
Copy Markdown
Member Author

ekohl commented Mar 7, 2025

This is failing because I'm making changes to the Containerfile and those aren't in the published images. Will continue to experiment locally.

ekohl added 2 commits March 7, 2025 15:26
This is an experiment to move configuration files into the container and
only replace environment variables.

It creates a file to start the container where it creates all the needed
files based on templates and environment variables. If the file already
exists, it won't be overwritten. This allows bypassing the template.
@ekohl ekohl force-pushed the move-config-file-into-container branch from 91603c2 to 95ccc9d Compare March 7, 2025 14:27
Comment on lines +10 to +14
ENV CANDLEPIN_KEYSTORE_PATH=/etc/candlepin/certs/truststore
ENV CANDLEPIN_KEYSTORE_PASSWORD=
ENV CANDLEPIN_TRUSTSTORE_PATH=/etc/candlepin/certs/truststore
# Optional - if unset, CANDLEPIN_KEYSTORE_PASSWORD is used
ENV CANDLEPIN_TRUSTSTORE_PASSWORD=
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.

I noticed every line is another layer so perhaps it's better to use the multi-line mode of ENV.

# Optional - if unset, CANDLEPIN_KEYSTORE_PASSWORD is used
ENV CANDLEPIN_TRUSTSTORE_PASSWORD=

ADD broker.xml.tpl /etc/candlepin/
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.

I thought about creating a candlepin directory locally and use ADD candlepin/* /etc/candlepin/ so make it easier to scale but haven't experimented with that yet.

@ekohl ekohl marked this pull request as ready for review March 7, 2025 15:34
@ekohl ekohl added the candlepin label Mar 7, 2025
@ehelms
Copy link
Copy Markdown
Member

ehelms commented Mar 7, 2025

Worth noting that when I played around with this, there was one scenario that wasn't working for me using Candlepin's built in environment variable evaluation (#71 (comment)). I think this method of substitution would work around that.

@ehelms
Copy link
Copy Markdown
Member

ehelms commented Mar 7, 2025

I think this idea would mean we cannot use the official Candlepin images directly. We could possibly use them as base containers, but we'd have to layer in our baseline configuration files on top of it.

@ekohl
Copy link
Copy Markdown
Member Author

ekohl commented Mar 7, 2025

I think this idea would mean we cannot use the official Candlepin images directly. We could possibly use them as base containers, but we'd have to layer in our baseline configuration files on top of it.

That's correct, so we'd be on the hook to rebuild.

@ehelms
Copy link
Copy Markdown
Member

ehelms commented Mar 12, 2025

Worth noting that when I played around with this, there was one scenario that wasn't working for me using Candlepin's built in environment variable evaluation (#71 (comment)). I think this method of substitution would work around that.

Could you next try this out with some of the values in candlepin.conf? Specifically:

org.quartz.dataSource.myDS.password={{ candlepin_db_password }}

@ekohl
Copy link
Copy Markdown
Member Author

ekohl commented Apr 28, 2025

Moved over to theforeman/candlepin-oci-images#3.

@ekohl ekohl closed this Apr 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants