mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-13 21:25:09 +00:00
Fix kubernetes
and kubernetes-ro
services creation
If `kube-apiserver` is started before `etcd` is reachable, `kube-apiserver` fails to create those services. However, in the `Create` function, an IP has already been reserved for them. When `etcd` comes back, the `Create` function fails because it considers that the IP is already used. If the service couldn't be created, the reserved IP should be released.
This commit is contained in:
@@ -110,11 +110,13 @@ func (rs *REST) Create(ctx api.Context, obj runtime.Object) (runtime.Object, err
|
||||
if service.Spec.CreateExternalLoadBalancer {
|
||||
err := rs.createExternalLoadBalancer(ctx, service)
|
||||
if err != nil {
|
||||
rs.portalMgr.Release(net.ParseIP(service.Spec.PortalIP))
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
if err := rs.registry.CreateService(ctx, service); err != nil {
|
||||
rs.portalMgr.Release(net.ParseIP(service.Spec.PortalIP))
|
||||
err = rest.CheckGeneratedNameError(rest.Services, err, service)
|
||||
return nil, err
|
||||
}
|
||||
|
Reference in New Issue
Block a user