1KUBERNETES(1) Jan 2015 KUBERNETES(1)
2
3
4
6 kubectl port-forward - Forward one or more local ports to a pod
7
8
9
11 kubectl port-forward [OPTIONS]
12
13
14
16 Forward one or more local ports to a pod. This command requires the
17 node to have 'socat' installed.
18
19
20 Use resource type/name such as deployment/mydeployment to select a pod.
21 Resource type defaults to 'pod' if omitted.
22
23
24 If there are multiple pods matching the criteria, a pod will be
25 selected automatically. The forwarding session ends when the selected
26 pod terminates, and rerun of the command is needed to resume
27 forwarding.
28
29
30
32 --address=[localhost]
33 Addresses to listen on (comma separated). Only accepts IP addresses
34 or localhost as a value. When localhost is supplied, kubectl will try
35 to bind on both 127.0.0.1 and ::1 and will fail if neither of these
36 addresses are available to bind.
37
38
39 --pod-running-timeout=1m0s
40 The length of time (like 5s, 2m, or 3h, higher than zero) to wait
41 until at least one pod is running
42
43
44
46 --add-dir-header=false
47 If true, adds the file directory to the header
48
49
50 --alsologtostderr=false
51 log to standard error as well as files
52
53
54 --application-metrics-count-limit=100
55 Max number of application metrics to store (per container)
56
57
58 --as=""
59 Username to impersonate for the operation
60
61
62 --as-group=[]
63 Group to impersonate for the operation, this flag can be repeated
64 to specify multiple groups.
65
66
67 --azure-container-registry-config=""
68 Path to the file containing Azure container registry configuration
69 information.
70
71
72 --boot-id-file="/proc/sys/kernel/random/boot_id"
73 Comma-separated list of files to check for boot-id. Use the first
74 one that exists.
75
76
77 --cache-dir="/builddir/.kube/http-cache"
78 Default HTTP cache directory
79
80
81 --certificate-authority=""
82 Path to a cert file for the certificate authority
83
84
85 --client-certificate=""
86 Path to a client certificate file for TLS
87
88
89 --client-key=""
90 Path to a client key file for TLS
91
92
93 --cloud-provider-gce-l7lb-src-cidrs=130.211.0.0/22,35.191.0.0/16
94 CIDRs opened in GCE firewall for L7 LB traffic proxy health checks
95
96
97 --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
98 CIDRs opened in GCE firewall for L4 LB traffic proxy health checks
99
100
101 --cluster=""
102 The name of the kubeconfig cluster to use
103
104
105 --container-hints="/etc/cadvisor/container_hints.json"
106 location of the container hints file
107
108
109 --containerd="/run/containerd/containerd.sock"
110 containerd endpoint
111
112
113 --containerd-namespace="k8s.io"
114 containerd namespace
115
116
117 --context=""
118 The name of the kubeconfig context to use
119
120
121 --default-not-ready-toleration-seconds=300
122 Indicates the tolerationSeconds of the toleration for
123 notReady:NoExecute that is added by default to every pod that does not
124 already have such a toleration.
125
126
127 --default-unreachable-toleration-seconds=300
128 Indicates the tolerationSeconds of the toleration for
129 unreachable:NoExecute that is added by default to every pod that does
130 not already have such a toleration.
131
132
133 --disable-root-cgroup-stats=false
134 Disable collecting root Cgroup stats
135
136
137 --docker="unix:///var/run/docker.sock"
138 docker endpoint
139
140
141 --docker-env-metadata-whitelist=""
142 a comma-separated list of environment variable keys that needs to
143 be collected for docker containers
144
145
146 --docker-only=false
147 Only report docker containers in addition to root stats
148
149
150 --docker-root="/var/lib/docker"
151 DEPRECATED: docker root is read from docker info (this is a
152 fallback, default: /var/lib/docker)
153
154
155 --docker-tls=false
156 use TLS to connect to docker
157
158
159 --docker-tls-ca="ca.pem"
160 path to trusted CA
161
162
163 --docker-tls-cert="cert.pem"
164 path to client certificate
165
166
167 --docker-tls-key="key.pem"
168 path to private key
169
170
171 --enable-load-reader=false
172 Whether to enable cpu load reader
173
174
175 --event-storage-age-limit="default=0"
176 Max length of time for which to store events (per type). Value is a
177 comma separated list of key values, where the keys are event types
178 (e.g.: creation, oom) or "default" and the value is a duration. Default
179 is applied to all non-specified event types
180
181
182 --event-storage-event-limit="default=0"
183 Max number of events to store (per type). Value is a comma
184 separated list of key values, where the keys are event types (e.g.:
185 creation, oom) or "default" and the value is an integer. Default is
186 applied to all non-specified event types
187
188
189 --global-housekeeping-interval=1m0s
190 Interval between global housekeepings
191
192
193 --housekeeping-interval=10s
194 Interval between container housekeepings
195
196
197 --insecure-skip-tls-verify=false
198 If true, the server's certificate will not be checked for validity.
199 This will make your HTTPS connections insecure
200
201
202 --kubeconfig=""
203 Path to the kubeconfig file to use for CLI requests.
204
205
206 --log-backtrace-at=:0
207 when logging hits line file:N, emit a stack trace
208
209
210 --log-cadvisor-usage=false
211 Whether to log the usage of the cAdvisor container
212
213
214 --log-dir=""
215 If non-empty, write log files in this directory
216
217
218 --log-file=""
219 If non-empty, use this log file
220
221
222 --log-file-max-size=1800
223 Defines the maximum size a log file can grow to. Unit is megabytes.
224 If the value is 0, the maximum file size is unlimited.
225
226
227 --log-flush-frequency=5s
228 Maximum number of seconds between log flushes
229
230
231 --logtostderr=true
232 log to standard error instead of files
233
234
235 --machine-id-file="/etc/machine-id,/var/lib/dbus/machine-id"
236 Comma-separated list of files to check for machine-id. Use the
237 first one that exists.
238
239
240 --match-server-version=false
241 Require server version to match client version
242
243
244 -n, --namespace=""
245 If present, the namespace scope for this CLI request
246
247
248 --password=""
249 Password for basic authentication to the API server
250
251
252 --profile="none"
253 Name of profile to capture. One of
254 (none|cpu|heap|goroutine|threadcreate|block|mutex)
255
256
257 --profile-output="profile.pprof"
258 Name of the file to write the profile to
259
260
261 --request-timeout="0"
262 The length of time to wait before giving up on a single server
263 request. Non-zero values should contain a corresponding time unit (e.g.
264 1s, 2m, 3h). A value of zero means don't timeout requests.
265
266
267 -s, --server=""
268 The address and port of the Kubernetes API server
269
270
271 --skip-headers=false
272 If true, avoid header prefixes in the log messages
273
274
275 --skip-log-headers=false
276 If true, avoid headers when opening log files
277
278
279 --stderrthreshold=2
280 logs at or above this threshold go to stderr
281
282
283 --storage-driver-buffer-duration=1m0s
284 Writes in the storage driver will be buffered for this duration,
285 and committed to the non memory backends as a single transaction
286
287
288 --storage-driver-db="cadvisor"
289 database name
290
291
292 --storage-driver-host="localhost:8086"
293 database host:port
294
295
296 --storage-driver-password="root"
297 database password
298
299
300 --storage-driver-secure=false
301 use secure connection with database
302
303
304 --storage-driver-table="stats"
305 table name
306
307
308 --storage-driver-user="root"
309 database username
310
311
312 --tls-server-name=""
313 Server name to use for server certificate validation. If it is not
314 provided, the hostname used to contact the server is used
315
316
317 --token=""
318 Bearer token for authentication to the API server
319
320
321 --update-machine-info-interval=5m0s
322 Interval between machine info updates.
323
324
325 --user=""
326 The name of the kubeconfig user to use
327
328
329 --username=""
330 Username for basic authentication to the API server
331
332
333 -v, --v=0
334 number for the log level verbosity
335
336
337 --version=false
338 Print version information and quit
339
340
341 --vmodule=
342 comma-separated list of pattern=N settings for file-filtered
343 logging
344
345
346
348 # Listen on ports 5000 and 6000 locally, forwarding data to/from ports 5000 and 6000 in the pod
349 kubectl port-forward pod/mypod 5000 6000
350
351 # Listen on ports 5000 and 6000 locally, forwarding data to/from ports 5000 and 6000 in a pod selected by the deployment
352 kubectl port-forward deployment/mydeployment 5000 6000
353
354 # Listen on ports 5000 and 6000 locally, forwarding data to/from ports 5000 and 6000 in a pod selected by the service
355 kubectl port-forward service/myservice 5000 6000
356
357 # Listen on port 8888 locally, forwarding to 5000 in the pod
358 kubectl port-forward pod/mypod 8888:5000
359
360 # Listen on port 8888 on all addresses, forwarding to 5000 in the pod
361 kubectl port-forward --address 0.0.0.0 pod/mypod 8888:5000
362
363 # Listen on port 8888 on localhost and selected IP, forwarding to 5000 in the pod
364 kubectl port-forward --address localhost,10.19.21.23 pod/mypod 8888:5000
365
366 # Listen on a random port locally, forwarding to 5000 in the pod
367 kubectl port-forward pod/mypod :5000
368
369
370
371
373 kubectl(1),
374
375
376
378 January 2015, Originally compiled by Eric Paris (eparis at redhat dot
379 com) based on the kubernetes source material, but hopefully they have
380 been automatically generated since!
381
382
383
384Eric Paris kubernetes User Manuals KUBERNETES(1)