Skip to content

Commit 0bb1827

Browse files
committed
Fix formatting for debugging services docs
1 parent 715f2c4 commit 0bb1827

File tree

1 file changed

+29
-29
lines changed

1 file changed

+29
-29
lines changed

docs/user-guide/debugging-services.md

+29-29
Original file line numberDiff line numberDiff line change
@@ -70,21 +70,21 @@ clear what is expected, this document will use the following conventions.
7070

7171
If the command "COMMAND" is expected to run in a `Pod` and produce "OUTPUT":
7272

73-
```sh
73+
```console
7474
pod$ COMMAND
7575
OUTPUT
7676
```
7777

7878
If the command "COMMAND" is expected to run on a `Node` and produce "OUTPUT":
7979

80-
```sh
80+
```console
8181
node$ COMMAND
8282
OUTPUT
8383
```
8484

8585
If the command is "kubectl ARGS":
8686

87-
```sh
87+
```console
8888
$ kubectl ARGS
8989
OUTPUT
9090
```
@@ -95,7 +95,7 @@ For many steps here you will want to see what a `Pod` running in the cluster
9595
sees. Kubernetes does not directly support interactive `Pod`s (yet), but you can
9696
approximate it:
9797

98-
```sh
98+
```console
9999
$ cat <<EOF | kubectl create -f -
100100
apiVersion: v1
101101
kind: Pod
@@ -115,13 +115,13 @@ pods/busybox-sleep
115115
Now, when you need to run a command (even an interactive shell) in a `Pod`-like
116116
context, use:
117117

118-
```sh
118+
```console
119119
$ kubectl exec busybox-sleep -- <COMMAND>
120120
```
121121

122122
or
123123

124-
```sh
124+
```console
125125
$ kubectl exec -ti busybox-sleep sh
126126
/ #
127127
```
@@ -132,7 +132,7 @@ For the purposes of this walk-through, let's run some `Pod`s. Since you're
132132
probably debugging your own `Service` you can substitute your own details, or you
133133
can follow along and get a second data point.
134134

135-
```sh
135+
```console
136136
$ kubectl run hostnames --image=gcr.io/google_containers/serve_hostname \
137137
--labels=app=hostnames \
138138
--port=9376 \
@@ -168,7 +168,7 @@ spec:
168168
169169
Confirm your `Pod`s are running:
170170

171-
```sh
171+
```console
172172
$ kubectl get pods -l app=hostnames
173173
NAME READY STATUS RESTARTS AGE
174174
hostnames-0uton 1/1 Running 0 12s
@@ -186,37 +186,37 @@ So what would happen if I tried to access a non-existent `Service`? Assuming yo
186186
have another `Pod` that consumes this `Service` by name you would get something
187187
like:
188188

189-
```sh
189+
```console
190190
pod$ wget -qO- hostnames
191191
wget: bad address 'hostname'
192192
```
193193

194194
or:
195195

196-
```sh
196+
```console
197197
pod$ echo $HOSTNAMES_SERVICE_HOST
198198
199199
```
200200

201201
So the first thing to check is whether that `Service` actually exists:
202202

203-
```sh
203+
```console
204204
$ kubectl get svc hostnames
205205
Error from server: service "hostnames" not found
206206
```
207207

208208
So we have a culprit, let's create the `Service`. As before, this is for the
209209
walk-through - you can use your own `Service`'s details here.
210210

211-
```sh
211+
```console
212212
$ kubectl expose rc hostnames --port=80 --target-port=9376
213213
NAME LABELS SELECTOR IP(S) PORT(S)
214214
hostnames app=hostnames app=hostnames 80/TCP
215215
```
216216

217217
And read it back, just to be sure:
218218

219-
```sh
219+
```console
220220
$ kubectl get svc hostnames
221221
NAME LABELS SELECTOR IP(S) PORT(S)
222222
hostnames app=hostnames app=hostnames 10.0.1.175 80/TCP
@@ -245,7 +245,7 @@ Now you can confirm that the `Service` exists.
245245

246246
From a `Pod` in the same `Namespace`:
247247

248-
```sh
248+
```console
249249
pod$ nslookup hostnames
250250
Server: 10.0.0.10
251251
Address: 10.0.0.10#53
@@ -257,7 +257,7 @@ Address: 10.0.1.175
257257
If this fails, perhaps your `Pod` and `Service` are in different
258258
`Namespace`s, try a namespace-qualified name:
259259

260-
```sh
260+
```console
261261
pod$ nslookup hostnames.default
262262
Server: 10.0.0.10
263263
Address: 10.0.0.10#53
@@ -269,7 +269,7 @@ Address: 10.0.1.175
269269
If this works, you'll need to ensure that `Pod`s and `Service`s run in the same
270270
`Namespace`. If this still fails, try a fully-qualified name:
271271

272-
```sh
272+
```console
273273
pod$ nslookup hostnames.default.svc.cluster.local
274274
Server: 10.0.0.10
275275
Address: 10.0.0.10#53
@@ -285,7 +285,7 @@ The "cluster.local" is your cluster domain.
285285
You can also try this from a `Node` in the cluster (note: 10.0.0.10 is my DNS
286286
`Service`):
287287

288-
```sh
288+
```console
289289
node$ nslookup hostnames.default.svc.cluster.local 10.0.0.10
290290
Server: 10.0.0.10
291291
Address: 10.0.0.10#53
@@ -307,7 +307,7 @@ If the above still fails - DNS lookups are not working for your `Service` - we
307307
can take a step back and see what else is not working. The Kubernetes master
308308
`Service` should always work:
309309

310-
```sh
310+
```console
311311
pod$ nslookup kubernetes.default
312312
Server: 10.0.0.10
313313
Address 1: 10.0.0.10
@@ -325,7 +325,7 @@ debugging your own `Service`, debug DNS.
325325
The next thing to test is whether your `Service` works at all. From a
326326
`Node` in your cluster, access the `Service`'s IP (from `kubectl get` above).
327327

328-
```sh
328+
```console
329329
node$ curl 10.0.1.175:80
330330
hostnames-0uton
331331
@@ -345,7 +345,7 @@ It might sound silly, but you should really double and triple check that your
345345
`Service` is correct and matches your `Pods`. Read back your `Service` and
346346
verify it:
347347

348-
```sh
348+
```console
349349
$ kubectl get service hostnames -o json
350350
{
351351
"kind": "Service",
@@ -398,7 +398,7 @@ actually being selected by the `Service`.
398398

399399
Earlier we saw that the `Pod`s were running. We can re-check that:
400400

401-
```sh
401+
```console
402402
$ kubectl get pods -l app=hostnames
403403
NAME READY STATUS RESTARTS AGE
404404
hostnames-0uton 1/1 Running 0 1h
@@ -413,7 +413,7 @@ The `-l app=hostnames` argument is a label selector - just like our `Service`
413413
has. Inside the Kubernetes system is a control loop which evaluates the
414414
selector of every `Service` and save the results into an `Endpoints` object.
415415

416-
```sh
416+
```console
417417
$ kubectl get endpoints hostnames
418418
NAME ENDPOINTS
419419
hostnames 10.244.0.5:9376,10.244.0.6:9376,10.244.0.7:9376
@@ -430,7 +430,7 @@ At this point, we know that your `Service` exists and has selected your `Pod`s.
430430
Let's check that the `Pod`s are actually working - we can bypass the `Service`
431431
mechanism and go straight to the `Pod`s.
432432

433-
```sh
433+
```console
434434
pod$ wget -qO- 10.244.0.5:9376
435435
hostnames-0uton
436436
@@ -458,7 +458,7 @@ suspect. Let's confirm it, piece by piece.
458458
Confirm that `kube-proxy` is running on your `Node`s. You should get something
459459
like the below:
460460

461-
```sh
461+
```console
462462
node$ ps auxw | grep kube-proxy
463463
root 4194 0.4 0.1 101864 17696 ? Sl Jul04 25:43 /usr/local/bin/kube-proxy --master=https://kubernetes-master --kubeconfig=/var/lib/kube-proxy/kubeconfig --v=2
464464
```
@@ -469,7 +469,7 @@ depends on your `Node` OS. On some OSes it is a file, such as
469469
/var/log/kube-proxy.log, while other OSes use `journalctl` to access logs. You
470470
should see something like:
471471

472-
```
472+
```console
473473
I0707 17:34:53.945651 30031 server.go:88] Running in resource-only container "/kube-proxy"
474474
I0707 17:34:53.945921 30031 proxier.go:121] Setting proxy IP to 10.240.115.247 and initializing iptables
475475
I0707 17:34:54.053023 30031 roundrobin.go:262] LoadBalancerRR: Setting endpoints for default/kubernetes: to [10.240.169.188:443]
@@ -499,7 +499,7 @@ One of the main responsibilities of `kube-proxy` is to write the `iptables`
499499
rules which implement `Service`s. Let's check that those rules are getting
500500
written.
501501

502-
```
502+
```console
503503
node$ iptables-save | grep hostnames
504504
-A KUBE-PORTALS-CONTAINER -d 10.0.1.175/32 -p tcp -m comment --comment "default/hostnames:default" -m tcp --dport 80 -j REDIRECT --to-ports 48577
505505
-A KUBE-PORTALS-HOST -d 10.0.1.175/32 -p tcp -m comment --comment "default/hostnames:default" -m tcp --dport 80 -j DNAT --to-destination 10.240.115.247:48577
@@ -514,7 +514,7 @@ then look at the logs again.
514514

515515
Assuming you do see the above rules, try again to access your `Service` by IP:
516516

517-
```sh
517+
```console
518518
node$ curl 10.0.1.175:80
519519
hostnames-0uton
520520
```
@@ -524,14 +524,14 @@ If this fails, we can try accessing the proxy directly. Look back at the
524524
using for your `Service`. In the above examples it is "48577". Now connect to
525525
that:
526526

527-
```sh
527+
```console
528528
node$ curl localhost:48577
529529
hostnames-yp2kp
530530
```
531531

532532
If this still fails, look at the `kube-proxy` logs for specific lines like:
533533

534-
```
534+
```console
535535
Setting endpoints for default/hostnames:default to [10.244.0.5:9376 10.244.0.6:9376 10.244.0.7:9376]
536536
```
537537

0 commit comments

Comments
 (0)