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:
Christopher Montoro 2020-10-07 21:37:03 -04:00
parent c9c24b46c3
commit 68e8fd5f33
No known key found for this signature in database
GPG Key ID: DFDA0C7BFD4582A9
2 changed files with 16 additions and 2 deletions

View File

@ -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 %} {% method %}
## Different Local and Remote Ports ## Different Local and Remote Ports

View File

@ -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 # 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 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 # 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 5000 6000 kubectl port-forward service/myservice 8443:https
# Listen on port 8888 locally, forwarding to 5000 in the pod # Listen on port 8888 locally, forwarding to 5000 in the pod
kubectl port-forward pod/mypod 8888:5000 kubectl port-forward pod/mypod 8888:5000