Short port names for service load balancer

If a port name is longer than 15 characters we are unable to create
the associated service load balancer containers. Use our own short
name of `lb-port-{port}` to avoid naming issues.

For rancher/k3s/issues/90
This commit is contained in:
Erik Wilson 2019-03-14 18:53:00 +00:00
parent dc91c4850b
commit 7e1abf28f1

View File

@ -272,11 +272,8 @@ func (h *handler) newDeployment(svc *core.Service) (*apps.Deployment, error) {
}, },
} }
for i, port := range svc.Spec.Ports { for _, port := range svc.Spec.Ports {
portName := port.Name portName := fmt.Sprintf("lb-port-%d", port.Port)
if portName == "" {
portName = fmt.Sprintf("port-%d", i)
}
container := core.Container{ container := core.Container{
Name: portName, Name: portName,
Image: image, Image: image,