Skip to content

Commit

Permalink
Update debug-service.md's tasks file and remove $ from kubectl
Browse files Browse the repository at this point in the history
  • Loading branch information
DanyC97 committed Feb 26, 2019
1 parent 224cebb commit ecc9447
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions content/en/docs/tasks/debug-application-cluster/debug-service.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ OUTPUT
If the command is "kubectl ARGS":

```shell
$ kubectl ARGS
kubectl ARGS
OUTPUT
```

Expand All @@ -51,16 +51,18 @@ For many steps here you will want to see what a `Pod` running in the cluster
sees. The simplest way to do this is to run an interactive busybox `Pod`:

```none
$ kubectl run -it --rm --restart=Never busybox --image=busybox sh
If you don't see a command prompt, try pressing enter.
kubectl run -it --rm --restart=Never busybox --image=busybox sh
/ #
```
{{< note >}}
If you don't see a command prompt, try pressing enter.
{{< /note >}}

If you already have a running `Pod` that you prefer to use, you can run a
command in it using:

```shell
$ kubectl exec <POD-NAME> -c <CONTAINER-NAME> -- <COMMAND>
kubectl exec <POD-NAME> -c <CONTAINER-NAME> -- <COMMAND>
```

## Setup
Expand All @@ -70,7 +72,7 @@ probably debugging your own `Service` you can substitute your own details, or yo
can follow along and get a second data point.

```shell
$ kubectl run hostnames --image=k8s.gcr.io/serve_hostname \
kubectl run hostnames --image=k8s.gcr.io/serve_hostname \
--labels=app=hostnames \
--port=9376 \
--replicas=3
Expand Down Expand Up @@ -108,7 +110,7 @@ spec:
Confirm your `Pods` are running:

```shell
$ kubectl get pods -l app=hostnames
kubectl get pods -l app=hostnames
NAME READY STATUS RESTARTS AGE
hostnames-632524106-bbpiw 1/1 Running 0 2m
hostnames-632524106-ly40y 1/1 Running 0 2m
Expand All @@ -134,7 +136,7 @@ wget: unable to resolve host address 'hostnames'
So the first thing to check is whether that `Service` actually exists:

```shell
$ kubectl get svc hostnames
kubectl get svc hostnames
No resources found.
Error from server (NotFound): services "hostnames" not found
```
Expand All @@ -143,14 +145,14 @@ So we have a culprit, let's create the `Service`. As before, this is for the
walk-through - you can use your own `Service`'s details here.

```shell
$ kubectl expose deployment hostnames --port=80 --target-port=9376
kubectl expose deployment hostnames --port=80 --target-port=9376
service/hostnames exposed
```

And read it back, just to be sure:

```shell
$ kubectl get svc hostnames
kubectl get svc hostnames
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
hostnames ClusterIP 10.0.1.175 <none> 80/TCP 5s
```
Expand Down Expand Up @@ -301,7 +303,7 @@ It might sound silly, but you should really double and triple check that your
and verify it:

```shell
$ kubectl get service hostnames -o json
kubectl get service hostnames -o json
```
```json
{
Expand Down Expand Up @@ -356,7 +358,7 @@ actually being selected by the `Service`.
Earlier we saw that the `Pods` were running. We can re-check that:

```shell
$ kubectl get pods -l app=hostnames
kubectl get pods -l app=hostnames
NAME READY STATUS RESTARTS AGE
hostnames-0uton 1/1 Running 0 1h
hostnames-bvc05 1/1 Running 0 1h
Expand All @@ -371,7 +373,7 @@ has. Inside the Kubernetes system is a control loop which evaluates the
selector of every `Service` and saves the results into an `Endpoints` object.

```shell
$ kubectl get endpoints hostnames
kubectl get endpoints hostnames
NAME ENDPOINTS
hostnames 10.244.0.5:9376,10.244.0.6:9376,10.244.0.7:9376
```
Expand Down Expand Up @@ -414,7 +416,7 @@ Another thing to check is that your `Pods` are not crashing or being restarted.
Frequent restarts could lead to intermittent connectivity issues.

```shell
$ kubectl get pods -l app=hostnames
kubectl get pods -l app=hostnames
NAME READY STATUS RESTARTS AGE
hostnames-632524106-bbpiw 1/1 Running 0 2m
hostnames-632524106-ly40y 1/1 Running 0 2m
Expand Down

0 comments on commit ecc9447

Please sign in to comment.