-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UPSTREAM: 33319: add nodeport option when creating NodePort service #11059
UPSTREAM: 33319: add nodeport option when creating NodePort service #11059
Conversation
[test] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks good, just minor comments.
func GetFlagInt32(cmd *cobra.Command, flag string) int32 { | ||
i, err := cmd.Flags().GetInt32(flag) | ||
if err != nil { | ||
glog.Fatalf("err accessing flag %s for command %s: %v", flag, cmd.Name(), err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/err/error/
@@ -133,6 +133,7 @@ func NewCmdCreateServiceNodePort(f *cmdutil.Factory, cmdOut io.Writer) *cobra.Co | |||
cmdutil.AddValidateFlags(cmd) | |||
cmdutil.AddPrinterFlags(cmd) | |||
cmdutil.AddGeneratorFlags(cmd, cmdutil.ServiceNodePortGeneratorV1Name) | |||
cmd.Flags().Int32("nodeport", 0, "Port used to expose the service on each node in a cluster.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like it should be named "node-port" based on the capitalization used in the API (NodePort)
return ErrNotInRange | ||
// include valid port range in error | ||
validPorts := r.portRange.String() | ||
msg := fmt.Sprintf("Valid ports range from %s", validPorts) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit ... I think "Valid ports range is %s" would be better
1588b81
to
fc8e559
Compare
@csrwng Review comments addressed, thanks for the feedback! |
55fb03e
to
2e5ece4
Compare
f80e7cf
to
f7c9a97
Compare
conformance test flaked on #11079 re[test] |
f7c9a97
to
5ed2b4c
Compare
@fabianofranz or @csrwng upstream PR merged, PTAL |
@juanvallejo is this up-to-date with upstream (4 versus 2 commits)? |
@fabianofranz it's up to date, I had forgotten to squash upstream :/ |
UPSTREAM: kubernetes/kubernetes#33319 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** ``` $ oc 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 $ oc create service nodeport mynodeport --tcp=8080:7777 --node-port=30000 service "mynodeport" created $ oc 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. ```
5ed2b4c
to
26655c5
Compare
Evaluated for origin test up to 26655c5 |
[merge] |
continuous-integration/openshift-jenkins/merge SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/9719/) (Image: devenv-rhel7_5156) |
Evaluated for origin merge up to 26655c5 |
continuous-integration/openshift-jenkins/test SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/9719/) |
UPSTREAM: kubernetes/kubernetes#33319
Related bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1378012
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
--nodeport
value is not specified, it defaults to zero, inwhich 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
toretrieve
Int32
cobra flags.Example
cc @openshift/cli-review @csrwng