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

⚠️ Make catalog server serve catalog contents over HTTPS #243

Closed

Conversation

everettraven
Copy link
Collaborator

@everettraven everettraven commented Apr 17, 2024

Description:

  • Updates the internal server.Server to have options for serving contents over HTTPS
  • Sets serving catalog contents over HTTPS, only configuration is the external https address, cert and key file
  • Adds cert-manager as a dependency and adds cert manager resources to the config to create the necessary self-signed certificates
  • Updates .goreleaser.yml to include cert-manager installation instructions since it is now a dependency again

adds cert-manager as a dependency again to create self-signed
certs for the catalog server

Signed-off-by: everettraven <everettraven@gmail.com>
@everettraven everettraven requested a review from a team as a code owner April 17, 2024 20:50
Signed-off-by: everettraven <everettraven@gmail.com>
Copy link

codecov bot commented Apr 17, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 48.84%. Comparing base (0d07c30) to head (495903c).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #243   +/-   ##
=======================================
  Coverage   48.84%   48.84%           
=======================================
  Files           8        8           
  Lines         434      434           
=======================================
  Hits          212      212           
  Misses        201      201           
  Partials       21       21           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -93,7 +93,7 @@ var _ = Describe("Catalog Unpacking", func() {
// the ProxyGet() call below needs an explicit port value, so if
// value from url.Port() is empty, we assume port 80.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// value from url.Port() is empty, we assume port 80.
// value from url.Port() is empty, we assume port 443.

@grokspawn
Copy link
Contributor

Looks like docs/fetching-catalog-contents.md, hack/scripts/demo-script.sh, README.md need updates for their port-forward instructions.

@@ -77,9 +77,11 @@ func main() {
catalogdVersion bool
systemNamespace string
catalogServerAddr string
httpExternalAddr string
httpsExternalAddr string
Copy link
Contributor

@grokspawn grokspawn Apr 24, 2024

Choose a reason for hiding this comment

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

possible I'm getting wrapped around the axle of nomenclature, but the description says that this defaults to https, and given the name it seems that the primary focus is https and I'm not clear on how they would disable it. All the relevant flags have actionable default values.

I'm not certain that we need to have an http escape hatch here, but if there isn't one can you update the PR description to say that we're moving exclusively to secured connections?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Description updated

Comment on lines +131 to +133
if s.ServeTLS {
return s.Server.ServeTLS(s.Listener, s.CertFile, s.KeyFile)
}
Copy link
Member

Choose a reason for hiding this comment

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

I finally got the upstream PR to make the controller-runtime HTTP server runnable exported, so I think we should plan to drop this package when there is a release containing it

With that in mind, I would suggest setting up TLS via an explicit s.Listener. That would also eliminate the slight weirdness with the server struct having CertFile and KeyFile fields that are inert when ServeTLS: false.

Copy link
Contributor

@trgeiger trgeiger May 2, 2024

Choose a reason for hiding this comment

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

Do you mean always creating a listener in main.go and passing that into the Server creation, conditionally enabling TLS if the cert/key exist?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@trgeiger that is my understanding. I would also revert the changes that I made to the server.Server. I read the wrong section of the net/http package and realize now that the changes I made were unnecessary and passing in the listener is the "right" way to go here

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks, that clears that up for me

@@ -14,5 +14,5 @@ kind: Kustomization
resources:
- ../crd
- ../rbac
- ../certmanager
Copy link
Member

Choose a reason for hiding this comment

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

This will break downstream for Red Hat because they use a different certificate manager on OCP clusters.

I'd suggest setting things up similar to what we did in rukpak: https://github.com/operator-framework/rukpak/tree/main/manifests

@@ -89,10 +91,12 @@ func main() {
"Enabling this will ensure there is only one active controller manager.")
flag.StringVar(&systemNamespace, "system-namespace", "", "The namespace catalogd uses for internal state, configuration, and workloads")
flag.StringVar(&catalogServerAddr, "catalogs-server-addr", ":8083", "The address where the unpacked catalogs' content will be accessible")
flag.StringVar(&httpExternalAddr, "http-external-address", "http://catalogd-catalogserver.catalogd-system.svc", "The external address at which the http server is reachable.")
flag.StringVar(&httpsExternalAddr, "https-external-address", "https://catalogd-catalogserver.catalogd-system.svc", "The external address at which the http server is reachable.")
Copy link

@tmshort tmshort Apr 24, 2024

Choose a reason for hiding this comment

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

We are effectively removing a flag from this executable. Is this considered a breaking change? Should the http-external-address flag be kept but... (unsure what to do with it right now).

Copy link

Choose a reason for hiding this comment

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

That being said, and in addition to @grokspawn's comment. Would it be possible for this to be set to an http:// address? Is that supported? Can we run either?

Comment on lines +98 to +99
flag.StringVar(&certfile, "tls-cert", "/var/certs/tls.crt", "The certificate file used for serving catalog contents over HTTPS")
flag.StringVar(&keyfile, "tls-key", "/var/certs/tls.key", "The key file used for serving catalog contents over HTTPS")
Copy link
Member

Choose a reason for hiding this comment

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

These defaults could be annoying for running the binary locally outside of a container.

WDYT about:

  1. Making these default to empty strings
  2. If they are empty, run the server without TLS
  3. If only one is set, fail
  4. If both are set, load cert/key from the specified locations, and run with TLS

Copy link
Member

Choose a reason for hiding this comment

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

Also, do we need to think about what happens during a key rotation? We might need a file watcher to detect when the keys change.

Copy link

Choose a reason for hiding this comment

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

What happens if an http:// address is specified?

Copy link
Member

Choose a reason for hiding this comment

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

Good point. I can't think of a good reason for this flag to carry a full URL with a scheme. Let's just make it --external-address=<ip>:<port>?

@everettraven
Copy link
Collaborator Author

Moving this to a draft until I have cycles to address review comments and make changes

@everettraven everettraven marked this pull request as draft April 24, 2024 15:00
@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Apr 24, 2024
@everettraven
Copy link
Collaborator Author

Closing in favor of @trgeiger 's PR (#263)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants