Skip to content

Commit d236e50

Browse files
authored
Merge pull request kubernetes#95383 from montmanu/kubectl/port-forward
Update the example for kubectl port-forward
2 parents c9c24b4 + 68e8fd5 commit d236e50

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

staging/src/k8s.io/kubectl/docs/book/pages/container_debugging/port_forward_to_pods.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,20 @@ kubectl port-forward deployment/mydeployment 5000 6000
4141

4242
---
4343

44+
{% method %}
45+
## Pod in a Service
46+
47+
Listen on port 8443 locally, forwarding to the targetPort of the service's port named "https" in a pod selected by the service
48+
{% sample lang="yaml" %}
49+
50+
```bash
51+
kubectl port-forward service/myservice 8443:https
52+
```
53+
54+
{% endmethod %}
55+
56+
---
57+
4458
{% method %}
4559
## Different Local and Remote Ports
4660

staging/src/k8s.io/kubectl/pkg/cmd/portforward/portforward.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ var (
7676
# Listen on ports 5000 and 6000 locally, forwarding data to/from ports 5000 and 6000 in a pod selected by the deployment
7777
kubectl port-forward deployment/mydeployment 5000 6000
7878
79-
# Listen on ports 5000 and 6000 locally, forwarding data to/from ports 5000 and 6000 in a pod selected by the service
80-
kubectl port-forward service/myservice 5000 6000
79+
# Listen on port 8443 locally, forwarding to the targetPort of the service's port named "https" in a pod selected by the service
80+
kubectl port-forward service/myservice 8443:https
8181
8282
# Listen on port 8888 locally, forwarding to 5000 in the pod
8383
kubectl port-forward pod/mypod 8888:5000

0 commit comments

Comments
 (0)