Skip to content

Commit 7359d60

Browse files
committed
Tweak indentation on portforward page
This PR fixes the indentation nits in the `port-forward-access-application-cluster` page. We are not supposed to indent lines by 4 spaces because such indentations may mislead the markdown parser to render them as code snippets.
1 parent 0577a89 commit 7359d60

File tree

1 file changed

+102
-116
lines changed

1 file changed

+102
-116
lines changed

content/en/docs/tasks/access-application-cluster/port-forward-access-application-cluster.md

Lines changed: 102 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -11,180 +11,169 @@ This page shows how to use `kubectl port-forward` to connect to a MongoDB
1111
server running in a Kubernetes cluster. This type of connection can be useful
1212
for database debugging.
1313

14-
15-
16-
1714
## {{% heading "prerequisites" %}}
1815

19-
2016
* {{< include "task-tutorial-prereqs.md" >}} {{< version-check >}}
21-
2217
* Install [MongoDB Shell](https://www.mongodb.com/try/download/shell).
2318

24-
25-
26-
2719
<!-- steps -->
2820

2921
## Creating MongoDB deployment and service
3022

3123
1. Create a Deployment that runs MongoDB:
3224

33-
```shell
34-
kubectl apply -f https://k8s.io/examples/application/mongodb/mongo-deployment.yaml
35-
```
36-
37-
The output of a successful command verifies that the deployment was created:
25+
```shell
26+
kubectl apply -f https://k8s.io/examples/application/mongodb/mongo-deployment.yaml
27+
```
3828

39-
```
40-
deployment.apps/mongo created
41-
```
29+
The output of a successful command verifies that the deployment was created:
4230

43-
View the pod status to check that it is ready:
31+
```
32+
deployment.apps/mongo created
33+
```
4434

45-
```shell
46-
kubectl get pods
47-
```
35+
View the pod status to check that it is ready:
4836

49-
The output displays the pod created:
37+
```shell
38+
kubectl get pods
39+
```
5040

51-
```
52-
NAME READY STATUS RESTARTS AGE
53-
mongo-75f59d57f4-4nd6q 1/1 Running 0 2m4s
54-
```
41+
The output displays the pod created:
5542

56-
View the Deployment's status:
43+
```
44+
NAME READY STATUS RESTARTS AGE
45+
mongo-75f59d57f4-4nd6q 1/1 Running 0 2m4s
46+
```
5747

58-
```shell
59-
kubectl get deployment
60-
```
48+
View the Deployment's status:
6149

62-
The output displays that the Deployment was created:
50+
```shell
51+
kubectl get deployment
52+
```
6353

64-
```
65-
NAME READY UP-TO-DATE AVAILABLE AGE
66-
mongo 1/1 1 1 2m21s
67-
```
54+
The output displays that the Deployment was created:
6855

69-
The Deployment automatically manages a ReplicaSet.
70-
View the ReplicaSet status using:
56+
```
57+
NAME READY UP-TO-DATE AVAILABLE AGE
58+
mongo 1/1 1 1 2m21s
59+
```
7160

72-
```shell
73-
kubectl get replicaset
74-
```
61+
The Deployment automatically manages a ReplicaSet.
62+
View the ReplicaSet status using:
7563

76-
The output displays that the ReplicaSet was created:
64+
```shell
65+
kubectl get replicaset
66+
```
7767

78-
```
79-
NAME DESIRED CURRENT READY AGE
80-
mongo-75f59d57f4 1 1 1 3m12s
81-
```
68+
The output displays that the ReplicaSet was created:
8269

70+
```
71+
NAME DESIRED CURRENT READY AGE
72+
mongo-75f59d57f4 1 1 1 3m12s
73+
```
8374

8475
2. Create a Service to expose MongoDB on the network:
8576

86-
```shell
87-
kubectl apply -f https://k8s.io/examples/application/mongodb/mongo-service.yaml
88-
```
77+
```shell
78+
kubectl apply -f https://k8s.io/examples/application/mongodb/mongo-service.yaml
79+
```
8980

90-
The output of a successful command verifies that the Service was created:
81+
The output of a successful command verifies that the Service was created:
9182

92-
```
93-
service/mongo created
94-
```
83+
```
84+
service/mongo created
85+
```
9586

96-
Check the Service created:
87+
Check the Service created:
9788

98-
```shell
99-
kubectl get service mongo
100-
```
89+
```shell
90+
kubectl get service mongo
91+
```
10192

102-
The output displays the service created:
93+
The output displays the service created:
10394

104-
```
105-
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
106-
mongo ClusterIP 10.96.41.183 <none> 27017/TCP 11s
107-
```
95+
```
96+
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
97+
mongo ClusterIP 10.96.41.183 <none> 27017/TCP 11s
98+
```
10899

109100
3. Verify that the MongoDB server is running in the Pod, and listening on port 27017:
110101

111-
```shell
112-
# Change mongo-75f59d57f4-4nd6q to the name of the Pod
113-
kubectl get pod mongo-75f59d57f4-4nd6q --template='{{(index (index .spec.containers 0).ports 0).containerPort}}{{"\n"}}'
114-
```
102+
```shell
103+
# Change mongo-75f59d57f4-4nd6q to the name of the Pod
104+
kubectl get pod mongo-75f59d57f4-4nd6q --template='{{(index (index .spec.containers 0).ports 0).containerPort}}{{"\n"}}'
105+
```
115106

116-
The output displays the port for MongoDB in that Pod:
107+
The output displays the port for MongoDB in that Pod:
117108

118-
```
119-
27017
120-
```
109+
```
110+
27017
111+
```
121112

122-
(this is the TCP port allocated to MongoDB on the internet).
113+
27017 is the TCP port allocated to MongoDB on the internet.
123114

124115
## Forward a local port to a port on the Pod
125116

126-
1. `kubectl port-forward` allows using resource name, such as a pod name, to select a matching pod to port forward to.
117+
1. `kubectl port-forward` allows using resource name, such as a pod name, to select a matching pod to port forward to.
127118

128119

129-
```shell
130-
# Change mongo-75f59d57f4-4nd6q to the name of the Pod
131-
kubectl port-forward mongo-75f59d57f4-4nd6q 28015:27017
132-
```
120+
```shell
121+
# Change mongo-75f59d57f4-4nd6q to the name of the Pod
122+
kubectl port-forward mongo-75f59d57f4-4nd6q 28015:27017
123+
```
133124

134-
which is the same as
125+
which is the same as
135126

136-
```shell
137-
kubectl port-forward pods/mongo-75f59d57f4-4nd6q 28015:27017
138-
```
127+
```shell
128+
kubectl port-forward pods/mongo-75f59d57f4-4nd6q 28015:27017
129+
```
139130

140-
or
131+
or
141132

142-
```shell
143-
kubectl port-forward deployment/mongo 28015:27017
144-
```
133+
```shell
134+
kubectl port-forward deployment/mongo 28015:27017
135+
```
145136

146-
or
137+
or
147138

148-
```shell
149-
kubectl port-forward replicaset/mongo-75f59d57f4 28015:27017
150-
```
139+
```shell
140+
kubectl port-forward replicaset/mongo-75f59d57f4 28015:27017
141+
```
151142

152-
or
143+
or
153144

154-
```shell
155-
kubectl port-forward service/mongo 28015:27017
156-
```
145+
```shell
146+
kubectl port-forward service/mongo 28015:27017
147+
```
157148

158-
Any of the above commands works. The output is similar to this:
149+
Any of the above commands works. The output is similar to this:
159150

160-
```
161-
Forwarding from 127.0.0.1:28015 -> 27017
162-
Forwarding from [::1]:28015 -> 27017
163-
```
151+
```
152+
Forwarding from 127.0.0.1:28015 -> 27017
153+
Forwarding from [::1]:28015 -> 27017
154+
```
164155

165-
{{< note >}}
166-
167-
`kubectl port-forward` does not return. To continue with the exercises, you will need to open another terminal.
156+
{{< note >}}
157+
`kubectl port-forward` does not return. To continue with the exercises, you will need to open another terminal.
158+
{{< /note >}}
168159

169-
{{< /note >}}
160+
2. Start the MongoDB command line interface:
170161

171-
2. Start the MongoDB command line interface:
162+
```shell
163+
mongosh --port 28015
164+
```
172165

173-
```shell
174-
mongosh --port 28015
175-
```
166+
3. At the MongoDB command line prompt, enter the `ping` command:
176167

177-
3. At the MongoDB command line prompt, enter the `ping` command:
168+
```
169+
db.runCommand( { ping: 1 } )
170+
```
178171

179-
```
180-
db.runCommand( { ping: 1 } )
181-
```
172+
A successful ping request returns:
182173

183-
A successful ping request returns:
184-
185-
```
186-
{ ok: 1 }
187-
```
174+
```
175+
{ ok: 1 }
176+
```
188177

189178
### Optionally let _kubectl_ choose the local port {#let-kubectl-choose-local-port}
190179

@@ -204,7 +193,6 @@ Forwarding from 127.0.0.1:63753 -> 27017
204193
Forwarding from [::1]:63753 -> 27017
205194
```
206195

207-
208196
<!-- discussion -->
209197

210198
## Discussion
@@ -219,9 +207,7 @@ The support for UDP protocol is tracked in
219207
[issue 47862](https://github.com/kubernetes/kubernetes/issues/47862).
220208
{{< /note >}}
221209

222-
223-
224-
225210
## {{% heading "whatsnext" %}}
226211

227212
Learn more about [kubectl port-forward](/docs/reference/generated/kubectl/kubectl-commands/#port-forward).
213+

0 commit comments

Comments
 (0)