-
Notifications
You must be signed in to change notification settings - Fork 3.4k
secret-sync: extract secret-sync logic from gateway api controller & introduce hive cell #29100
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
secret-sync: extract secret-sync logic from gateway api controller & introduce hive cell #29100
Conversation
/test |
9b1d854
to
d850dce
Compare
/test |
/test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CODEOWNERS looks good to me, that's the contributing change I was assigned for. Read through the rest too and have some feedback.
d850dce
to
9b7c82a
Compare
Thanks a lot for your valuable feedback @bimmlerd ! I tried to address and answer your concerns / questions! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM for me!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
/test |
In preparation for reusing the secretsyncer for Ingress too, this commit removes the Gateway API related field `controllerName` from the struct `secretSyncer`. Signed-off-by: Marco Hofstetter <marco.hofstetter@isovalent.com>
As a preparation for extracting the secretSyncer into its own package, this commit adds the logger as field to the secretSyncer. Signed-off-by: Marco Hofstetter <marco.hofstetter@isovalent.com>
In preparation to extract the secret syncer into its own package, the Gateway API related GatewayAPI watch defined in the method `enqueueTLSSecrets` has been converted into a function. This way it can be passed into the secretSyncer when used by the package gatewayapi. Signed-off-by: Marco Hofstetter <marco.hofstetter@isovalent.com>
This commit changes the secret-sync label prefix for owning namespace and name from `io.cilium.gateway` to `secretsync.cilium.io`. This way the same label can be re-used for Cilium Ingress secret sync. Signed-off-by: Marco Hofstetter <marco.hofstetter@isovalent.com>
This commit removes the unused field scheme from the secretSyncer. Signed-off-by: Marco Hofstetter <marco.hofstetter@isovalent.com>
In preparation to re-use the secret-syncer from Gateway API for Cilium Ingress, the mainObject (e.g. Gateway) and mainObjectEnqueueFunc (how to map changed Gateways to referenced Secrets) are represented as field in the `secretSyncer` and passed on creation. Signed-off-by: Marco Hofstetter <marco.hofstetter@isovalent.com>
This commit extracts the function mainObjectReferencedFunc as field of the `secretSyncer` to pass this function into the secret syncer. This enables to re-use the secretsyncer for Cilium Ingress. Signed-off-by: Marco Hofstetter <marco.hofstetter@isovalent.com>
This commit moves the reconcile helper functions (fail & success) into the controller-runtime package. This way they can be used by multiple reconcilers over different packages. Signed-off-by: Marco Hofstetter <marco.hofstetter@isovalent.com>
This commit extracts the secret-sync related Gateway API functions into a dedicated file. This way the secret-sync can be moved into its own package. Signed-off-by: Marco Hofstetter <marco.hofstetter@isovalent.com>
This commit extracts the secretSyncer into its own package. Signed-off-by: Marco Hofstetter <marco.hofstetter@isovalent.com>
This commit introduces a dedicated cell for the TLS Secret Sync. Cells that are interested in having TLS Secrets synced (e.g. Gateway API) register themself as SecretSyncRegistration by providing information about which Secrets are required to sync. Signed-off-by: Marco Hofstetter <marco.hofstetter@isovalent.com>
This commit moves the unit-test of the secret-sync reconciliation back into the secretsync package. To be able to use the Gateway without introducing a cyclic dependency, a dedicated test package `secretsync_test` is used. Signed-off-by: Marco Hofstetter <marco.hofstetter@isovalent.com>
With this commit, the usage of the global logger in `EnqueueTLSSecrets` gets replaced with a logger passed as function argument. Signed-off-by: Marco Hofstetter <marco.hofstetter@isovalent.com>
9b7c82a
to
383fae6
Compare
rebased to |
/test |
With cilium#28982 a check got introduced that disables the Gateway API functionality if the required Gateway API CRDs aren't installed in the cluster. But this check is not executed when the secret sync registrations is performed. This results in failures in the secret-sync: ``` level=error msg="kind must be registered to the Scheme" error="no kind is registered for the type v1.Gateway in scheme \"k8s.io/client-go/kubernetes/scheme/register.go:80\"" logger=controller-runtime.source.EventHandler subsys=controller-runtime ``` Therefore, this commit adds the check to the secret sync registration too. Fixes: cilium#29100 Signed-off-by: Marco Hofstetter <marco.hofstetter@isovalent.com>
With #28982 a check got introduced that disables the Gateway API functionality if the required Gateway API CRDs aren't installed in the cluster. But this check is not executed when the secret sync registrations is performed. This results in failures in the secret-sync: ``` level=error msg="kind must be registered to the Scheme" error="no kind is registered for the type v1.Gateway in scheme \"k8s.io/client-go/kubernetes/scheme/register.go:80\"" logger=controller-runtime.source.EventHandler subsys=controller-runtime ``` Therefore, this commit adds the check to the secret sync registration too. Fixes: #29100 Signed-off-by: Marco Hofstetter <marco.hofstetter@isovalent.com>
With cilium#28982 a check got introduced that disables the Gateway API functionality if the required Gateway API CRDs aren't installed in the cluster. But this check is not executed when the secret sync registrations is performed. This results in failures in the secret-sync: ``` level=error msg="kind must be registered to the Scheme" error="no kind is registered for the type v1.Gateway in scheme \"k8s.io/client-go/kubernetes/scheme/register.go:80\"" logger=controller-runtime.source.EventHandler subsys=controller-runtime ``` Therefore, this commit adds the check to the secret sync registration too. Fixes: cilium#29100 Signed-off-by: Marco Hofstetter <marco.hofstetter@isovalent.com>
Follow up of #29017
In preparation for migrating the Cilium Ingress controller to use the controller-runtime library (#28911), the K8s TLS Secret synchronization logic from the Gateway API controller gets untangled from the rest of Gateway API logic and extracted into its own Hive Cell. Dependent cells can register their need for having Secrets synced.
This way, the Cilium Ingress controller can re-use the existing logic that already uses the controller-runtime library. (will be done in an upcoming PR).
For more information, please refer to the individual commits.