1KUBERNETES(1)(kubernetes)                            KUBERNETES(1)(kubernetes)
2
3
4
5Eric Paris Jan 2015
6
7

NAME

9       kubectl port-forward - Forward one or more local ports to a pod
10
11
12

SYNOPSIS

14       kubectl port-forward [OPTIONS]
15
16
17

DESCRIPTION

19       Forward one or more local ports to a pod.
20
21
22       Use resource type/name such as deployment/mydeployment to select a pod.
23       Resource type defaults to 'pod' if omitted.
24
25
26       If there are multiple pods matching the criteria, a  pod  will  be  se‐
27       lected automatically. The forwarding session ends when the selected pod
28       terminates, and a rerun of the command is needed to resume forwarding.
29
30
31

OPTIONS

33       --address=[localhost]      Addresses to listen  on  (comma  separated).
34       Only  accepts  IP  addresses or localhost as a value. When localhost is
35       supplied, kubectl will try to bind on both 127.0.0.1 and ::1  and  will
36       fail if neither of these addresses are available to bind.
37
38
39       --pod-running-timeout=1m0s      The length of time (like 5s, 2m, or 3h,
40       higher than zero) to wait until at least one pod is running
41
42
43

OPTIONS INHERITED FROM PARENT COMMANDS

45       --as=""      Username to impersonate for the operation. User could be a
46       regular user or a service account in a namespace.
47
48
49       --as-group=[]       Group  to  impersonate for the operation, this flag
50       can be repeated to specify multiple groups.
51
52
53       --as-uid=""      UID to impersonate for the operation.
54
55
56       --azure-container-registry-config=""      Path to the  file  containing
57       Azure container registry configuration information.
58
59
60       --cache-dir="/builddir/.kube/cache"      Default cache directory
61
62
63       --certificate-authority=""      Path to a cert file for the certificate
64       authority
65
66
67       --client-certificate=""      Path to a client certificate file for TLS
68
69
70       --client-key=""      Path to a client key file for TLS
71
72
73       --cluster=""      The name of the kubeconfig cluster to use
74
75
76       --context=""      The name of the kubeconfig context to use
77
78
79       --disable-compression=false      If true, opt-out of response  compres‐
80       sion for all requests to the server
81
82
83       --insecure-skip-tls-verify=false      If true, the server's certificate
84       will not be checked for validity. This will make your HTTPS connections
85       insecure
86
87
88       --kubeconfig=""       Path  to  the  kubeconfig file to use for CLI re‐
89       quests.
90
91
92       --match-server-version=false       Require  server  version  to   match
93       client version
94
95
96       -n,  --namespace=""       If  present, the namespace scope for this CLI
97       request
98
99
100       --password=""      Password for basic authentication to the API server
101
102
103       --profile="none"        Name   of   profile   to   capture.   One    of
104       (none|cpu|heap|goroutine|threadcreate|block|mutex)
105
106
107       --profile-output="profile.pprof"       Name  of  the  file to write the
108       profile to
109
110
111       --request-timeout="0"      The length of time to wait before giving  up
112       on  a  single  server  request. Non-zero values should contain a corre‐
113       sponding time unit (e.g. 1s, 2m, 3h). A value of zero means don't time‐
114       out requests.
115
116
117       -s, --server=""      The address and port of the Kubernetes API server
118
119
120       --tls-server-name=""       Server  name  to  use for server certificate
121       validation. If it is not provided, the hostname  used  to  contact  the
122       server is used
123
124
125       --token=""      Bearer token for authentication to the API server
126
127
128       --user=""      The name of the kubeconfig user to use
129
130
131       --username=""      Username for basic authentication to the API server
132
133
134       --version=false      Print version information and quit
135
136
137       --warnings-as-errors=false      Treat warnings received from the server
138       as errors and exit with a non-zero exit code
139
140
141

EXAMPLE

143                # Listen on ports 5000 and 6000 locally, forwarding data to/from ports 5000 and 6000 in the pod
144                kubectl port-forward pod/mypod 5000 6000
145
146                # Listen on ports 5000 and 6000 locally, forwarding data to/from ports 5000 and 6000 in a pod selected by the deployment
147                kubectl port-forward deployment/mydeployment 5000 6000
148
149                # Listen on port 8443 locally, forwarding to the targetPort of the service's port named "https" in a pod selected by the service
150                kubectl port-forward service/myservice 8443:https
151
152                # Listen on port 8888 locally, forwarding to 5000 in the pod
153                kubectl port-forward pod/mypod 8888:5000
154
155                # Listen on port 8888 on all addresses, forwarding to 5000 in the pod
156                kubectl port-forward --address 0.0.0.0 pod/mypod 8888:5000
157
158                # Listen on port 8888 on localhost and selected IP, forwarding to 5000 in the pod
159                kubectl port-forward --address localhost,10.19.21.23 pod/mypod 8888:5000
160
161                # Listen on a random port locally, forwarding to 5000 in the pod
162                kubectl port-forward pod/mypod :5000
163
164
165
166

SEE ALSO

168       kubectl(1),
169
170
171

HISTORY

173       January 2015, Originally compiled by Eric Paris (eparis at  redhat  dot
174       com)  based  on the kubernetes source material, but hopefully they have
175       been automatically generated since!
176
177
178
179Manuals                              User            KUBERNETES(1)(kubernetes)
Impressum