mirror of
https://github.com/k3s-io/k3s.git
synced 2024-06-07 19:41:36 +00:00
Monitor endpoint changes to trigger service-lb
This commit is contained in:
parent
793ac4fb89
commit
3df9155d02
@ -50,9 +50,10 @@ func Register(ctx context.Context, kubernetes kubernetes.Interface, enabled bool
|
||||
|
||||
clients.Service.OnChange(ctx, "svccontroller", h.onChange)
|
||||
changeset.Watch(ctx, "svccontroller-watcher",
|
||||
h.onPodChange,
|
||||
h.onResourceChange,
|
||||
clients.Service,
|
||||
clients.Pod)
|
||||
clients.Pod,
|
||||
clients.Endpoints)
|
||||
|
||||
return nil
|
||||
}
|
||||
@ -66,7 +67,16 @@ type handler struct {
|
||||
services coregetter.ServicesGetter
|
||||
}
|
||||
|
||||
func (h *handler) onPodChange(name, namespace string, obj runtime.Object) ([]changeset.Key, error) {
|
||||
func (h *handler) onResourceChange(name, namespace string, obj runtime.Object) ([]changeset.Key, error) {
|
||||
if ep, ok := obj.(*core.Endpoints); ok {
|
||||
return []changeset.Key{
|
||||
{
|
||||
Name: ep.Name,
|
||||
Namespace: ep.Namespace,
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
|
||||
pod, ok := obj.(*core.Pod)
|
||||
if !ok {
|
||||
return nil, nil
|
||||
|
@ -72,6 +72,7 @@ func main() {
|
||||
|
||||
if err := generator.ControllersForForeignTypes(basePackage, corev1.SchemeGroupVersion, []interface{}{
|
||||
corev1.ServiceAccount{},
|
||||
corev1.Endpoints{},
|
||||
corev1.Service{},
|
||||
corev1.Pod{},
|
||||
corev1.ConfigMap{},
|
||||
|
Loading…
Reference in New Issue
Block a user