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

Support Kubernetes style TLS Secrets #4137

Closed
4 tasks done
aryan9600 opened this issue Aug 5, 2023 · 2 comments
Closed
4 tasks done

Support Kubernetes style TLS Secrets #4137

aryan9600 opened this issue Aug 5, 2023 · 2 comments
Labels
area/api API related issues and pull requests area/security Security related issues and pull requests enhancement New feature or request umbrella-issue Umbrella issue for tracking progress of a larger effort

Comments

@aryan9600
Copy link
Member

aryan9600 commented Aug 5, 2023

There are several Flux APIs that provide a way to configure TLS authentication. These APIs expect the specified Secret to contain three keys, namely caFile, certFile and keyFile. This allows for users to specify their TLS data, but it doesn't align with the API of a Kubernetes Secret of type TLS.
A TLS secret needs to contain the keys tls.crt for the certificate and tls.key for the private key. While it doesn't specify an exact key for the CA file, the common convention is to use ca.crt as used by cert-manager and ingress-nginx.

To make adoption and usage easier, we should adopt these standards in the Flux project as well. This change would require the following things:

  • OCIRepository, ImageRepository, Provider: Add support for tls.crt, tls.key and ca.crt keys in the Secret specified in .spec.certSecretRef and deprecate the currently supported keys, in a way that is similar to the deprecation of .spec.secretRef for TLS data in HelmRepository. Support for the existing keys would be completely dropped when the API receives it's next version bump.

    Note: Since Provider only supports accepting a set of CA certificates via caFile, only support for ca.crt shall be added. If and when, support for TLS client authentication is added, support for the tls.crt and tls.key keys shall also be added

  • HelmRepository: Drop support for the currently supported keys in the Secret specified in .spec.certSecretRef and replace it with the tls.crt, tls.key and ca.crt.

  • GitRepository: Since GitRepository is v1, we can't drop support for the caFile key as a Secret's supported keys are a part of the API and this'd be a breaking change. We can either leave the API as it is or add support for the ca.crt key and support both keys in the controller, but use the new key in docs and for generating Secrets using the Flux CLI.

  • CLI: Atm, we have two commands to generate a Secret with TLS data, flux create secret tls, flux create secret helm where both support the --ca-file, --cert-file and --key-file flags. Since we are separating TLS Secrets throughout the project, we should remove these flags from flux create secret helm and have one standard command for generating Secrets with TLS data. Furthermore, the logic behind flux create secret tls should be updated to generate Secrets using the new keys using the flags --ca-crt, --tls-key, --tls-crt.
    While flux create secret git also supports the --ca-file flag, since GitRepository expects the CA certificate to be in the same Secret as other auth data, it doesn't make sense to remove the flag altogether. Instead it should also be updated to be --ca-crt and use ca.crt as the key in the Secret.

@stefanprodan stefanprodan added the area/api API related issues and pull requests label Aug 5, 2023
@aryan9600 aryan9600 transferred this issue from fluxcd/source-controller Aug 7, 2023
@hiddeco
Copy link
Member

hiddeco commented Aug 8, 2023

Instead of deleting flux create secret helm right away, I would like it to be a more gradual deprecation in which we first log a deprecation warning. Which is a tad less aggressive towards users.

@hiddeco hiddeco added the enhancement New feature or request label Aug 8, 2023
@stefanprodan
Copy link
Member

As a first step we can add the new flags to all commands and deprecate the old flags. The controllers and the CLI should work with both formats in the next release. I agree that we should update the docs to use the new CLI args and Secret format.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/api API related issues and pull requests area/security Security related issues and pull requests enhancement New feature or request umbrella-issue Umbrella issue for tracking progress of a larger effort
Projects
None yet
Development

No branches or pull requests

3 participants