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

egress rule for postgres should not be tied to devMode #489

Closed
blancharda opened this issue Jun 17, 2024 · 5 comments · Fixed by #554
Closed

egress rule for postgres should not be tied to devMode #489

blancharda opened this issue Jun 17, 2024 · 5 comments · Fixed by #554
Assignees
Labels
documentation Improvements or additions to documentation good first issue Good for newcomers possible-bug Something may not be working sso Issues related to the SSO stack (Keycloak/Authservice)
Milestone

Comments

@blancharda
Copy link
Contributor

Overview

Currently, the egress rule for postgres is conditioned on devMode: false.
DevMode provides increased logging (among other things), and there are many reasons why you might want both. In any case, if an external database is configured, the egress rule should be created accordingly.

Environment

App version: 0.22.1-registry1

Steps to reproduce

  1. devMode: true
  2. configure an external postgres database
  3. roll the dice

Expected result

If a postgres database is configured, the egress rule should be created accordingly

Actual Result

The rule is only created when devMode is false

Additional Context

This may be a case where the race (see related gitlab issue)between pepr creating the netpol and the keycloak pods starting up may have masked the behavior on initial install.. but now that pepr is more consistent in applying rules, upgrades in our long lived environments are failing to restart keycloak pods with JDBC connection timeouts.

@blancharda blancharda added the possible-bug Something may not be working label Jun 17, 2024
@anthonywendt
Copy link
Contributor

anthonywendt commented Jun 18, 2024

Wanted to add some more devMode issues when it comes to configuration of an external database. devMode is also used to template the secret that contains the postgres configuration as well as the statefulset that is created. devMode and external database configuration should not be coupled. Might need to create a separate issue to define the scope and possibly remove devMode. Or that may be resolved as part of this issue?

@anthonywendt
Copy link
Contributor

Also, instead of creating a new issue I wanted to make sure it was clear that the race condition mentioned in the additional context of this issue is also resolved as part of this. The uds-package.yaml is part of the same helm chart that deploys keycloak itself. That uds-package.yaml needs to be decoupled from the keycloak helm chart and be applied and ready before keycloak is ever deployed.

@mjnagel
Copy link
Contributor

mjnagel commented Jun 20, 2024

Happy to dive in more and see if there's a different solution, but as @anthonywendt pointed out devMode does not allow you to use postgres currently (that was intentional, devMode is just meant to be for ephemeral dev). If the log level is the main reason you want dev mode it might be worth just moving those to a different conditional for debug mode or something similar.

@blancharda
Copy link
Contributor Author

blancharda commented Jun 21, 2024

It's very unintuitive that configuring postgres connection info doesn't result in using postgres unless you know to disable the default devMode value..

@mjnagel
Copy link
Contributor

mjnagel commented Jun 21, 2024

@blancharda yeah agreed. There's a small note hidden in the readme that says by default, this package deploys Keycloak in "dev mode", which disables HA and uses an H2 database persisted to a PVC. This is not suitable for production use, but is useful for development and testing but I don't think that's sufficient here (especially since its in a readme in a subdir, not surfaced on the docs site).

A couple things I think we could/should do here:

  • Be more clear in the docs about what devMode is/does - and ensure that this is more visible (i.e. docs site)
  • Potentially use helm fail to block incompatible setup of devMode + postgres (block bad things path) OR modify conditionals so that a DB takes precedence over dev mode if provided (fix it for you path)
  • Move debug logging to a separate/additional flag so that it can be toggled independently of devMode.

@mjnagel mjnagel added sso Issues related to the SSO stack (Keycloak/Authservice) good first issue Good for newcomers documentation Improvements or additions to documentation labels Jul 2, 2024
@noahpb noahpb self-assigned this Jul 3, 2024
mjnagel added a commit that referenced this issue Jul 12, 2024
## Description
Updates the internal `keycloak` helm chart to be more explicit about
using an external postgres database connection.
Notable changes are:
- Configures egress rule and `keycloak` env vars for postgres based on
`postgresql` being populated
- Defaults `postgresql.username`, `postgresql.password`,
`postgresql.database`, and `postgresql.host` to an empty string
- Adds option to enable debug logging via `debugMode: true`
- Adds a `fail` case when `devMode` is true and `postgresql` has values
defined
- Adds fail cases when users do not supply required values for
`postgresql` when `devMode` is `false`

## Related Issue

Fixes #489 
## Type of change

- [x] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Other (security config, docs update, etc)

## Checklist before merging

- [ ] Test, docs, adr added or updated as needed
- [ ] [Contributor
Guide](https://github.com/defenseunicorns/uds-template-capability/blob/main/CONTRIBUTING.md)
followed

---------

Co-authored-by: Micah Nagel <micah.nagel@defenseunicorns.com>
@mjnagel mjnagel added this to the 0.24.0 milestone Jul 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation good first issue Good for newcomers possible-bug Something may not be working sso Issues related to the SSO stack (Keycloak/Authservice)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants