mirror of https://github.com/k3s-io/k3s
Ignore "unspecified" externalIP during LB create
Previously we always passed `Address: externalIP.String()` while creating a loadbalancer VIP. This passed "0.0.0.0" when externalIP was unspecified, effectively making it mandatory to specify an externalIP. This change correctly leaves `Address` unspecified when externalIP is unspecified (has a zero value). (Thanks to @justinsb for the report)pull/6/head
parent
9394635cc0
commit
75f49b331a
|
@ -607,15 +607,19 @@ func (lb *LoadBalancer) CreateTCPLoadBalancer(name, region string, externalIP ne
|
|||
}
|
||||
}
|
||||
|
||||
vip, err := vips.Create(lb.network, vips.CreateOpts{
|
||||
createOpts := vips.CreateOpts{
|
||||
Name: name,
|
||||
Description: fmt.Sprintf("Kubernetes external service %s", name),
|
||||
Address: externalIP.String(),
|
||||
Protocol: "TCP",
|
||||
ProtocolPort: ports[0].Port, //TODO: need to handle multi-port
|
||||
PoolID: pool.ID,
|
||||
Persistence: persistence,
|
||||
}).Extract()
|
||||
}
|
||||
if !externalIP.IsUnspecified() {
|
||||
createOpts.Address = externalIP.String()
|
||||
}
|
||||
|
||||
vip, err := vips.Create(lb.network, createOpts).Extract()
|
||||
if err != nil {
|
||||
if mon != nil {
|
||||
monitors.Delete(lb.network, mon.ID)
|
||||
|
|
Loading…
Reference in New Issue