-
Notifications
You must be signed in to change notification settings - Fork 0
/
parksmap-container-image.html
718 lines (643 loc) · 28.4 KB
/
parksmap-container-image.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="apple-touch-icon" sizes="180x180" href="apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="favicon-16x16.png">
<link rel="manifest" href="site.webmanifest">
<link rel="mask-icon" href="safari-pinned-tab.svg" color="#5bbad5">
<meta name="msapplication-TileColor" content="#da532c">
<meta name="theme-color" content="#ffffff">
<script src="jquery/jquery.min.js"></script>
<script src="popper/popper.min.js"></script>
<script src="bootstrap/js/bootstrap.min.js"></script>
<script src="requirejs/require.js"></script>
<script>var workshop_base_url = "/user/user3/workshop";</script>
<link rel="stylesheet" href="asciidoctor/css/asciidoctor.css">
<link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" href="fontawesome/css/all.min.css">
<link rel="stylesheet" href="css/workshop.css">
<link rel="stylesheet" href="css/workshop-asciidoc.css">
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-135921114-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag("js", new Date());
gtag("config", "UA-135921114-11");
</script>
</head>
</body>
<!-- Header -->
<header class="header">
<div class="container-fluid">
<div class="row">
<div class="col-sm-6">
<a href="" class="logo">Starter Labs (Java)</a>
</div>
</div>
</div>
</header>
<!-- Main -->
<div class="container-fluid">
<div class="row">
<div class="col-sm-3 d-sm-block d-none">
<!-- Table of Contents -->
<ul class="menu">
<li class="category">
<ul class="modules">
<h5 class="category-title">Workshop Modules</h5>
<li class="page"><a href="common-workshop-summary.html">Workshop Summary</a></li>
<li class="page"><a href="common-environment.html">Environment Overview</a></li>
<li class="page"><a href="common-using-homeroom.html">Using Homeroom</a></li>
<li class="page"><a href="common-parksmap-architecture.html">Architecture Overview of the ParksMap Application</a></li>
<li class="page"><a href="common-explore.html">Exploring the CLI and Web Console</a></li>
<li class="page active"><a href="parksmap-container-image.html">Deploying Your First Container Image</a></li>
<li class="page"><a href="parksmap-scaling.html">Scaling and Self Healing</a></li>
<li class="page"><a href="parksmap-routes.html">Exposing Your Application to the Outside World</a></li>
<li class="page"><a href="parksmap-logging.html">Exploring OpenShift's Logging Capabilities</a></li>
<li class="page"><a href="parksmap-permissions.html">Role-Based Access Control</a></li>
<li class="page"><a href="parksmap-rsh.html">Remote Access to Your Application</a></li>
<li class="page"><a href="nationalparks-java.html">Deploying Java Code</a></li>
<li class="page"><a href="nationalparks-java-databases.html">Adding a Database (MongoDB)</a></li>
<li class="page"><a href="nationalparks-java-application-health.html">Application Health</a></li>
<li class="page"><a href="nationalparks-java-pipeline.html">Automate Build and Deployment with Pipelines</a></li>
<li class="page"><a href="nationalparks-java-pipeline-codechanges-gogs.html">Automation for Your Application on Code Changes</a></li>
<li class="page"><a href="mlbparks-templates.html">Using Application Templates</a></li>
<li class="page"><a href="mlbparks-binary-build.html">Binary Builds for Day to Day Development</a></li>
<li class="page"><a href="common-further-resources.html">Further Resources</a></li>
<li class="page"><a href="common-workshop-links.html">Workshop Links</a></li>
</ul>
</li>
</ul>
</div>
<div class="col-sm-9">
<section class="page-content">
<!-- Top Navigation -->
<div class="btn-group btn-group-xs float-right">
<button type="button" onclick="location.href='common-explore';" class="btn btn-xs btn-transparent" aria-label="Prev">
<span class="fas fa-arrow-left" aria-hidden="true"></span>
</button>
<button type="button" onclick="location.href='';" class="btn btn-xs btn-transparent" aria-label="Home">
<span class="fas fa-home" aria-hidden="true"></span>
</button>
<button type="button" onclick="location.href='parksmap-scaling';" class="btn btn-xs btn-transparent" aria-label="Next">
<span class="fas fa-arrow-right" aria-hidden="true"></span>
</button>
</div>
<!-- Title -->
<h1 class="title">Deploying Your First Container Image</h1>
<!-- Content -->
<div class="paragraph">
<p>In this lab, we’re going to deploy the web component of the ParksMap application which is also called <code>parksmap</code> and uses OpenShift’s service discovery mechanism to discover the backend services deployed and shows their data on the map.</p>
</div>
<div class="imageblock text-center">
<div class="content">
<img src="images/roadshow-app-architecture-parksmap-1.png" alt="Application architecture" width="800">
</div>
</div>
<div class="sect1">
<h2 id="_exercise_deploying_your_first_image">Exercise: Deploying your First Image</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Let’s start by doing the simplest thing possible - get a plain old
Docker-formatted image to run on OpenShift. This is incredibly simple to do.
With OpenShift it can be done directly from the web console.</p>
</div>
<div class="paragraph">
<p>Return to the <a href="http://console-openshift-console.apps.cluster-test-efcf.test-efcf.example.opentlc.com/k8s/cluster/projects">Web Console</a>.</p>
</div>
<div class="paragraph">
<p>If you’re no longer on the <strong>Topology</strong> view in the Developer perspective, return there now. Click <strong>Container Image</strong> to open a dialog that will allow you to specify the information for the image you want to deploy.</p>
</div>
<div class="imageblock">
<div class="content">
<img src="images/parksmap-devconsole-container-image.png" alt="Add from Container Image">
</div>
</div>
<div class="paragraph">
<p>In the <strong>Image Name</strong> field, copy/paste the following into the box:</p>
</div>
<div class="listingblock copy">
<div class="content">
<pre class="highlight"><code>quay.io/openshiftroadshow/parksmap:latest</code></pre>
</div>
</div>
<div class="paragraph">
<p>OpenShift will then go out to the container registry specified and interrogate the image.</p>
</div>
<div class="paragraph">
<p>Your screen will end up looking something like this:</p>
</div>
<div class="imageblock">
<div class="content">
<img src="images/parksmap-image.png" alt="Explore Project">
</div>
</div>
<div class="paragraph">
<p>In <strong>Runtime Icon</strong> you can select the icon to use in OpenShift Topology View for the app. You can leave the default OpenShift icon, or select one from the list.</p>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<div class="title">Note</div>
</td>
<td class="content">
The purpose of this exercise is to deploy a microservice from an agnostic existing container image (Frontend, this was made with Spring Boot). The specific programming language path you have chosen is described and implemented in the next microservice chapter (Backend).
</td>
</tr>
</table>
</div>
<div class="paragraph">
<p>Make sure to have the correct values in:</p>
</div>
<div class="ulist">
<ul>
<li>
<p><strong>Application Name</strong> : workshop</p>
</li>
<li>
<p><strong>Name</strong> : parksmap</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>Ensure <strong>Deployment</strong> is selected from <strong>Resource</strong> section.</p>
</div>
<div class="paragraph">
<p><strong>Un-check</strong> the checkbox next to <strong>Create a route to the application</strong>. For learning purposes, we will create a <strong>Route</strong> for the application later in the workshop.</p>
</div>
<div class="paragraph">
<p>At the bottom of the page, click <strong>Labels</strong> in the Advanced Options section and add some labels to better identify this deployment later. Labels will help us identify and filter components in the web console and in the command line.</p>
</div>
<div class="paragraph">
<p>We will add 3 labels. After you enter the name=value pair for each label, press <strong>tab</strong> or de-focus with mouse before typing the next. First the name to be given to the application.</p>
</div>
<div class="listingblock copy">
<div class="content">
<pre class="highlight"><code>app=workshop</code></pre>
</div>
</div>
<div class="paragraph">
<p>Next the name of this deployment.</p>
</div>
<div class="listingblock copy">
<div class="content">
<pre class="highlight"><code>component=parksmap</code></pre>
</div>
</div>
<div class="paragraph">
<p>And finally, the role this component plays in the overall application.</p>
</div>
<div class="listingblock copy">
<div class="content">
<pre class="highlight"><code>role=frontend</code></pre>
</div>
</div>
<div class="imageblock">
<div class="content">
<img src="images/parksmap-image-options.png" alt="Deploy image">
</div>
</div>
<div class="paragraph">
<p>Next, click the blue <strong>Create</strong> button. You will be directed to the <strong>Topology</strong> page, where you should see the visualization for the <code>parksmap</code> deployment config in the <code>workshop</code> application.</p>
</div>
<div class="imageblock">
<div class="content">
<img src="images/parksmap-dc-topology.png" alt="Topology View with Parksmap">
</div>
</div>
<div class="paragraph">
<p>These few steps are the only ones you need to run to get a
container image deployed on OpenShift. This should work with any
container image that follows best practices, such as defining an EXPOSE
port, not needing to run specifically as the <strong>root user</strong> or other user name, and a single non-exiting CMD to execute on start.</p>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<div class="title">Note</div>
</td>
<td class="content">
Providing appropriate labels is desired when deploying complex applications for organization purposes. OpenShift uses a label <strong>app</strong> to define and group components together in the Overview page. OpenShift will create this label with some default if the user doesn’t provide it explicitly.
</td>
</tr>
</table>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_background_containers_and_pods">Background: Containers and Pods</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Before we start digging in, we need to understand how containers and <strong>Pods</strong> are
related. We will not be covering the background on these technologies in this lab but if you have questions please inform the instructor. Instead, we will dive right in and start using them.</p>
</div>
<div class="paragraph">
<p>In OpenShift, the smallest deployable unit is a <strong>Pod</strong>. A <strong>Pod</strong> is a group of one or more OCI containers deployed together and guaranteed to be on the same host.
From the official OpenShift documentation:</p>
</div>
<div class="quoteblock">
<blockquote>
<em>
Each <strong>Pod</strong> has its own IP address, therefore owning its entire port space, and
containers within pods can share storage. <strong>Pods</strong> can be "tagged" with one or
more labels, which are then used to select and manage groups of <strong>pods</strong> in a
single operation.
</em>
</blockquote>
</div>
<div class="paragraph">
<p><strong>Pods</strong> can contain multiple OCI containers. The general idea is for a <strong>Pod</strong> to
contain a "main process" and any auxiliary services you want to run along with that process. Examples of containers you might put in a <strong>Pod</strong> are, an Apache HTTPD
server, a log analyzer, and a file service to help manage uploaded files.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_exercise_examining_the_pod">Exercise: Examining the Pod</h2>
<div class="sectionbody">
<div class="paragraph">
<p>If you click on the <code>parksmap</code> entry in the Topology view, you will see some information about that deployment config. The <strong>Resources</strong> tab may be displayed by default. If so, click on the <strong>Details</strong> tab. On that panel, you will see that there is a single <strong>Pod</strong> that was created by your actions.</p>
</div>
<div class="imageblock">
<div class="content">
<img src="images/parksmap-overview.png" alt="Pod overview">
</div>
</div>
<div class="paragraph">
<p>You can also get a list of all the <strong>Pods</strong> created within your <strong>Project</strong>, by navigating to <strong>Workloads → Pods</strong> in the Administrator perspective of the web console.</p>
</div>
<div class="imageblock">
<div class="content">
<img src="images/parksmap-podlist.png" alt="Pod list">
</div>
</div>
<div class="paragraph">
<p>This <strong>Pod</strong> contains a single container, which
happens to be the <code>parksmap</code> application - a simple Spring Boot/Java application.</p>
</div>
<div class="paragraph">
<p>You can also examine <strong>Pods</strong> from the command line:</p>
</div>
<div class="listingblock execute-1">
<div class="content">
<pre class="highlight"><code class="language-bash" data-lang="bash">oc get pods</code></pre>
</div>
</div>
<div class="paragraph">
<p>You should see output that looks similar to:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-text" data-lang="text">NAME READY STATUS RESTARTS AGE
parksmap-65c4f8b676-k5gkk 1/1 Running 0 20s</code></pre>
</div>
</div>
<div class="paragraph">
<p>The above output lists all of the <strong>Pods</strong> in the current <strong>Project</strong>, including the
<strong>Pod</strong> name, state, restarts, and uptime. Once you have a <strong>Pod</strong>'s name, you can
get more information about the <strong>Pod</strong> using the <code>oc get</code> command. To make the
output readable, I suggest changing the output type to <strong>YAML</strong> using the
following syntax:</p>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<div class="title">Note</div>
</td>
<td class="content">
Make sure you use the correct <strong>Pod</strong> name from your output.
</td>
</tr>
</table>
</div>
<div class="listingblock copy-and-edit">
<div class="content">
<pre class="highlight"><code class="language-bash" data-lang="bash">oc get pod parksmap-65c4f8b676-k5gkk -o yaml</code></pre>
</div>
</div>
<div class="paragraph">
<p>You should see something like the following output (which has been truncated due
to space considerations of this workshop manual):</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-text" data-lang="text">apiVersion: v1
kind: Pod
metadata:
annotations:
k8s.v1.cni.cncf.io/network-status: |-
[{
"name": "",
"interface": "eth0",
"ips": [
"10.131.0.93"
],
"default": true,
"dns": {}
}]
k8s.v1.cni.cncf.io/networks-status: |-
[{
"name": "",
"interface": "eth0",
"ips": [
"10.131.0.93"
],
"default": true,
"dns": {}
}]
openshift.io/generated-by: OpenShiftWebConsole
openshift.io/scc: restricted
creationTimestamp: "2021-01-05T17:00:32Z"
generateName: parksmap-65c4f8b676-
labels:
app: parksmap
component: parksmap
deploymentconfig: parksmap
pod-template-hash: 65c4f8b676
role: frontend
...............</code></pre>
</div>
</div>
<div class="paragraph">
<p>The web interface also shows a lot of the same information on the <strong>Pod</strong> details
page. If you click on the name of the <strong>Pod</strong>, you will
find the details page. You can also get there by clicking on the <code>parksmap</code> deployment config on the <strong>Topology</strong> page, selecting <strong>Resources</strong>, and then clicking the <strong>Pod</strong> name.</p>
</div>
<div class="imageblock">
<div class="content">
<img src="images/parksmap-dc-resources.png" alt="Parksmap Resources">
</div>
</div>
<div class="imageblock">
<div class="content">
<img src="images/parksmap-pod.png" alt="Pod list">
</div>
</div>
<div class="paragraph">
<p>Getting the <code>parksmap</code> image running may take a little while to complete. Each
OpenShift node that is asked to run the image has to pull (download) it, if the
node does not already have it cached locally. You can check on the status of the
image download and deployment in the <strong>Pod</strong> details page, or from the command
line with the <code>oc get pods</code> command that you used before.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_background_customizing_the_image_lifecycle_behavior">Background: Customizing the Image Lifecycle Behavior</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Whenever OpenShift asks the node’s CRI (Container Runtime Interface) runtime (Docker daemon or CRI-O) to run an image, the runtime will check to make sure it has the right "version" of the image to run.
If it doesn’t, it will pull it from the specified registry.</p>
</div>
<div class="paragraph">
<p>There are a number of ways to customize this behavior. They are documented in
<a href="https://docs.openshift.com/container-platform/latest/applications/application_life_cycle_management/creating-applications-using-cli.html#applications-create-using-cli-image_creating-applications-using-cli">specifying an image</a>
as well as
<a href="https://docs.openshift.com/container-platform/latest/openshift_images/managing_images/image-pull-policy.html">image pull policy</a>.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_background_services">Background: Services</h2>
<div class="sectionbody">
<div class="paragraph">
<p><strong>Services</strong> provide a convenient abstraction layer inside OpenShift to find a
group of similar <strong>Pods</strong>. They also act as an internal proxy/load balancer between
those <strong>Pods</strong> and anything else that needs to access them from inside the
OpenShift environment. For example, if you needed more <code>parksmap</code> instances to
handle the load, you could spin up more <strong>Pods</strong>. OpenShift automatically maps
them as endpoints to the <strong>Service</strong>, and the incoming requests would not notice
anything different except that the <strong>Service</strong> was now doing a better job handling
the requests.</p>
</div>
<div class="paragraph">
<p>When you asked OpenShift to run the image, it automatically created a <strong>Service</strong>
for you. Remember that services are an internal construct. They are not
available to the "outside world", or anything that is outside the OpenShift
environment. That’s okay, as you will learn later.</p>
</div>
<div class="paragraph">
<p>The way that a <strong>Service</strong> maps to a set of <strong>Pods</strong> is via a system of <strong>Labels</strong> and
<strong>Selectors</strong>. <strong>Services</strong> are assigned a fixed IP address and many ports and
protocols can be mapped.</p>
</div>
<div class="paragraph">
<p>There is a lot more information about
<a href="https://docs.openshift.com/container-platform/latest/architecture/understanding-development.html#understanding-kubernetes-pods">Services</a>,
including the YAML format to make one by hand, in the official documentation.</p>
</div>
<div class="paragraph">
<p>Now that we understand the basics of what a <strong>Service</strong> is, let’s take a look at
the <strong>Service</strong> that was created for the image that we just deployed. In order to
view the <strong>Services</strong> defined in your <strong>Project</strong>, enter in the following command:</p>
</div>
<div class="listingblock execute-1">
<div class="content">
<pre class="highlight"><code class="language-bash" data-lang="bash">oc get services</code></pre>
</div>
</div>
<div class="paragraph">
<p>You should see output similar to the following:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-bash" data-lang="bash">NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
parksmap ClusterIP 172.30.22.209 <none> 8080/TCP 3h</code></pre>
</div>
</div>
<div class="paragraph">
<p>In the above output, we can see that we have a <strong>Service</strong> named <code>parksmap</code> with an
IP/Port combination of 172.30.22.209/8080TCP. Your IP address may be different, as
each <strong>Service</strong> receives a unique IP address upon creation. <strong>Service</strong> IPs are
fixed and never change for the life of the <strong>Service</strong>.</p>
</div>
<div class="paragraph">
<p>In the Developer perspective from the <strong>Topology</strong> view, service information is available by clicking the <code>parksmap</code> deployment config, then <strong>Resources</strong>, and then you should see the <code>parksmap</code> entry in the <strong>Services</strong> section.</p>
</div>
<div class="imageblock">
<div class="content">
<img src="images/parksmap-serviceslist.png" alt="Services list">
</div>
</div>
<div class="paragraph">
<p>You can also get more detailed information about a <strong>Service</strong> by using the
following command to display the data in YAML:</p>
</div>
<div class="listingblock execute-1">
<div class="content">
<pre class="highlight"><code class="language-bash" data-lang="bash">oc get service parksmap -o yaml</code></pre>
</div>
</div>
<div class="paragraph">
<p>You should see output similar to the following:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-text" data-lang="text">apiVersion: v1
kind: Service
metadata:
annotations:
openshift.io/generated-by: OpenShiftWebConsole
creationTimestamp: "2020-09-30T14:10:12Z"
labels:
app: workshop
app.kubernetes.io/component: parksmap
app.kubernetes.io/instance: parksmap
app.kubernetes.io/part-of: workshop
component: parksmap
role: frontend
name: parksmap
namespace: user1
resourceVersion: "1062269"
selfLink: /api/v1/namespaces/user1/services/parksmap
uid: e1ff69c8-cb2f-11e9-82a1-0267eec7e1a0
spec:
clusterIP: 172.30.22.209
ports:
- name: 8080-tcp
port: 8080
protocol: TCP
targetPort: 8080
selector:
app: parksmap
deploymentconfig: parksmap
sessionAffinity: None
type: ClusterIP
status:
loadBalancer: {}</code></pre>
</div>
</div>
<div class="paragraph">
<p>Take note of the <code>selector</code> stanza. Remember it.</p>
</div>
<div class="paragraph">
<p>Alternatively, you can use the web console to view information about the <strong>Service</strong> by clicking on it from the previous screen.</p>
</div>
<div class="imageblock">
<div class="content">
<img src="images/parksmap-service.png" alt="Service">
</div>
</div>
<div class="paragraph">
<p>It is also of interest to view the YAML of the <strong>Pod</strong> to understand how OpenShift
wires components together. For example, run the following command to get the
name of your <code>parksmap</code> <strong>Pod</strong>:</p>
</div>
<div class="listingblock execute-1">
<div class="content">
<pre class="highlight"><code class="language-bash" data-lang="bash">oc get pods</code></pre>
</div>
</div>
<div class="paragraph">
<p>You should see output similar to the following:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-bash" data-lang="bash">NAME READY STATUS RESTARTS AGE
parksmap-65c4f8b676-k5gkk 1/1 Running 0 5m12s</code></pre>
</div>
</div>
<div class="paragraph">
<p>Now you can view the detailed data for your <strong>Pod</strong> with the following command:</p>
</div>
<div class="listingblock copy-and-edit">
<div class="content">
<pre class="highlight"><code class="language-bash" data-lang="bash">oc get pod parksmap-65c4f8b676-k5gkk -o yaml</code></pre>
</div>
</div>
<div class="paragraph">
<p>Under the <code>metadata</code> section you should see the following:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-bash" data-lang="bash"> labels:
app: parksmap
deploymentconfig: parksmap</code></pre>
</div>
</div>
<div class="ulist">
<ul>
<li>
<p>The <strong>Service</strong> has <code>selector</code> stanza that refers to <code>deploymentconfig=parksmap</code>.</p>
</li>
<li>
<p>The <strong>Pod</strong> has multiple <strong>Labels</strong>:</p>
<div class="ulist">
<ul>
<li>
<p><code>app=parksmap</code></p>
</li>
<li>
<p><code>deploymentconfig=parksmap</code></p>
</li>
</ul>
</div>
</li>
</ul>
</div>
<div class="paragraph">
<p><strong>Labels</strong> are just key/value pairs. Any <strong>Pod</strong> in this <strong>Project</strong> that has a <strong>Label</strong> that
matches the <strong>Selector</strong> will be associated with the <strong>Service</strong>. To see this in
action, issue the following command:</p>
</div>
<div class="listingblock execute-1">
<div class="content">
<pre class="highlight"><code class="language-bash" data-lang="bash">oc describe service parksmap</code></pre>
</div>
</div>
<div class="paragraph">
<p>You should see something like the following output:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-text" data-lang="text">Name: parksmap
Namespace: user1
Labels: app=workshop
app.kubernetes.io/component=parksmap
app.kubernetes.io/instance=parksmap
app.kubernetes.io/part-of=workshop
component=parksmap
role=frontend
Annotations: openshift.io/generated-by: OpenShiftWebConsole
Selector: app=parksmap,deploymentconfig=parksmap
Type: ClusterIP
IP: 172.30.22.209
Port: 8080-tcp 8080/TCP
TargetPort: 8080/TCP
Endpoints: 10.128.2.90:8080
Session Affinity: None
Events: <none></code></pre>
</div>
</div>
<div class="paragraph">
<p>You may be wondering why only one endpoint is listed. That is because there is
only one <strong>Pod</strong> currently running. In the next lab, we will learn how to scale
an application, at which point you will be able to see multiple endpoints
associated with the <strong>Service</strong>.</p>
</div>
</div>
</div>
<!-- Bottom Navigation -->
<div class="page-meta clearfix">
<input type="button" class="btn btn-lg btn-primary float-right" onclick="location.href='parksmap-scaling';" value="Continue" />
</div>
</section>
</div>
</div>
</div>
<!-- Footer -->
<footer class="footer">
</footer>
<!-- Javascript-->
<script src="js/workshop.js"></script>
<script src="js/workshop-asciidoc.js"></script>
</body>
</html>