mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-04 18:00:08 +00:00
plumb the new multicidr clusterip allocator
This commit is contained in:
parent
65e6938946
commit
164276175f
@ -61,6 +61,7 @@ import (
|
||||
serviceaccountstore "k8s.io/kubernetes/pkg/registry/core/serviceaccount/storage"
|
||||
kubeschedulerconfig "k8s.io/kubernetes/pkg/scheduler/apis/config"
|
||||
"k8s.io/kubernetes/pkg/util/async"
|
||||
netutils "k8s.io/utils/net"
|
||||
)
|
||||
|
||||
// Config provides information needed to build RESTStorage for core.
|
||||
@ -350,7 +351,16 @@ func (c *Config) newServiceIPAllocators() (registries rangeRegistries, primaryCl
|
||||
if err != nil {
|
||||
return rangeRegistries{}, nil, nil, nil, err
|
||||
}
|
||||
primaryClusterIPAllocator, err = ipallocator.NewIPAllocator(&serviceClusterIPRange, networkingv1alphaClient, c.Informers.Networking().V1alpha1().IPAddresses())
|
||||
// TODO(aojea) Revisit the initialization of the allocators
|
||||
// since right now it depends on the service-cidr flags and
|
||||
// sets the default IPFamily that may not be coherent with the
|
||||
// existing default ServiceCIDR
|
||||
primaryClusterIPAllocator, err = ipallocator.NewMetaAllocator(
|
||||
networkingv1alphaClient,
|
||||
c.Informers.Networking().V1alpha1().ServiceCIDRs(),
|
||||
c.Informers.Networking().V1alpha1().IPAddresses(),
|
||||
netutils.IsIPv6CIDR(&serviceClusterIPRange),
|
||||
)
|
||||
if err != nil {
|
||||
return rangeRegistries{}, nil, nil, nil, fmt.Errorf("cannot create cluster IP allocator: %v", err)
|
||||
}
|
||||
@ -381,7 +391,16 @@ func (c *Config) newServiceIPAllocators() (registries rangeRegistries, primaryCl
|
||||
if err != nil {
|
||||
return rangeRegistries{}, nil, nil, nil, err
|
||||
}
|
||||
secondaryClusterIPAllocator, err = ipallocator.NewIPAllocator(&c.Services.SecondaryClusterIPRange, networkingv1alphaClient, c.Informers.Networking().V1alpha1().IPAddresses())
|
||||
// TODO(aojea) Revisit the initialization of the allocators
|
||||
// since right now it depends on the service-cidr flags and
|
||||
// sets the default IPFamily that may not be coherent with the
|
||||
// existing default ServiceCIDR
|
||||
secondaryClusterIPAllocator, err = ipallocator.NewMetaAllocator(
|
||||
networkingv1alphaClient,
|
||||
c.Informers.Networking().V1alpha1().ServiceCIDRs(),
|
||||
c.Informers.Networking().V1alpha1().IPAddresses(),
|
||||
netutils.IsIPv6CIDR(&c.Services.SecondaryClusterIPRange),
|
||||
)
|
||||
if err != nil {
|
||||
return rangeRegistries{}, nil, nil, nil, fmt.Errorf("cannot create cluster secondary IP allocator: %v", err)
|
||||
}
|
||||
|
@ -405,7 +405,8 @@ func (al *Allocators) allocIPs(service *api.Service, toAlloc map[api.IPFamily]st
|
||||
var allocatedIP net.IP
|
||||
var err error
|
||||
if utilfeature.DefaultFeatureGate.Enabled(features.MultiCIDRServiceAllocator) {
|
||||
svcAllocator, ok := allocator.(*ipallocator.Allocator)
|
||||
// TODO: simplify this and avoid all this duplicate code
|
||||
svcAllocator, ok := allocator.(*ipallocator.MetaAllocator)
|
||||
if ok {
|
||||
allocatedIP, err = svcAllocator.AllocateNextService(service)
|
||||
} else {
|
||||
@ -425,7 +426,8 @@ func (al *Allocators) allocIPs(service *api.Service, toAlloc map[api.IPFamily]st
|
||||
}
|
||||
var err error
|
||||
if utilfeature.DefaultFeatureGate.Enabled(features.MultiCIDRServiceAllocator) {
|
||||
svcAllocator, ok := allocator.(*ipallocator.Allocator)
|
||||
// TODO: simplify this and avoid all this duplicate code
|
||||
svcAllocator, ok := allocator.(*ipallocator.MetaAllocator)
|
||||
if ok {
|
||||
err = svcAllocator.AllocateService(service, parsedIP)
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user