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