mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 03:41:45 +00:00
Update the example for kubectl port-forward
Clarify that `REMOTE_PORT` is interpreted as identifying a _Service_ port when provided `TYPE` is `service`. Also, highlight support for specifying a named port as `REMOTE_PORT`.
This commit is contained in:
parent
c9c24b46c3
commit
68e8fd5f33
@ -41,6 +41,20 @@ kubectl port-forward deployment/mydeployment 5000 6000
|
||||
|
||||
---
|
||||
|
||||
{% method %}
|
||||
## Pod in a Service
|
||||
|
||||
Listen on port 8443 locally, forwarding to the targetPort of the service's port named "https" in a pod selected by the service
|
||||
{% sample lang="yaml" %}
|
||||
|
||||
```bash
|
||||
kubectl port-forward service/myservice 8443:https
|
||||
```
|
||||
|
||||
{% endmethod %}
|
||||
|
||||
---
|
||||
|
||||
{% method %}
|
||||
## Different Local and Remote Ports
|
||||
|
||||
|
@ -76,8 +76,8 @@ var (
|
||||
# Listen on ports 5000 and 6000 locally, forwarding data to/from ports 5000 and 6000 in a pod selected by the deployment
|
||||
kubectl port-forward deployment/mydeployment 5000 6000
|
||||
|
||||
# Listen on ports 5000 and 6000 locally, forwarding data to/from ports 5000 and 6000 in a pod selected by the service
|
||||
kubectl port-forward service/myservice 5000 6000
|
||||
# Listen on port 8443 locally, forwarding to the targetPort of the service's port named "https" in a pod selected by the service
|
||||
kubectl port-forward service/myservice 8443:https
|
||||
|
||||
# Listen on port 8888 locally, forwarding to 5000 in the pod
|
||||
kubectl port-forward pod/mypod 8888:5000
|
||||
|
Loading…
Reference in New Issue
Block a user