mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-04 01:40:07 +00:00
Merge pull request #1238 from brendandburns/service
Add an earlier check and error for names that won't work for services.
This commit is contained in:
commit
fb4199cba7
@ -29,6 +29,7 @@ import (
|
|||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
|
||||||
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/util/wait"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/util/wait"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/version"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/version"
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
@ -174,6 +175,9 @@ func portsFromString(spec string) []api.Port {
|
|||||||
|
|
||||||
// RunController creates a new replication controller named 'name' which creates 'replicas' pods running 'image'.
|
// RunController creates a new replication controller named 'name' which creates 'replicas' pods running 'image'.
|
||||||
func RunController(image, name string, replicas int, client client.Interface, portSpec string, servicePort int) error {
|
func RunController(image, name string, replicas int, client client.Interface, portSpec string, servicePort int) error {
|
||||||
|
if servicePort > 0 && !util.IsDNSLabel(name) {
|
||||||
|
return fmt.Errorf("Service creation requested, but an invalid name for a service was provided (%s). Service names must be valid DNS labels.", name)
|
||||||
|
}
|
||||||
controller := &api.ReplicationController{
|
controller := &api.ReplicationController{
|
||||||
JSONBase: api.JSONBase{
|
JSONBase: api.JSONBase{
|
||||||
ID: name,
|
ID: name,
|
||||||
|
Loading…
Reference in New Issue
Block a user