1KUBERNETES(1)                      Jan 2015                      KUBERNETES(1)
2
3
4

NAME

6       kubectl  expose - Take a replication controller, service, deployment or
7       pod and expose it as a new Kubernetes Service
8
9
10

SYNOPSIS

12       kubectl expose [OPTIONS]
13
14
15

DESCRIPTION

17       Expose a resource as a new Kubernetes service.
18
19
20       Looks up a deployment, service, replica set, replication controller  or
21       pod by name and uses the selector for that resource as the selector for
22       a new service on the specified port. A deployment or replica  set  will
23       be exposed as a service only if its selector is convertible to a selec‐
24       tor that service supports, i.e. when the  selector  contains  only  the
25       matchLabels component. Note that if no port is specified via --port and
26       the exposed resource has multiple ports, all will be re-used by the new
27       service.  Also  if no labels are specified, the new service will re-use
28       the labels from the resource it exposes.
29
30
31       Possible resources include (case insensitive):
32
33
34       pod  (po),  service  (svc),  replicationcontroller   (rc),   deployment
35       (deploy), replicaset (rs)
36
37
38

OPTIONS

40       --allow-missing-template-keys=true
41           If  true, ignore any errors in templates when a field or map key is
42       missing in the template. Only applies to  golang  and  jsonpath  output
43       formats.
44
45
46       --cluster-ip=""
47           ClusterIP  to be assigned to the service. Leave empty to auto-allo‐
48       cate, or set to 'None' to create a headless service.
49
50
51       --container-port=""
52           Synonym for --target-port
53
54
55       --dry-run=false
56           If true, only print the object that would be sent, without  sending
57       it.
58
59
60       --external-ip=""
61           Additional  external  IP  address  (not  managed  by Kubernetes) to
62       accept for the service. If this IP is routed to a node, the service can
63       be accessed by this IP in addition to its generated service IP.
64
65
66       -f, --filename=[]
67           Filename,  directory,  or  URL to files identifying the resource to
68       expose a service
69
70
71       --generator="service/v2"
72           The name of the API generator to use. There are 2 generators: 'ser‐
73       vice/v1'  and  'service/v2'.  The  only difference between them is that
74       service port in v1 is named 'default', while it is left unnamed in  v2.
75       Default is 'service/v2'.
76
77
78       -l, --labels=""
79           Labels to apply to the service created by this call.
80
81
82       --load-balancer-ip=""
83           IP to assign to the LoadBalancer. If empty, an ephemeral IP will be
84       created and used (cloud-provider specific).
85
86
87       --name=""
88           The name for the newly created object.
89
90
91       -o, --output=""
92           Output format. One of: json|yaml|name|templatefile|template|go-tem‐
93       plate|go-template-file|jsonpath|jsonpath-file.
94
95
96       --overrides=""
97           An  inline  JSON  override  for  the  generated  object. If this is
98       non-empty, it is used to override the generated object.  Requires  that
99       the object supply a valid apiVersion field.
100
101
102       --port=""
103           The port that the service should serve on. Copied from the resource
104       being exposed, if unspecified
105
106
107       --protocol=""
108           The network protocol for the service  to  be  created.  Default  is
109       'TCP'.
110
111
112       --record=false
113           Record  current  kubectl command in the resource annotation. If set
114       to false, do not record the command. If set to true,  record  the  com‐
115       mand.  If  not  set,  default to updating the existing annotation value
116       only if one already exists.
117
118
119       -R, --recursive=false
120           Process the directory used in -f,  --filename  recursively.  Useful
121       when  you  want  to  manage related manifests organized within the same
122       directory.
123
124
125       --save-config=false
126           If true, the configuration of current object will be saved  in  its
127       annotation.  Otherwise,  the annotation will be unchanged. This flag is
128       useful when you want to perform kubectl apply on  this  object  in  the
129       future.
130
131
132       --selector=""
133           A  label  selector  to  use  for  this service. Only equality-based
134       selector requirements are supported. If empty (the default)  infer  the
135       selector from the replication controller or replica set.)
136
137
138       --session-affinity=""
139           If  non-empty,  set  the  session affinity for the service to this;
140       legal values: 'None', 'ClientIP'
141
142
143       --target-port=""
144           Name or number for the port  on  the  container  that  the  service
145       should direct traffic to. Optional.
146
147
148       --template=""
149           Template  string  or  path  to template file to use when -o=go-tem‐
150       plate, -o=go-template-file. The template format is golang  templates  [
151http://golang.org/pkg/text/template/#pkg-overview⟩].
152
153
154       --type=""
155           Type for this service: ClusterIP, NodePort, LoadBalancer, or Exter‐
156       nalName. Default is 'ClusterIP'.
157
158
159

OPTIONS INHERITED FROM PARENT COMMANDS

161       --allow-verification-with-non-compliant-keys=false
162           Allow  a  SignatureVerifier  to  use  keys  which  are  technically
163       non-compliant with RFC6962.
164
165
166       --alsologtostderr=false
167           log to standard error as well as files
168
169
170       --application-metrics-count-limit=100
171           Max number of application metrics to store (per container)
172
173
174       --as=""
175           Username to impersonate for the operation
176
177
178       --as-group=[]
179           Group  to  impersonate for the operation, this flag can be repeated
180       to specify multiple groups.
181
182
183       --azure-container-registry-config=""
184           Path to the file containing Azure container registry  configuration
185       information.
186
187
188       --boot-id-file="/proc/sys/kernel/random/boot_id"
189           Comma-separated  list  of files to check for boot-id. Use the first
190       one that exists.
191
192
193       --cache-dir="/builddir/.kube/http-cache"
194           Default HTTP cache directory
195
196
197       --certificate-authority=""
198           Path to a cert file for the certificate authority
199
200
201       --client-certificate=""
202           Path to a client certificate file for TLS
203
204
205       --client-key=""
206           Path to a client key file for TLS
207
208
209       --cloud-provider-gce-lb-src-cidrs=130.211.0.0/22,209.85.152.0/22,209.85.204.0/22,35.191.0.0/16
210           CIDRs opened in GCE firewall for LB traffic proxy  health checks
211
212
213       --cluster=""
214           The name of the kubeconfig cluster to use
215
216
217       --container-hints="/etc/cadvisor/container_hints.json"
218           location of the container hints file
219
220
221       --containerd="unix:///var/run/containerd.sock"
222           containerd endpoint
223
224
225       --context=""
226           The name of the kubeconfig context to use
227
228
229       --default-not-ready-toleration-seconds=300
230           Indicates    the    tolerationSeconds   of   the   toleration   for
231       notReady:NoExecute that is added by default to every pod that does  not
232       already have such a toleration.
233
234
235       --default-unreachable-toleration-seconds=300
236           Indicates  the  tolerationSeconds  of  the  toleration for unreach‐
237       able:NoExecute that is added by default to  every  pod  that  does  not
238       already have such a toleration.
239
240
241       --docker="unix:///var/run/docker.sock"
242           docker endpoint
243
244
245       --docker-env-metadata-whitelist=""
246           a  comma-separated  list of environment variable keys that needs to
247       be collected for docker containers
248
249
250       --docker-only=false
251           Only report docker containers in addition to root stats
252
253
254       --docker-root="/var/lib/docker"
255           DEPRECATED: docker root is read from docker info (this is  a  fall‐
256       back, default: /var/lib/docker)
257
258
259       --docker-tls=false
260           use TLS to connect to docker
261
262
263       --docker-tls-ca="ca.pem"
264           path to trusted CA
265
266
267       --docker-tls-cert="cert.pem"
268           path to client certificate
269
270
271       --docker-tls-key="key.pem"
272           path to private key
273
274
275       --enable-load-reader=false
276           Whether to enable cpu load reader
277
278
279       --event-storage-age-limit="default=0"
280           Max length of time for which to store events (per type). Value is a
281       comma separated list of key values, where  the  keys  are  event  types
282       (e.g.: creation, oom) or "default" and the value is a duration. Default
283       is applied to all non-specified event types
284
285
286       --event-storage-event-limit="default=0"
287           Max number of events to store (per type). Value is  a  comma  sepa‐
288       rated  list  of  key values, where the keys are event types (e.g.: cre‐
289       ation, oom) or "default" and  the  value  is  an  integer.  Default  is
290       applied to all non-specified event types
291
292
293       --global-housekeeping-interval=1m0s
294           Interval between global housekeepings
295
296
297       --google-json-key=""
298           The  Google  Cloud  Platform  Service  Account  JSON Key to use for
299       authentication.
300
301
302       --housekeeping-interval=10s
303           Interval between container housekeepings
304
305
306       --insecure-skip-tls-verify=false
307           If true, the server's certificate will not be checked for validity.
308       This will make your HTTPS connections insecure
309
310
311       --kubeconfig=""
312           Path to the kubeconfig file to use for CLI requests.
313
314
315       --log-backtrace-at=:0
316           when logging hits line file:N, emit a stack trace
317
318
319       --log-cadvisor-usage=false
320           Whether to log the usage of the cAdvisor container
321
322
323       --log-dir=""
324           If non-empty, write log files in this directory
325
326
327       --log-flush-frequency=5s
328           Maximum number of seconds between log flushes
329
330
331       --logtostderr=true
332           log to standard error instead of files
333
334
335       --machine-id-file="/etc/machine-id,/var/lib/dbus/machine-id"
336           Comma-separated  list  of  files  to  check for machine-id. Use the
337       first one that exists.
338
339
340       --match-server-version=false
341           Require server version to match client version
342
343
344       --mesos-agent="127.0.0.1:5051"
345           Mesos agent address
346
347
348       --mesos-agent-timeout=10s
349           Mesos agent timeout
350
351
352       -n, --namespace=""
353           If present, the namespace scope for this CLI request
354
355
356       --request-timeout="0"
357           The length of time to wait before giving  up  on  a  single  server
358       request. Non-zero values should contain a corresponding time unit (e.g.
359       1s, 2m, 3h). A value of zero means don't timeout requests.
360
361
362       -s, --server=""
363           The address and port of the Kubernetes API server
364
365
366       --stderrthreshold=2
367           logs at or above this threshold go to stderr
368
369
370       --storage-driver-buffer-duration=1m0s
371           Writes in the storage driver will be buffered  for  this  duration,
372       and committed to the non memory backends as a single transaction
373
374
375       --storage-driver-db="cadvisor"
376           database name
377
378
379       --storage-driver-host="localhost:8086"
380           database host:port
381
382
383       --storage-driver-password="root"
384           database password
385
386
387       --storage-driver-secure=false
388           use secure connection with database
389
390
391       --storage-driver-table="stats"
392           table name
393
394
395       --storage-driver-user="root"
396           database username
397
398
399       --token=""
400           Bearer token for authentication to the API server
401
402
403       --user=""
404           The name of the kubeconfig user to use
405
406
407       -v, --v=0
408           log level for V logs
409
410
411       --version=false
412           Print version information and quit
413
414
415       --vmodule=
416           comma-separated  list  of pattern=N settings for file-filtered log‐
417       ging
418
419
420

EXAMPLE

422                # Create a service for a replicated nginx, which serves on port 80 and connects to the containers on port 8000.
423                kubectl expose rc nginx --port=80 --target-port=8000
424
425                # Create a service for a replication controller identified by type and name specified in "nginx-controller.yaml", which serves on port 80 and connects to the containers on port 8000.
426                kubectl expose -f nginx-controller.yaml --port=80 --target-port=8000
427
428                # Create a service for a pod valid-pod, which serves on port 444 with the name "frontend"
429                kubectl expose pod valid-pod --port=444 --name=frontend
430
431                # Create a second service based on the above service, exposing the container port 8443 as port 443 with the name "nginx-https"
432                kubectl expose service nginx --port=443 --target-port=8443 --name=nginx-https
433
434                # Create a service for a replicated streaming application on port 4100 balancing UDP traffic and named 'video-stream'.
435                kubectl expose rc streamer --port=4100 --protocol=udp --name=video-stream
436
437                # Create a service for a replicated nginx using replica set, which serves on port 80 and connects to the containers on port 8000.
438                kubectl expose rs nginx --port=80 --target-port=8000
439
440                # Create a service for an nginx deployment, which serves on port 80 and connects to the containers on port 8000.
441                kubectl expose deployment nginx --port=80 --target-port=8000
442
443
444
445

SEE ALSO

447       kubectl(1),
448
449
450

HISTORY

452       January 2015, Originally compiled by Eric Paris (eparis at  redhat  dot
453       com)  based  on the kubernetes source material, but hopefully they have
454       been automatically generated since!
455
456
457
458Eric Paris                  kubernetes User Manuals              KUBERNETES(1)
Impressum