Merge pull request #32811 from fraenkel/headless_service

Automatic merge from submit-queue (batch tested with PRs 38260, 32811, 28458, 33570, 37096)

Allow no ports when exposing headless service

fixes #32795
This commit is contained in:
Kubernetes Submit Queue
2016-12-08 02:11:20 -08:00
committed by GitHub
4 changed files with 91 additions and 33 deletions

View File

@@ -177,6 +177,8 @@ func RunExpose(f cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []stri
params["selector"] = s
}
isHeadlessService := params["cluster-ip"] == "None"
// For objects that need a port, derive it from the exposed object in case a user
// didn't explicitly specify one via --port
if port, found := params["port"]; found && kubectl.IsZero(port) {
@@ -186,7 +188,9 @@ func RunExpose(f cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []stri
}
switch len(ports) {
case 0:
return cmdutil.UsageError(cmd, "couldn't find port via --port flag or introspection")
if !isHeadlessService {
return cmdutil.UsageError(cmd, "couldn't find port via --port flag or introspection")
}
case 1:
params["port"] = ports[0]
default: