Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix custom CA certificates for task/web/migration #1846

Open
wants to merge 2 commits into
base: devel
Choose a base branch
from

Conversation

JoelKle
Copy link
Contributor

@JoelKle JoelKle commented Apr 30, 2024

SUMMARY

This PR fixes the usage of custom CA certificates in the migration job and improves the existing implementation in the task & web deployment.
During the upgrade to awx 24.0.0, a new pod is created for migration. This pod doesnt contain the custom ca certificate and fails when using external postgres with verify enabled.

PR fixes: #1782
Follow up / Improves: #1800

ISSUE TYPE
  • Bug, Docs Fix or other nominal change
ADDITIONAL INFORMATION

This PR is based on the great work of @YassineFadhlaoui in #1782 (comment) and @akkaba23 in #1800 (comment)

The following has changed:

  • Added a new init container init-bundle-ca-trust to the task + web deployment and to the migration job

    • the init container runs the update-ca-trust extract if bundle_ca_crt is set.
    • I've added a new init container for the following reasons:
      • this init container need to run before all other init containers
      • only this init container requires runAsUser: 0
  • Removed the update-ca-trust command from the init container init-receptor because it will run once in the new init container init-bundle-ca-trust

  • Removed the mounting of the volume {{ ansible_operator_meta.name }}-bundle-cacert from containers that really do not need it

  • Added the whole bundle_ca_crt logic to the migration job

I've successfully tested that change during my upgrade from awx-operator v2.12.1 to v2.15.0

- added a new init container init-bundle-ca-trust
- added volume ca-trust-extracted to the migration job
- added volume ca-trust-extracted to the init container init-database
- removed volume bundle-ca from all follow-up containers
@akkaba23
Copy link

Thank you for the nice work done on this PR @JoelKle .

@JoelKle
Copy link
Contributor Author

JoelKle commented May 7, 2024

@rooftopcellist @fosterseth Could you have a look on this PR? Thx :)

Comment on lines 88 to 90
securityContext:
runAsUser: 0
runAsGroup: 0
Copy link
Member

Choose a reason for hiding this comment

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

@JoelKle This will break on Openshift. Can we template this in only if is_k8s=true?

Copy link
Member

Choose a reason for hiding this comment

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

Did update-ca-trust extract require more permissions than just update-ca-trust? I am trying to understand why the securityContext bit was added.

Copy link
Contributor Author

@JoelKle JoelKle May 16, 2024

Choose a reason for hiding this comment

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

I removed the whole securityContext block from this PR. Now the init-container behaves as before.
@rooftopcellist Is this fine for you?

TL;DR
Withouth the runAsUser: 0 parameter the init-container runs the update-ca-trust command as uid=1000(awx) gid=0(root). That means the files in the folder /etc/pki/ca-trust/extracted are owned by awx:root
With the runAsUser: 0 parameter all files are owned by root:root which is more accurate.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The update-ca-trust extract behaves the same as withouth the extract. However with the extract the command may print more warnings, ...
Check the manpage of update-ca-trust extract > "COMMANDS"

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.

AWX database migration job fail when using custom CA certificate
3 participants