kubernetes/pkg/kubectl
Kubernetes Submit Queue 05192d9d57 Merge pull request #33319 from juanvallejo/jvallejo/add-option-to-set-nodeport
Automatic merge from submit-queue

Add option to set a service nodeport

**Release note**:
```release-note
Add kubectl --node-port option for specifying the service nodeport
```

This patch adds the option to set a nodeport when creating a NodePort
service. In case of a port allocation error due to a specified port
being out of the valid range, the error now includes the valid
range. If a `--node-port` value is not specified, it defaults to zero, in
which case the allocator will default to its current behavior of
assigning an available port.

This patch also adds a new helper function in `cmd/util/helpers.go` to
retrieve `Int32` cobra flags.

**Example**
```
# create a nodeport service with an invalid port
$ kubectl create service nodeport mynodeport --tcp=8080:7777 --node-port=1
The Service "mynodeport" is invalid: spec.ports[0].nodePort: Invalid
value: 1: provided port is not in the valid range. Valid ports range
from 30000-32767

# create a nodeport service with a valid port
$ kubectl create service nodeport mynodeport --tcp=8080:7777 --node-port=30000
service "mynodeport" created

# create a nodeport service with a port already in use
$ kubectl create service nodeport mynodeport --tcp=8080:7777 --node-port=30000
The Service "mynodeport" is invalid: spec.ports[0].nodePort: Invalid value: 3000: provided port is already allocated

$ kubectl describe service mynodeport
Name:                   mynodeport
Namespace:              default
Labels:                 app=mynodeport
Selector:               app=mynodeport
Type:                   NodePort
IP:                     172.30.81.254
Port:                   8080-7777       8080/TCP
NodePort:               8080-7777       30000/TCP
Endpoints:              <none>
Session Affinity:       None
No events.
```

@fabianofranz
2016-10-05 15:00:32 -07:00
..
cmd Merge pull request #33319 from juanvallejo/jvallejo/add-option-to-set-nodeport 2016-10-05 15:00:32 -07:00
metricsutil Fix printing container usage. 2016-09-14 12:11:24 +02:00
resource allow kubectl -f to filter by selector 2016-09-30 00:42:35 -07:00
testing Update generated files due to dependency shift. 2016-08-09 10:41:09 -05:00
apply.go delete private interface with no references in package 2016-09-20 00:13:16 +00:00
autoscale.go Remove "All rights reserved" from all the headers. 2016-06-29 17:47:36 -07:00
bash_comp_utils.go Remove "All rights reserved" from all the headers. 2016-06-29 17:47:36 -07:00
configmap_test.go Remove "All rights reserved" from all the headers. 2016-06-29 17:47:36 -07:00
configmap.go Move IsSecretKey into util/validation 2016-07-03 02:19:09 -07:00
custom_column_printer_test.go 24133 fix: --no-headers works with custom columns now 2016-07-07 10:04:09 +02:00
custom_column_printer.go Simplify the output in AfterPrint() 2016-09-08 09:42:17 +10:00
deployment_test.go Add "create deployment" sub-command 2016-08-08 13:24:30 +10:00
deployment.go Add "create deployment" sub-command 2016-08-08 13:24:30 +10:00
describe_test.go kubectl: move events sorting interface to the api for general use 2016-09-18 19:25:42 +02:00
describe.go Enable kubectl describe rs to work when apiserver does not support pods 2016-10-04 13:27:31 -07:00
doc.go Use Go canonical import paths 2016-07-16 13:48:21 -04:00
explain.go Remove "All rights reserved" from all the headers. 2016-06-29 17:47:36 -07:00
generate_test.go Remove "All rights reserved" from all the headers. 2016-06-29 17:47:36 -07:00
generate.go Remove "All rights reserved" from all the headers. 2016-06-29 17:47:36 -07:00
history.go kubectl: refactor rollout history to be more configurable 2016-07-12 10:36:14 +02:00
interfaces.go Remove "All rights reserved" from all the headers. 2016-06-29 17:47:36 -07:00
kubectl_test.go Remove "All rights reserved" from all the headers. 2016-06-29 17:47:36 -07:00
kubectl.go make shortcut expanding restmapper handle all 2016-09-15 11:03:51 -04:00
namespace_test.go Fix namespace_test error message 2016-08-08 12:08:57 +10:00
namespace.go Remove "All rights reserved" from all the headers. 2016-06-29 17:47:36 -07:00
OWNERS Remove bgrant from pkg/OWNERS and pkg/kubectl/OWNERS since he has plenty to do. 2016-06-16 08:21:27 -07:00
proxy_server_test.go Make "attach" and "exec" rejection in proxy more explicit 2016-07-19 20:50:19 +02:00
proxy_server.go Fix various typos in kubectl 2016-08-02 19:51:51 +03:00
quota_test.go Add --scopes to kubectl-create-quota and add tests 2016-07-26 14:12:35 +02:00
quota.go Add --scopes to kubectl-create-quota and add tests 2016-07-26 14:12:35 +02:00
resource_filter.go add resource handling before printing 2016-09-21 10:03:59 -04:00
resource_printer_test.go add resource handling before printing 2016-09-21 10:03:59 -04:00
resource_printer.go formatting json printer for runtime.Unknown 2016-09-29 08:45:08 -07:00
rollback.go rollout undo add dry-run implementation 2016-09-08 08:02:04 +08:00
rolling_updater_test.go convert rest of kubectl to generated clients 2016-09-12 08:22:34 -04:00
rolling_updater.go convert rolling updater to generated client 2016-09-12 07:38:34 -04:00
rollout_status_test.go convert rest of kubectl to generated clients 2016-09-12 08:22:34 -04:00
rollout_status.go convert rest of kubectl to generated clients 2016-09-12 08:22:34 -04:00
run_test.go add port validate when --port is set or --expose=true 2016-09-01 17:24:02 +08:00
run.go use len > 0 to replace port > 0 2016-09-28 10:23:25 +08:00
scale_test.go convert rest of kubectl to generated clients 2016-09-12 08:22:34 -04:00
scale.go convert rest of kubectl to generated clients 2016-09-12 08:22:34 -04:00
secret_for_docker_registry_test.go Remove "All rights reserved" from all the headers. 2016-06-29 17:47:36 -07:00
secret_for_docker_registry.go Remove "All rights reserved" from all the headers. 2016-06-29 17:47:36 -07:00
secret_for_tls_test.go the created path should be closed in test case 2016-09-06 11:08:52 +08:00
secret_for_tls.go Remove "All rights reserved" from all the headers. 2016-06-29 17:47:36 -07:00
secret_test.go Remove "All rights reserved" from all the headers. 2016-06-29 17:47:36 -07:00
secret.go Move IsSecretKey into util/validation 2016-07-03 02:19:09 -07:00
service_basic_test.go Add "create service" sub-commands 2016-08-08 12:31:21 +10:00
service_basic.go make portallocator.ErrNotInRange a type 2016-10-04 13:19:24 -04:00
service_test.go Merge pull request #28239 from ApsOps/kubectl-expose-headless-svc 2016-08-02 01:18:19 -07:00
service.go Merge pull request #28239 from ApsOps/kubectl-expose-headless-svc 2016-08-02 01:18:19 -07:00
serviceaccount_test.go Remove "All rights reserved" from all the headers. 2016-06-29 17:47:36 -07:00
serviceaccount.go Remove "All rights reserved" from all the headers. 2016-06-29 17:47:36 -07:00
sorted_resource_name_list_test.go Remove "All rights reserved" from all the headers. 2016-06-29 17:47:36 -07:00
sorted_resource_name_list.go Merge pull request #28110 from mfojtik/describe-volume-mounts 2016-06-30 17:15:05 -07:00
sorting_printer_test.go Remove "All rights reserved" from all the headers. 2016-06-29 17:47:36 -07:00
sorting_printer.go Simplify the output in AfterPrint() 2016-09-08 09:42:17 +10:00
stop_test.go convert rest of kubectl to generated clients 2016-09-12 08:22:34 -04:00
stop.go convert rest of kubectl to generated clients 2016-09-12 08:22:34 -04:00
version.go convert more command to use a generated clientset 2016-09-12 07:38:34 -04:00