diff --git a/docs/kubectl.md b/docs/kubectl.md index df39769f368..7cd59182e3a 100644 --- a/docs/kubectl.md +++ b/docs/kubectl.md @@ -930,7 +930,6 @@ Usage: --output-version="": Output the formatted object with the given version (default api-version) --overrides="": An inline JSON override for the generated object. If this is non-empty, it is parsed used to override the generated object. Requires that the object supply a valid apiVersion field. --port=-1: The port that this container exposes. - --public-ip="": A public IP address to use for this service. -r, --replicas=1: Number of replicas to create for this container. Default 1 -s, --server="": The address of the Kubernetes API server --stderrthreshold=2: logs at or above this threshold go to stderr diff --git a/pkg/kubectl/cmd/run.go b/pkg/kubectl/cmd/run.go index 09f0195a48d..dc96df3959d 100644 --- a/pkg/kubectl/cmd/run.go +++ b/pkg/kubectl/cmd/run.go @@ -90,7 +90,6 @@ Examples: cmd.Flags().String("image", "", "The image for the container you wish to run.") cmd.Flags().IntP("replicas", "r", 1, "Number of replicas to create for this container. Default 1") cmd.Flags().Bool("dry-run", false, "If true, only print the object that would be sent, don't actually do anything") - cmd.Flags().String("public-ip", "", "A public IP address to use for this service.") cmd.Flags().String("overrides", "", "An inline JSON override for the generated object. If this is non-empty, it is parsed used to override the generated object. Requires that the object supply a valid apiVersion field.") cmd.Flags().Int("port", -1, "The port that this container exposes.") cmd.Flags().StringP("labels", "l", "", "Labels to apply to the pod(s) created by this call to run-container.") diff --git a/pkg/kubectl/run.go b/pkg/kubectl/run.go index 9bde1cf9713..2fad5ced9ec 100644 --- a/pkg/kubectl/run.go +++ b/pkg/kubectl/run.go @@ -73,8 +73,12 @@ func (BasicReplicationController) Generate(params map[string]string) (runtime.Ob }, }, } - port, err := strconv.Atoi(params["port"]) - if err != nil { + + if len(params["port"]) > 0 { + port, err := strconv.Atoi(params["port"]) + if err != nil { + return nil, err + } controller.Spec.Template.Spec.Containers[0].Ports = []api.Port{ { ContainerPort: port, diff --git a/pkg/kubectl/run_test.go b/pkg/kubectl/run_test.go index 07bd523a160..a6efa35fbb9 100644 --- a/pkg/kubectl/run_test.go +++ b/pkg/kubectl/run_test.go @@ -59,6 +59,42 @@ func TestGenerate(t *testing.T) { }, }, }, + { + params: map[string]string{ + "name": "foo", + "image": "someimage", + "replicas": "1", + "port": "80", + }, + expected: &api.ReplicationController{ + ObjectMeta: api.ObjectMeta{ + Name: "foo", + Labels: map[string]string{"run-container": "foo"}, + }, + Spec: api.ReplicationControllerSpec{ + Replicas: 1, + Selector: map[string]string{"run-container": "foo"}, + Template: &api.PodTemplateSpec{ + ObjectMeta: api.ObjectMeta{ + Labels: map[string]string{"run-container": "foo"}, + }, + Spec: api.PodSpec{ + Containers: []api.Container{ + { + Name: "foo", + Image: "someimage", + Ports: []api.Port{ + { + ContainerPort: 80, + }, + }, + }, + }, + }, + }, + }, + }, + }, { params: map[string]string{ "name": "foo", @@ -97,8 +133,8 @@ func TestGenerate(t *testing.T) { if !test.expectErr && err != nil { t.Errorf("unexpected error: %v", err) } - if !reflect.DeepEqual(obj, test.expected) { - t.Errorf("\nexpected:\n%v\nsaw:\n%v", test.expected, obj) + if !reflect.DeepEqual(obj.(*api.ReplicationController).Spec.Template, test.expected.Spec.Template) { + t.Errorf("\nexpected:\n%#v\nsaw:\n%#v", test.expected.Spec.Template, obj.(*api.ReplicationController).Spec.Template) } } }