mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-04 01:40:07 +00:00
Merge pull request #6034 from thockin/target_port_flag
Alias --container-port to --target-port in kubectl
This commit is contained in:
commit
803086c2c6
@ -11,17 +11,17 @@ Looks up a replication controller or service by name and uses the selector for t
|
|||||||
selector for a new Service on the specified port.
|
selector for a new Service on the specified port.
|
||||||
|
|
||||||
```
|
```
|
||||||
kubectl expose RESOURCE NAME --port=port [--protocol=TCP|UDP] [--container-port=number-or-name] [--service-name=name] [--public-ip=ip] [--create-external-load-balancer=bool]
|
kubectl expose RESOURCE NAME --port=port [--protocol=TCP|UDP] [--target-port=number-or-name] [--service-name=name] [--public-ip=ip] [--create-external-load-balancer=bool]
|
||||||
```
|
```
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
|
||||||
```
|
```
|
||||||
// Creates a service for a replicated nginx, which serves on port 80 and connects to the containers on port 8000.
|
// Creates a service for a replicated nginx, which serves on port 80 and connects to the containers on port 8000.
|
||||||
$ kubectl expose nginx --port=80 --container-port=8000
|
$ kubectl expose nginx --port=80 --target-port=8000
|
||||||
|
|
||||||
// Creates a second service based on the above service, exposing the container port 8443 as port 443 with the name "nginx-https"
|
// Creates a second service based on the above service, exposing the container port 8443 as port 443 with the name "nginx-https"
|
||||||
$ kubectl expose service nginx --port=443 --container-port=8443 --service-name=nginx-https
|
$ kubectl expose service nginx --port=443 --target-port=8443 --service-name=nginx-https
|
||||||
|
|
||||||
// Create a service for a replicated streaming application on port 4100 balancing UDP traffic and named 'video-stream'.
|
// Create a service for a replicated streaming application on port 4100 balancing UDP traffic and named 'video-stream'.
|
||||||
$ kubectl expose streamer --port=4100 --protocol=udp --service-name=video-stream
|
$ kubectl expose streamer --port=4100 --protocol=udp --service-name=video-stream
|
||||||
@ -30,7 +30,7 @@ $ kubectl expose streamer --port=4100 --protocol=udp --service-name=video-stream
|
|||||||
### Options
|
### Options
|
||||||
|
|
||||||
```
|
```
|
||||||
--container-port="": Name or number for the port on the container that the service should direct traffic to. Optional.
|
--container-port="": Synonym for --target-port
|
||||||
--create-external-load-balancer=false: If true, create an external load balancer for this service. Implementation is cloud provider dependent. Default is 'false'.
|
--create-external-load-balancer=false: If true, create an external load balancer for this service. Implementation is cloud provider dependent. Default is 'false'.
|
||||||
--dry-run=false: If true, only print the object that would be sent, without creating it.
|
--dry-run=false: If true, only print the object that would be sent, without creating it.
|
||||||
--generator="service/v1": The name of the API generator to use. Default is 'service/v1'.
|
--generator="service/v1": The name of the API generator to use. Default is 'service/v1'.
|
||||||
@ -45,6 +45,7 @@ $ kubectl expose streamer --port=4100 --protocol=udp --service-name=video-stream
|
|||||||
--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.
|
--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.
|
--selector="": A label selector to use for this service. If empty (the default) infer the selector from the replication controller.
|
||||||
--service-name="": The name for the newly created service.
|
--service-name="": The name for the newly created service.
|
||||||
|
--target-port="": Name or number for the port on the container that the service should direct traffic to. Optional.
|
||||||
-t, --template="": Template string or path to template file to use when -o=template or -o=templatefile. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview]
|
-t, --template="": Template string or path to template file to use when -o=template or -o=templatefile. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ selector for a new Service on the specified port.
|
|||||||
.SH OPTIONS
|
.SH OPTIONS
|
||||||
.PP
|
.PP
|
||||||
\fB\-\-container\-port\fP=""
|
\fB\-\-container\-port\fP=""
|
||||||
Name or number for the port on the container that the service should direct traffic to. Optional.
|
Synonym for \-\-target\-port
|
||||||
|
|
||||||
.PP
|
.PP
|
||||||
\fB\-\-create\-external\-load\-balancer\fP=false
|
\fB\-\-create\-external\-load\-balancer\fP=false
|
||||||
@ -81,6 +81,10 @@ selector for a new Service on the specified port.
|
|||||||
\fB\-\-service\-name\fP=""
|
\fB\-\-service\-name\fP=""
|
||||||
The name for the newly created service.
|
The name for the newly created service.
|
||||||
|
|
||||||
|
.PP
|
||||||
|
\fB\-\-target\-port\fP=""
|
||||||
|
Name or number for the port on the container that the service should direct traffic to. Optional.
|
||||||
|
|
||||||
.PP
|
.PP
|
||||||
\fB\-t\fP, \fB\-\-template\fP=""
|
\fB\-t\fP, \fB\-\-template\fP=""
|
||||||
Template string or path to template file to use when \-o=template or \-o=templatefile. The template format is golang templates [
|
Template string or path to template file to use when \-o=template or \-o=templatefile. The template format is golang templates [
|
||||||
@ -195,10 +199,10 @@ selector for a new Service on the specified port.
|
|||||||
|
|
||||||
.nf
|
.nf
|
||||||
// Creates a service for a replicated nginx, which serves on port 80 and connects to the containers on port 8000.
|
// Creates a service for a replicated nginx, which serves on port 80 and connects to the containers on port 8000.
|
||||||
$ kubectl expose nginx \-\-port=80 \-\-container\-port=8000
|
$ kubectl expose nginx \-\-port=80 \-\-target\-port=8000
|
||||||
|
|
||||||
// Creates a second service based on the above service, exposing the container port 8443 as port 443 with the name "nginx\-https"
|
// Creates a second service based on the above service, exposing the container port 8443 as port 443 with the name "nginx\-https"
|
||||||
$ kubectl expose service nginx \-\-port=443 \-\-container\-port=8443 \-\-service\-name=nginx\-https
|
$ kubectl expose service nginx \-\-port=443 \-\-target\-port=8443 \-\-service\-name=nginx\-https
|
||||||
|
|
||||||
// Create a service for a replicated streaming application on port 4100 balancing UDP traffic and named 'video\-stream'.
|
// Create a service for a replicated streaming application on port 4100 balancing UDP traffic and named 'video\-stream'.
|
||||||
$ kubectl expose streamer \-\-port=4100 \-\-protocol=udp \-\-service\-name=video\-stream
|
$ kubectl expose streamer \-\-port=4100 \-\-protocol=udp \-\-service\-name=video\-stream
|
||||||
|
@ -33,10 +33,10 @@ Looks up a replication controller or service by name and uses the selector for t
|
|||||||
selector for a new Service on the specified port.`
|
selector for a new Service on the specified port.`
|
||||||
|
|
||||||
expose_example = `// Creates a service for a replicated nginx, which serves on port 80 and connects to the containers on port 8000.
|
expose_example = `// Creates a service for a replicated nginx, which serves on port 80 and connects to the containers on port 8000.
|
||||||
$ kubectl expose nginx --port=80 --container-port=8000
|
$ kubectl expose nginx --port=80 --target-port=8000
|
||||||
|
|
||||||
// Creates a second service based on the above service, exposing the container port 8443 as port 443 with the name "nginx-https"
|
// Creates a second service based on the above service, exposing the container port 8443 as port 443 with the name "nginx-https"
|
||||||
$ kubectl expose service nginx --port=443 --container-port=8443 --service-name=nginx-https
|
$ kubectl expose service nginx --port=443 --target-port=8443 --service-name=nginx-https
|
||||||
|
|
||||||
// Create a service for a replicated streaming application on port 4100 balancing UDP traffic and named 'video-stream'.
|
// Create a service for a replicated streaming application on port 4100 balancing UDP traffic and named 'video-stream'.
|
||||||
$ kubectl expose streamer --port=4100 --protocol=udp --service-name=video-stream`
|
$ kubectl expose streamer --port=4100 --protocol=udp --service-name=video-stream`
|
||||||
@ -44,7 +44,7 @@ $ kubectl expose streamer --port=4100 --protocol=udp --service-name=video-stream
|
|||||||
|
|
||||||
func (f *Factory) NewCmdExposeService(out io.Writer) *cobra.Command {
|
func (f *Factory) NewCmdExposeService(out io.Writer) *cobra.Command {
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "expose RESOURCE NAME --port=port [--protocol=TCP|UDP] [--container-port=number-or-name] [--service-name=name] [--public-ip=ip] [--create-external-load-balancer=bool]",
|
Use: "expose RESOURCE NAME --port=port [--protocol=TCP|UDP] [--target-port=number-or-name] [--service-name=name] [--public-ip=ip] [--create-external-load-balancer=bool]",
|
||||||
Short: "Take a replicated application and expose it as Kubernetes Service",
|
Short: "Take a replicated application and expose it as Kubernetes Service",
|
||||||
Long: expose_long,
|
Long: expose_long,
|
||||||
Example: expose_example,
|
Example: expose_example,
|
||||||
@ -61,7 +61,8 @@ func (f *Factory) NewCmdExposeService(out io.Writer) *cobra.Command {
|
|||||||
cmd.Flags().String("selector", "", "A label selector to use for this service. If empty (the default) infer the selector from the replication controller.")
|
cmd.Flags().String("selector", "", "A label selector to use for this service. If empty (the default) infer the selector from the replication controller.")
|
||||||
cmd.Flags().StringP("labels", "l", "", "Labels to apply to the service created by this call.")
|
cmd.Flags().StringP("labels", "l", "", "Labels to apply to the service created by this call.")
|
||||||
cmd.Flags().Bool("dry-run", false, "If true, only print the object that would be sent, without creating it.")
|
cmd.Flags().Bool("dry-run", false, "If true, only print the object that would be sent, without creating it.")
|
||||||
cmd.Flags().String("container-port", "", "Name or number for the port on the container that the service should direct traffic to. Optional.")
|
cmd.Flags().String("container-port", "", "Synonym for --target-port")
|
||||||
|
cmd.Flags().String("target-port", "", "Name or number for the port on the container that the service should direct traffic to. Optional.")
|
||||||
cmd.Flags().String("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.")
|
cmd.Flags().String("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.")
|
||||||
cmd.Flags().String("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.")
|
cmd.Flags().String("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.")
|
||||||
cmd.Flags().String("service-name", "", "The name for the newly created service.")
|
cmd.Flags().String("service-name", "", "The name for the newly created service.")
|
||||||
|
Loading…
Reference in New Issue
Block a user