-
Notifications
You must be signed in to change notification settings - Fork 336
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
perf(kuma-cp) cached client for fetching secrets on k8s #1393
Conversation
Signed-off-by: Jakub Dyszkiewicz <[email protected]>
Signed-off-by: Jakub Dyszkiewicz <[email protected]>
err = kubeCache.IndexField(context.Background(), &kube_core.Secret{}, "type", func(object kube_runtime.Object) []string { | ||
secret := object.(*kube_core.Secret) | ||
return []string{string(secret.Type)} | ||
}) | ||
if err != nil { | ||
return nil, errors.Wrap(err, "could not add index of Secret cache by field 'type'") | ||
} |
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.
Why not:
err = kubeCache.IndexField(context.Background(), &kube_core.Secret{}, "type", func(object kube_runtime.Object) []string { | |
secret := object.(*kube_core.Secret) | |
return []string{string(secret.Type)} | |
}) | |
if err != nil { | |
return nil, errors.Wrap(err, "could not add index of Secret cache by field 'type'") | |
} | |
if err := kubeCache.IndexField(context.Background(), &kube_core.Secret{}, "type", func(object kube_runtime.Object) []string { | |
secret := object.(*kube_core.Secret) | |
return []string{string(secret.Type)} | |
}); err != nil { | |
return nil, errors.Wrap(err, "could not add index of Secret cache by field 'type'") | |
} |
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.
(just a nit)
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.
It's less redable for me. I don't use if err := exp(); err != nil {
when exp()
is multiline.
Signed-off-by: Jakub Dyszkiewicz <[email protected]>
@@ -232,9 +232,9 @@ func addValidators(mgr kube_ctrl.Manager, rt core_runtime.Runtime, converter k8s | |||
mgr.GetWebhookServer().Register("/validate-v1-service", &kube_webhook.Admission{Handler: &k8s_webhooks.ServiceValidator{}}) | |||
log.Info("Registering a validation webhook for v1/Service", "path", "/validate-v1-service") | |||
|
|||
client, ok := k8s_extensions.FromNonCachedClientContext(rt.Extensions()) | |||
client, ok := k8s_extensions.FromSecretClientContext(rt.Extensions()) |
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.
Is it possible to receive a request in the SecretValidator
webhook which is not for kuma-system
namespace?
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.
no
- name: secret.validator.kuma-admission.kuma.io
namespaceSelector:
matchLabels:
kuma.io/system-namespace: "true"
Signed-off-by: Jakub Dyszkiewicz <[email protected]> (cherry picked from commit 04cd0de)
Signed-off-by: Jakub Dyszkiewicz <[email protected]> (cherry picked from commit 04cd0de) Co-authored-by: Jakub Dyszkiewicz <[email protected]>
Summary
See the explanation in the comment of the code. We used non-cached client for Secrets on Kubernetes because we could not use the regular cached client in ControllerManager. This was ok until we introduced Secrets into reconciliation loop (Secrets are taken into account of Mesh Hash, because Secrets are used for TLS settings of External Service).
This change brings a separate cached client for Secrets.
Documentation