Change:
uses manifests However, these files were removed in . The new example is using mongodb instead of redis, and so, the document needs to be updated overall. The page to update:
/language en
/kind bug /language en /priority backlog /triage accepted /help Thanks
This request has been marked as needing help from a contributor. Please ensure the request meets the requirements listed . If this request no longer meets these requirements, the label can be removed by commenting with the command. <detailsIn response to : /kind bug /language en /priority backlog /triage accepted </details
/assign

Discussion:
<!-- overview --> <del> This page shows how to use `kubectl port-forward` to connect to a Redis </del> <ins> This page shows how to use `kubectl port-forward` to connect to a MongoDB </ins> server running in a Kubernetes cluster. This type of connection can be useful for database debugging.

* {{< include "task-tutorial-prereqs.md" >}} {{< version-check >}} <del> * Install [redis-cli](http://redis.io/topics/rediscli). </del> <ins> * Install [MongoDB Shell](https://www.mongodb.com/try/download/shell). </ins> <!-- steps --> <del> ## Creating Redis deployment and service </del> <ins> ## Creating MongoDB deployment and service </ins> <del> 1. Create a Deployment that runs Redis: </del> <ins> 1. Create a Deployment that runs MongoDB: </ins> ```shell <del> kubectl apply -f https://k8s.io/examples/application/guestbook/redis-master-deployment.yaml </del> <ins> kubectl apply -f https://k8s.io/examples/application/guestbook/mongo-deployment.yaml </ins> ``` The output of a successful command verifies that the deployment was created: ``` <del> deployment.apps/redis-master created </del> <ins> deployment.apps/mongo created </ins> ``` View the pod status to check that it is ready:

The output displays the pod created: ``` <del> NAME                            READY     STATUS    RESTARTS   AGE redis-master-765d459796-258hz   1/1       Running   0          50s </del> <ins> NAME                     READY   STATUS    RESTARTS   AGE mongo-75f59d57f4-4nd6q   1/1     Running   0          2m4s </ins> ``` View the Deployment's status:

The output displays that the Deployment was created: ``` <del> NAME         READY   UP-TO-DATE   AVAILABLE   AGE redis-master 1/1     1            1           55s </del> <ins> NAME    READY   UP-TO-DATE   AVAILABLE   AGE mongo   1/1     1            1           2m21s </ins> ``` The Deployment automatically manages a ReplicaSet.

The output displays that the ReplicaSet was created: ``` <del> NAME                      DESIRED   CURRENT   READY     AGE redis-master-765d459796   1         1         1         1m </del> <ins> NAME               DESIRED   CURRENT   READY   AGE mongo-75f59d57f4   1         1         1       3m12s </ins> ``` <del> 2. Create a Service to expose Redis on the network: </del> <ins> 2. Create a Service to expose MongoDB on the network: </ins> ```shell <del> kubectl apply -f https://k8s.io/examples/application/guestbook/redis-master-service.yaml </del> <ins> kubectl apply -f https://k8s.io/examples/application/guestbook/mongo-service.yaml </ins> ``` The output of a successful command verifies that the Service was created: ``` <del> service/redis-master created </del> <ins> service/mongo created </ins> ``` Check the Service created: ```shell <del> kubectl get service redis-master </del> <ins> kubectl get service mongo </ins> ``` The output displays the service created: ``` <del> NAME           TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)    AGE redis-master   ClusterIP   10.0.0.213   <none>        6379/TCP   27s </del> <ins> NAME    TYPE        CLUSTER-IP     EXTERNAL-IP   PORT(S)     AGE mongo   ClusterIP   10.96.41.183   <none>        27017/TCP   11s </ins> ``` <del> 3. Verify that the Redis server is running in the Pod, and listening on port 6379: </del> <ins> 3. Verify that the MongoDB server is running in the Pod, and listening on port 27017: </ins> ```shell <del> # Change redis-master-765d459796-258hz to the name of the Pod kubectl get pod redis-master-765d459796-258hz --template='{{(index (index .spec.containers 0).ports 0).containerPort}}{{"n"}}' </del> <ins> # Change mongo-75f59d57f4-4nd6q to the name of the Pod kubectl get pod mongo-75f59d57f4-4nd6q --template='{{(index (index .spec.containers 0).ports 0).containerPort}}{{"n"}}' </ins> ``` <del> The output displays the port for Redis in that Pod: </del> <ins> The output displays the port for MongoDB in that Pod: </ins> ``` <del> 6379 </del> <ins> 27017 </ins> ``` <del> (this is the TCP port allocated to Redis on the internet). </del> <ins> (this is the TCP port allocated to MongoDB on the internet). </ins> ## Forward a local port to a port on the Pod

```shell <del> # Change redis-master-765d459796-258hz to the name of the Pod kubectl port-forward redis-master-765d459796-258hz 7000:6379 </del> <ins> # Change mongo-75f59d57f4-4nd6q to the name of the Pod kubectl port-forward mongo-75f59d57f4-4nd6q 28015:27017 </ins> ``` which is the same as ```shell <del> kubectl port-forward pods/redis-master-765d459796-258hz 7000:6379 </del> <ins> kubectl port-forward pods/mongo-75f59d57f4-4nd6q 28015:27017 </ins> ``` or ```shell <del> kubectl port-forward deployment/redis-master 7000:6379 </del> <ins> kubectl port-forward deployment/mongo 28015:27017 </ins> ``` or ```shell <del> kubectl port-forward replicaset/redis-master 7000:6379 </del> <ins> kubectl port-forward replicaset/mongo-75f59d57f4 28015:27017 </ins> ``` or ```shell <del> kubectl port-forward service/redis-master 7000:redis </del> <ins> kubectl port-forward service/mongo 28015:27017 </ins> ``` Any of the above commands works. The output is similar to this: ``` <del> Forwarding from 127.0.0.1:7000 -> 6379 Forwarding from [::1]:7000 -> 6379 </del> <ins> Forwarding from 127.0.0.1:28015 -> 27017 Forwarding from [::1]:28015 -> 27017 </ins> ``` {{< note >}}

{{< /note >}} <del> 2.  Start the Redis command line interface: </del> <ins> 2.  Start the MongoDB command line interface: </ins> ```shell <del> redis-cli -p 7000 </del> <ins> mongosh --port 28015 </ins> ``` <del> 3.  At the Redis command line prompt, enter the `ping` command: </del> <ins> 3.  At the MongoDB command line prompt, enter the `ping` command: </ins> ``` <del> ping </del> <ins> db.runCommand( { ping: 1 } ) </ins> ``` A successful ping request returns: ``` <del> PONG </del> <ins> { ok: 1 } </ins> ``` ### Optionally let _kubectl_ choose the local port {#let-kubectl-choose-local-port}

the slightly simpler syntax: ```shell <del> kubectl port-forward deployment/redis-master :6379 </del> <ins> kubectl port-forward deployment/mongo :27017 ``` The output is similar to this: ``` Forwarding from 127.0.0.1:63753 -> 27017 Forwarding from [::1]:63753 -> 27017 </ins> ``` The `kubectl` tool finds a local port number that is not in use (avoiding low ports numbers, because these might be used by other applications). The output is similar to: ``` <del> Forwarding from 127.0.0.1:62162 -> 6379 Forwarding from [::1]:62162 -> 6379 </del> <ins> Forwarding from 127.0.0.1:63753 -> 27017 Forwarding from [::1]:63753 -> 27017 </ins> ```

## Discussion <del> 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 </del> <ins> Connections made to local port 28015 are forwarded to port 27017 of the Pod that is running the MongoDB server. With this connection in place, you can use your </ins> local workstation to debug the database that is running in the Pod. {{< note >}}