mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-09 03:57:41 +00:00
Merge pull request #6625 from wojtek-t/list_minions_supports_labels
ListMinions support for selectors
This commit is contained in:
commit
6a86608634
@ -41,6 +41,8 @@ import (
|
|||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/auth/handlers"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/auth/handlers"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/cloudprovider"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/cloudprovider"
|
||||||
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/fields"
|
||||||
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/master/ports"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/master/ports"
|
||||||
controlleretcd "github.com/GoogleCloudPlatform/kubernetes/pkg/registry/controller/etcd"
|
controlleretcd "github.com/GoogleCloudPlatform/kubernetes/pkg/registry/controller/etcd"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/registry/endpoint"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/registry/endpoint"
|
||||||
@ -567,7 +569,7 @@ func (m *Master) getServersToValidate(c *Config) map[string]apiserver.Server {
|
|||||||
}
|
}
|
||||||
serversToValidate[fmt.Sprintf("etcd-%d", ix)] = apiserver.Server{Addr: addr, Port: port, Path: "/v2/keys/"}
|
serversToValidate[fmt.Sprintf("etcd-%d", ix)] = apiserver.Server{Addr: addr, Port: port, Path: "/v2/keys/"}
|
||||||
}
|
}
|
||||||
nodes, err := m.nodeRegistry.ListMinions(api.NewDefaultContext())
|
nodes, err := m.nodeRegistry.ListMinions(api.NewDefaultContext(), labels.Everything(), fields.Everything())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Errorf("Failed to list minions: %v", err)
|
glog.Errorf("Failed to list minions: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ import (
|
|||||||
|
|
||||||
// Registry is an interface for things that know how to store node.
|
// Registry is an interface for things that know how to store node.
|
||||||
type Registry interface {
|
type Registry interface {
|
||||||
ListMinions(ctx api.Context) (*api.NodeList, error)
|
ListMinions(ctx api.Context, label labels.Selector, field fields.Selector) (*api.NodeList, error)
|
||||||
CreateMinion(ctx api.Context, minion *api.Node) error
|
CreateMinion(ctx api.Context, minion *api.Node) error
|
||||||
UpdateMinion(ctx api.Context, minion *api.Node) error
|
UpdateMinion(ctx api.Context, minion *api.Node) error
|
||||||
GetMinion(ctx api.Context, minionID string) (*api.Node, error)
|
GetMinion(ctx api.Context, minionID string) (*api.Node, error)
|
||||||
@ -45,8 +45,8 @@ func NewRegistry(s rest.StandardStorage) Registry {
|
|||||||
return &storage{s}
|
return &storage{s}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *storage) ListMinions(ctx api.Context) (*api.NodeList, error) {
|
func (s *storage) ListMinions(ctx api.Context, label labels.Selector, field fields.Selector) (*api.NodeList, error) {
|
||||||
obj, err := s.List(ctx, labels.Everything(), fields.Everything())
|
obj, err := s.List(ctx, label, field)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ import (
|
|||||||
// Registry is an interface implemented by things that know how to store Pod objects.
|
// Registry is an interface implemented by things that know how to store Pod objects.
|
||||||
type Registry interface {
|
type Registry interface {
|
||||||
// ListPods obtains a list of pods having labels which match selector.
|
// ListPods obtains a list of pods having labels which match selector.
|
||||||
ListPods(ctx api.Context, selector labels.Selector) (*api.PodList, error)
|
ListPods(ctx api.Context, label labels.Selector) (*api.PodList, error)
|
||||||
// Watch for new/changed/deleted pods
|
// Watch for new/changed/deleted pods
|
||||||
WatchPods(ctx api.Context, label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error)
|
WatchPods(ctx api.Context, label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error)
|
||||||
// Get a specific pod
|
// Get a specific pod
|
||||||
|
@ -59,7 +59,7 @@ func (r *MinionRegistry) SetError(err error) {
|
|||||||
r.Err = err
|
r.Err = err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *MinionRegistry) ListMinions(ctx api.Context) (*api.NodeList, error) {
|
func (r *MinionRegistry) ListMinions(ctx api.Context, label labels.Selector, field fields.Selector) (*api.NodeList, error) {
|
||||||
r.Lock()
|
r.Lock()
|
||||||
defer r.Unlock()
|
defer r.Unlock()
|
||||||
return &r.Minions, r.Err
|
return &r.Minions, r.Err
|
||||||
|
@ -295,7 +295,7 @@ func (rs *REST) createExternalLoadBalancer(ctx api.Context, service *api.Service
|
|||||||
if !ok {
|
if !ok {
|
||||||
return fmt.Errorf("the cloud provider does not support zone enumeration.")
|
return fmt.Errorf("the cloud provider does not support zone enumeration.")
|
||||||
}
|
}
|
||||||
hosts, err := rs.machines.ListMinions(ctx)
|
hosts, err := rs.machines.ListMinions(ctx, labels.Everything(), fields.Everything())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user