Skip to content

Commit 58811df

Browse files
authored
Merge pull request #21065 from sharet-adl/patch-2
update deployment sample, due to deprecated option
2 parents 75392cb + c9a278d commit 58811df

File tree

1 file changed

+39
-27
lines changed

1 file changed

+39
-27
lines changed

content/en/docs/tasks/debug-application-cluster/debug-service.md

Lines changed: 39 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,22 @@ probably debugging your own Service you can substitute your own details, or you
4545
can follow along and get a second data point.
4646

4747
```shell
48-
kubectl run hostnames --image=k8s.gcr.io/serve_hostname \
49-
--replicas=3
48+
kubectl create deployment hostnames --image=k8s.gcr.io/serve_hostname
5049
```
5150
```none
5251
deployment.apps/hostnames created
5352
```
5453

5554
`kubectl` commands will print the type and name of the resource created or mutated, which can then be used in subsequent commands.
5655

56+
Let's scale the deployment to 3 replicas.
57+
```shell
58+
kubectl scale deployment hostnames --replicas=3
59+
```
60+
```none
61+
deployment.apps/hostnames scaled
62+
```
63+
5764
{{< note >}}
5865
This is the same as if you had started the Deployment with the following
5966
YAML:
@@ -62,30 +69,32 @@ YAML:
6269
apiVersion: apps/v1
6370
kind: Deployment
6471
metadata:
72+
labels:
73+
app: hostnames
6574
name: hostnames
6675
spec:
6776
selector:
6877
matchLabels:
69-
run: hostnames
78+
app: hostnames
7079
replicas: 3
7180
template:
7281
metadata:
7382
labels:
74-
run: hostnames
83+
app: hostnames
7584
spec:
7685
containers:
7786
- name: hostnames
7887
image: k8s.gcr.io/serve_hostname
7988
```
8089
81-
The label "run" is automatically set by `kubectl run` to the name of the
90+
The label "app" is automatically set by `kubectl create deployment` to the name of the
8291
Deployment.
8392
{{< /note >}}
8493

8594
You can confirm your Pods are running:
8695

8796
```shell
88-
kubectl get pods -l run=hostnames
97+
kubectl get pods -l app=hostnames
8998
```
9099
```none
91100
NAME READY STATUS RESTARTS AGE
@@ -98,7 +107,7 @@ You can also confirm that your Pods are serving. You can get the list of
98107
Pod IP addresses and test them directly.
99108

100109
```shell
101-
kubectl get pods -l run=hostnames \
110+
kubectl get pods -l app=hostnames \
102111
-o go-template='{{range .items}}{{.status.podIP}}{{"\n"}}{{end}}'
103112
```
104113
```none
@@ -122,9 +131,9 @@ done
122131
This should produce something like:
123132

124133
```
125-
hostnames-0uton
126-
hostnames-bvc05
127-
hostnames-yp2kp
134+
hostnames-632524106-bbpiw
135+
hostnames-632524106-ly40y
136+
hostnames-632524106-tlaok
128137
```
129138

130139
If you are not getting the responses you expect at this point, your Pods
@@ -193,10 +202,12 @@ As before, this is the same as if you had started the Service with YAML:
193202
apiVersion: v1
194203
kind: Service
195204
metadata:
205+
labels:
206+
app: hostnames
196207
name: hostnames
197208
spec:
198209
selector:
199-
run: hostnames
210+
app: hostnames
200211
ports:
201212
- name: default
202213
protocol: TCP
@@ -345,9 +356,9 @@ done
345356
This should produce something like:
346357

347358
```
348-
hostnames-0uton
349-
hostnames-bvc05
350-
hostnames-yp2kp
359+
hostnames-632524106-bbpiw
360+
hostnames-632524106-ly40y
361+
hostnames-632524106-tlaok
351362
```
352363

353364
If your Service is working, you should get correct responses. If not, there
@@ -373,7 +384,7 @@ kubectl get service hostnames -o json
373384
"resourceVersion": "347189",
374385
"creationTimestamp": "2015-07-07T15:24:29Z",
375386
"labels": {
376-
"run": "hostnames"
387+
"app": "hostnames"
377388
}
378389
},
379390
"spec": {
@@ -387,7 +398,7 @@ kubectl get service hostnames -o json
387398
}
388399
],
389400
"selector": {
390-
"run": "hostnames"
401+
"app": "hostnames"
391402
},
392403
"clusterIP": "10.0.1.175",
393404
"type": "ClusterIP",
@@ -414,16 +425,16 @@ actually being selected by the Service.
414425
Earlier you saw that the Pods were running. You can re-check that:
415426

416427
```shell
417-
kubectl get pods -l run=hostnames
428+
kubectl get pods -l app=hostnames
418429
```
419430
```none
420431
NAME READY STATUS RESTARTS AGE
421-
hostnames-0uton 1/1 Running 0 1h
422-
hostnames-bvc05 1/1 Running 0 1h
423-
hostnames-yp2kp 1/1 Running 0 1h
432+
hostnames-632524106-bbpiw 1/1 Running 0 1h
433+
hostnames-632524106-ly40y 1/1 Running 0 1h
434+
hostnames-632524106-tlaok 1/1 Running 0 1h
424435
```
425436

426-
The `-l run=hostnames` argument is a label selector - just like our Service
437+
The `-l app=hostnames` argument is a label selector - just like our Service
427438
has.
428439

429440
The "AGE" column says that these Pods are about an hour old, which implies that
@@ -448,7 +459,8 @@ your Service. If the `ENDPOINTS` column is `<none>`, you should check that
448459
the `spec.selector` field of your Service actually selects for
449460
`metadata.labels` values on your Pods. A common mistake is to have a typo or
450461
other error, such as the Service selecting for `app=hostnames`, but the
451-
Deployment specifying `run=hostnames`.
462+
Deployment specifying `run=hostnames`, as in versions previous to 1.18, where
463+
the `kubectl run` command could have been also used to create a Deployment.
452464

453465
## Are the Pods working?
454466

@@ -473,9 +485,9 @@ done
473485
This should produce something like:
474486

475487
```
476-
hostnames-0uton
477-
hostnames-bvc05
478-
hostnames-yp2kp
488+
hostnames-632524106-bbpiw
489+
hostnames-632524106-ly40y
490+
hostnames-632524106-tlaok
479491
```
480492

481493
You expect each Pod in the Endpoints list to return its own hostname. If
@@ -617,7 +629,7 @@ IP from one of your Nodes:
617629
curl 10.0.1.175:80
618630
```
619631
```none
620-
hostnames-0uton
632+
hostnames-632524106-bbpiw
621633
```
622634

623635
If this fails and you are using the userspace proxy, you can try accessing the
@@ -631,7 +643,7 @@ examples it is "48577". Now connect to that:
631643
curl localhost:48577
632644
```
633645
```none
634-
hostnames-yp2kp
646+
hostnames-632524106-tlaok
635647
```
636648

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

0 commit comments

Comments
 (0)