Skip to content

Commit

Permalink
Correcting example to avoid ambiguity
Browse files Browse the repository at this point in the history
Both local and pod port number are same i.e. 6379 which causes confusion to first time reader. This can be easily avoided by using two different port number.
  • Loading branch information
rajeshdeshpande02 authored May 16, 2019
1 parent 21b7d12 commit 7a41602
Showing 1 changed file with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,38 +90,38 @@ for database debugging.

## Forward a local port to a port on the pod

1. `kubectl port-forward` allows using resource name, such as a service name, to select a matching pod to port forward to since Kubernetes v1.10.
1. `kubectl port-forward` allows using resource name, such as a pod name, to select a matching pod to port forward to since Kubernetes v1.10.

kubectl port-forward redis-master-765d459796-258hz 6379:6379
kubectl port-forward redis-master-765d459796-258hz 7000:6379

which is the same as

kubectl port-forward pods/redis-master-765d459796-258hz 6379:6379
kubectl port-forward pods/redis-master-765d459796-258hz 7000:6379

or

kubectl port-forward deployment/redis-master 6379:6379
kubectl port-forward deployment/redis-master 7000:6379

or

kubectl port-forward rs/redis-master 6379:6379
kubectl port-forward rs/redis-master 7000:6379

or

kubectl port-forward svc/redis-master 6379:6379
kubectl port-forward svc/redis-master 7000:6379

Any of the above commands works. The output is similar to this:

I0710 14:43:38.274550 3655 portforward.go:225] Forwarding from 127.0.0.1:6379 -> 6379
I0710 14:43:38.274797 3655 portforward.go:225] Forwarding from [::1]:6379 -> 6379
I0710 14:43:38.274550 3655 portforward.go:225] Forwarding from 127.0.0.1:7000 -> 6379
I0710 14:43:38.274797 3655 portforward.go:225] Forwarding from [::1]:7000 -> 6379

2. Start the Redis command line interface:

redis-cli

3. At the Redis command line prompt, enter the `ping` command:

127.0.0.1:6379>ping
127.0.0.1:7000>ping

A successful ping request returns PONG.

Expand All @@ -132,7 +132,7 @@ for database debugging.

## Discussion

Connections made to local port 6379 are forwarded to port 6379 of the pod that
Connections made to local port 7000 are forwarded to port 6379 of the pod that
is running the Redis server. With this connection in place you can use your
local workstation to debug the database that is running in the pod.

Expand Down

0 comments on commit 7a41602

Please sign in to comment.