mirror of https://github.com/k3s-io/k3s
Fixing the error message
parent
1ee86d05cb
commit
c849730116
|
@ -68,7 +68,7 @@ re\-use the labels from the resource it exposes.
|
|||
|
||||
.PP
|
||||
\fB\-\-port\fP=\-1
|
||||
The port that the service should serve on. Required.
|
||||
The port that the service should serve on. Copied from the resource being exposed, if unspecified
|
||||
|
||||
.PP
|
||||
\fB\-\-protocol\fP="TCP"
|
||||
|
|
|
@ -64,7 +64,7 @@ $ kubectl expose rc streamer --port=4100 --protocol=udp --name=video-stream
|
|||
-o, --output="": Output format. One of: json|yaml|template|templatefile|wide.
|
||||
--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 used to override the generated object. Requires that the object supply a valid apiVersion field.
|
||||
--port=-1: The port that the service should serve on. Required.
|
||||
--port=-1: The port that the service should serve on. Copied from the resource being exposed, if unspecified
|
||||
--protocol="TCP": The network protocol for the service to be created. Default is 'tcp'.
|
||||
--public-ip="": Name of a public IP address to set for the service. The service will be assigned this IP in addition to its generated service IP.
|
||||
--selector="": A label selector to use for this service. If empty (the default) infer the selector from the replication controller.
|
||||
|
@ -105,7 +105,7 @@ $ kubectl expose rc streamer --port=4100 --protocol=udp --name=video-stream
|
|||
### SEE ALSO
|
||||
* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager
|
||||
|
||||
###### Auto generated by spf13/cobra at 2015-07-16 21:22:36.08263026 +0000 UTC
|
||||
###### Auto generated by spf13/cobra at 2015-07-17 01:17:57.020108348 +0000 UTC
|
||||
|
||||
|
||||
<!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
|
||||
|
|
|
@ -58,7 +58,7 @@ func NewCmdExposeService(f *cmdutil.Factory, out io.Writer) *cobra.Command {
|
|||
cmdutil.AddPrinterFlags(cmd)
|
||||
cmd.Flags().String("generator", "service/v2", "The name of the API generator to use. There are 2 generators: 'service/v1' and 'service/v2'. The only difference between them is that service port in v1 is named 'default', while it is left unnamed in v2. Default is 'service/v2'.")
|
||||
cmd.Flags().String("protocol", "TCP", "The network protocol for the service to be created. Default is 'tcp'.")
|
||||
cmd.Flags().Int("port", -1, "The port that the service should serve on. Required.")
|
||||
cmd.Flags().Int("port", -1, "The port that the service should serve on. Copied from the resource being exposed, if unspecified")
|
||||
cmd.MarkFlagRequired("port")
|
||||
cmd.Flags().String("type", "", "Type for this service: ClusterIP, NodePort, or LoadBalancer. Default is 'ClusterIP' unless --create-external-load-balancer is specified.")
|
||||
cmd.Flags().Bool("create-external-load-balancer", false, "If true, create an external load balancer for this service (trumped by --type). Implementation is cloud provider dependent. Default is 'false'.")
|
||||
|
@ -126,7 +126,7 @@ func RunExpose(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []str
|
|||
if len(s) == 0 {
|
||||
s, err := f.PodSelectorForObject(inputObject)
|
||||
if err != nil {
|
||||
return err
|
||||
return cmdutil.UsageError(cmd, fmt.Sprintf("couldn't find selectors via --selector flag or introspection: %s", err))
|
||||
}
|
||||
params["selector"] = s
|
||||
}
|
||||
|
@ -140,15 +140,15 @@ func RunExpose(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []str
|
|||
if cmdutil.GetFlagInt(cmd, "port") < 0 && !noPorts {
|
||||
ports, err := f.PortsForObject(inputObject)
|
||||
if err != nil {
|
||||
return err
|
||||
return cmdutil.UsageError(cmd, fmt.Sprintf("couldn't find port via --port flag or introspection: %s", err))
|
||||
}
|
||||
switch len(ports) {
|
||||
case 0:
|
||||
return cmdutil.UsageError(cmd, "couldn't find a suitable port via --port flag or introspection")
|
||||
return cmdutil.UsageError(cmd, "couldn't find port via --port flag or introspection")
|
||||
case 1:
|
||||
params["port"] = ports[0]
|
||||
default:
|
||||
return cmdutil.UsageError(cmd, "more than one port to choose from, please explicitly specify a port using the --port flag.")
|
||||
return cmdutil.UsageError(cmd, fmt.Sprintf("multiple ports to choose from: %v, please explicitly specify a port using the --port flag.", ports))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -163,11 +163,11 @@ func NewFactory(optionalClientConfig clientcmd.ClientConfig) *Factory {
|
|||
}
|
||||
return kubectl.MakeLabels(t.Spec.Selector), nil
|
||||
default:
|
||||
kind, err := meta.NewAccessor().Kind(object)
|
||||
_, kind, err := api.Scheme.ObjectVersionAndKind(object)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return "", fmt.Errorf("it is not possible to get a pod selector from %s", kind)
|
||||
return "", fmt.Errorf("cannot extract pod selector from %s", kind)
|
||||
}
|
||||
},
|
||||
PortsForObject: func(object runtime.Object) ([]string, error) {
|
||||
|
@ -178,11 +178,13 @@ func NewFactory(optionalClientConfig clientcmd.ClientConfig) *Factory {
|
|||
case *api.Pod:
|
||||
return getPorts(t.Spec), nil
|
||||
default:
|
||||
kind, err := meta.NewAccessor().Kind(object)
|
||||
// TODO: support extracting ports from service:
|
||||
// https://github.com/GoogleCloudPlatform/kubernetes/issues/11392
|
||||
_, kind, err := api.Scheme.ObjectVersionAndKind(object)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return nil, fmt.Errorf("it is not possible to get ports from %s", kind)
|
||||
return nil, fmt.Errorf("cannot extract ports from %s", kind)
|
||||
}
|
||||
},
|
||||
LabelsForObject: func(object runtime.Object) (map[string]string, error) {
|
||||
|
|
Loading…
Reference in New Issue