-
Notifications
You must be signed in to change notification settings - Fork 0
/
nationalparks-java-databases.html
678 lines (602 loc) · 26.2 KB
/
nationalparks-java-databases.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
<!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"><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 active"><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='nationalparks-java';" 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='nationalparks-java-application-health';" 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">Adding a Database (MongoDB)</h1>
<!-- Content -->
<div class="paragraph">
<p>In this section we will deploy and connect a MongoDB database where the
<code>nationalparks</code> application will store location information.</p>
</div>
<div class="paragraph">
<p>Finally, we will mark the <code>nationalparks</code> application as a backend for the map
visualization tool, so that it can be dynamically discovered by the <code>parksmap</code>
component using the OpenShift discovery mechanism and the map will be displayed
automatically.</p>
</div>
<div class="imageblock text-center">
<div class="content">
<img src="images/roadshow-app-architecture-nationalparks-2.png" alt="Application architecture" width="800">
</div>
</div>
<div class="sect1">
<h2 id="_background_storage">Background: Storage</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Most useful applications are "stateful" or "dynamic" in some way, and this is
usually achieved with a database or other data storage. In this lab we are
going to add MongoDB to our <code>nationalparks</code> application and then rewire it to
talk to the database using environment variables via a secret.</p>
</div>
<div class="paragraph">
<p>We are going to use the MongoDB image that is included with OpenShift.</p>
</div>
<div class="paragraph">
<p>By default, this will use <strong>EmptyDir</strong> for data storage, which means if the <strong>Pod</strong>
disappears the data does as well. In a real application you would use
OpenShift’s persistent storage mechanism to attach real-world storage (NFS,
Ceph, EBS, iSCSI, etc) to the <strong>Pods</strong> to give them a persistent place to store their data.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_background_templates">Background: Templates</h2>
<div class="sectionbody">
<div class="paragraph">
<p>In this module we will create MongoDB from a <strong>Template</strong>, which is useful mechanism in OpenShift to define parameters for certain values, such as
DB username or password, that can be automatically generated by OpenShift at
processing time.</p>
</div>
<div class="paragraph">
<p>Administrators can load <strong>Templates</strong> into OpenShift and make them available to
all users. Users can create <strong>Templates</strong> and load them
into their own <strong>Projects</strong> for other users (with access) to share and use.</p>
</div>
<div class="paragraph">
<p>The great thing about <strong>Templates</strong> is that they can speed up the deployment
workflow for application development by providing a "recipe" of sorts that can
be deployed with a single command. Not only that, they can be loaded into
OpenShift from an external URL, which will allow you to keep your templates in a
version control system.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_exercise_instantiate_a_mongodb_template">Exercise: Instantiate a MongoDB Template</h2>
<div class="sectionbody">
<div class="paragraph">
<p>In this step we will create a MongoDB template inside our project, so that is only visible to our user and we can access it from Developer Perspective to create a MongoDB instance.</p>
</div>
<div class="listingblock execute-1">
<div class="content">
<pre class="highlight"><code class="language-bash" data-lang="bash">oc create -f https://raw.githubusercontent.com/openshift-labs/starter-guides/ocp-4.6/mongodb-template.yaml -n user3</code></pre>
</div>
</div>
<div class="paragraph">
<p>What just happened? What did you just <code>create</code>? The item that we passed to the <code>create</code>
command is a <strong>Template</strong>. <code>create</code> simply makes the template available in
your <strong>Project</strong>.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_exercise_deploy_mongodb">Exercise: Deploy MongoDB</h2>
<div class="sectionbody">
<div class="paragraph">
<p>As you’ve seen so far, the web console makes it very easy to deploy things onto
OpenShift. When we deploy the database, we pass in some values for configuration.
These values are used to set the username, password, and name of
the database.</p>
</div>
<div class="paragraph">
<p>The database image is built in a way that it will automatically configure itself
using the supplied information (assuming there is no data already present in the
persistent storage!). The image will ensure that:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>A database exists with the specified name</p>
</li>
<li>
<p>A user exists with the specified name</p>
</li>
<li>
<p>The user can access the specified database with the specified password</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>In the Developer Perspective in your <code>user3</code> project,
click <strong>+Add</strong> and then <strong>Database</strong>. In the Databases view, you can click <strong>Mongo</strong> to filter for just MongoDB.</p>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<div class="title">Note</div>
</td>
<td class="content">
Make sure to uncheck <strong>Operator Backed</strong> option from <strong>Type</strong> section
</td>
</tr>
</table>
</div>
<div class="imageblock">
<div class="content">
<img src="images/nationalparks-databases-catalog-databases.png" alt="Data Stores">
</div>
</div>
<div class="paragraph">
<p>Alternatively, you could type <code>mongodb</code> in the search box. Once you have drilled down to see MongoDB, find the <strong>MongoDB (Ephemeral)</strong> template and select it. You will notice that there are multiple
MongoDB templates available. We do not need a database with persistent storage, so the ephemeral Mongo
template is what you should choose. Go ahead and select the ephemeral template and click the <strong>Instantiate Template</strong> button.</p>
</div>
<div class="paragraph">
<p>When we performed the application build, there was no template. Rather, we selected the
builder image directly and OpenShift presented only the standard build workflow.
Now we are using a template - a preconfigured set of resources that includes
parameters that can be customized. In our case, the parameters we are concerned
with are — user, password, database, and
admin password.</p>
</div>
<div class="imageblock">
<div class="content">
<img src="images/nationalparks-databases-catalog-databases-mongodb-config.png" alt="MongoDB Deploy">
</div>
</div>
<div class="admonitionblock caution">
<table>
<tr>
<td class="icon">
<div class="title">Caution</div>
</td>
<td class="content">
Make sure you name your database service name <strong>mongodb-nationalparks</strong>
</td>
</tr>
</table>
</div>
<div class="paragraph">
<p>You can see that some of the fields say <strong>"generated if empty"</strong>. This is a
feature of <strong>Templates</strong> in OpenShift. For
now, be sure to use the following values in their respective fields:</p>
</div>
<div class="ulist">
<ul>
<li>
<p><code>Database Service Name</code> : <code>mongodb-nationalparks</code></p>
</li>
<li>
<p><code>MongoDB Connection Username</code> : <code>mongodb</code></p>
</li>
<li>
<p><code>MongoDB Connection Password</code> : <code>mongodb</code></p>
</li>
<li>
<p><code>MongoDB Database Name</code>: <code>mongodb</code></p>
</li>
<li>
<p><code>MongoDB Admin Password</code> : <code>mongodb</code></p>
</li>
</ul>
</div>
<div class="admonitionblock caution">
<table>
<tr>
<td class="icon">
<div class="title">Caution</div>
</td>
<td class="content">
Make sure to have configured the <strong><code>MongoDB Database Name</code></strong> parameter with the appropriate value as by default it will already have a value of <code>sampledb</code>.
</td>
</tr>
</table>
</div>
<div class="paragraph">
<p>Once you have entered in the above information, click on <strong>Create</strong> to go to the next step which will allow us to add a binding.</p>
</div>
<div class="paragraph">
<p>From left-side menu, click to <strong>Secrets</strong>.</p>
</div>
<div class="imageblock">
<div class="content">
<img src="images/nationalparks-databases-list-secrets.png" alt="List Secrets">
</div>
</div>
<div class="paragraph">
<p>Click the secret name listed that we will use for <strong>Parameters</strong>. The secret can be used in other components, such as the <code>nationalparks</code> backend, to authenticate to the database.</p>
</div>
<div class="paragraph">
<p>Now that the connection and authentication information stored in a secret in our project, we need to add it to the <code>nationalparks</code> backend. Click the <strong>Add Secret to Workload</strong> button.</p>
</div>
<div class="imageblock">
<div class="content">
<img src="images/nationalparks-databases-binding-view-secret.png" alt="National Parks Binding">
</div>
</div>
<div class="paragraph">
<p>Select the <code>nationalparks</code> workload and click <strong>Save</strong>.</p>
</div>
<div class="imageblock">
<div class="content">
<img src="images/nationalparks-databases-binding-add-binding-to-nationalparks.png" alt="Add binding to application">
</div>
</div>
<div class="paragraph">
<p>This change in configuration will trigger a new deployment of the <code>nationalparks</code> application with the environment variables properly injected.</p>
</div>
<div class="paragraph">
<p>Back in the <strong>Topology</strong> view, click and drag with Shift key the <code>mongodb-nationalparks</code> component into the light gray area that denotes the <code>workshop</code> application, so that all three components are contained in it.</p>
</div>
<div class="imageblock">
<div class="content">
<img src="images/nationalparks-databases-add-mongodb-to-workshop-app.png" alt="Add mongodb to the workshop app">
</div>
</div>
<div class="paragraph">
<p>Next, let’s fix the labels assigned to the <code>mongodb-nationalparks</code> deployment. Currently, we cannot set labels when using the database template from the catalog, so we will fix these labels manually.</p>
</div>
<div class="paragraph">
<p>Like before, we’ll add 3 labels:</p>
</div>
<div class="paragraph">
<p>The name of the Application group:</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=nationalparks</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=database</code></pre>
</div>
</div>
<div class="paragraph">
<p>Execute the following command:</p>
</div>
<div class="listingblock execute-1">
<div class="content">
<pre class="highlight"><code class="language-bash" data-lang="bash">oc label dc/mongodb-nationalparks svc/mongodb-nationalparks app=workshop component=nationalparks role=database --overwrite</code></pre>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_exercise_exploring_openshift_magic">Exercise: Exploring OpenShift Magic</h2>
<div class="sectionbody">
<div class="paragraph">
<p>As soon as we attached the Secret to the <strong>Deployment</strong>, some
magic happened. OpenShift decided that this was a significant enough change to
warrant updating the internal version number of the <strong>ReplicaSet</strong>. You
can verify this by looking at the output of <code>oc get rs</code>:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-bash" data-lang="bash">NAME DESIRED CURRENT READY AGE
nationalparks-58bd4758fc 0 0 0 4m58s
nationalparks-7445576cd9 0 0 0 6m42s
nationalparks-789c6bc4f4 1 1 1 41s
parksmap-57df75c46d 1 1 1 8m24s
parksmap-65c4f8b676 0 0 0 18m</code></pre>
</div>
</div>
<div class="paragraph">
<p>We see that the DESIRED and CURRENT number of instances for the current deployment. The desired and current number of the other instances are 0.
This means that OpenShift has gracefully torn down our "old" application and
stood up a "new" instance.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_exercise_data_data_everywhere">Exercise: Data, Data, Everywhere</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Now that we have a database deployed, we can again visit the <code>nationalparks</code> web
service to query for data:</p>
</div>
<div class="listingblock copypaste">
<div class="content">
<pre class="highlight"><code class="language-bash" data-lang="bash">http://nationalparks-user3.apps.cluster-test-efcf.test-efcf.example.opentlc.com/ws/data/all</code></pre>
</div>
</div>
<div class="paragraph">
<p>And the result?</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-bash" data-lang="bash">[]</code></pre>
</div>
</div>
<div class="paragraph">
<p>Where’s the data? Think about the process you went through. You deployed the
application and then deployed the database. Nothing actually loaded anything
<strong>INTO</strong> the database, though.</p>
</div>
<div class="paragraph">
<p>The application provides an endpoint to do just that:</p>
</div>
<div class="listingblock copypaste">
<div class="content">
<pre class="highlight"><code class="language-bash" data-lang="bash">http://nationalparks-user3.apps.cluster-test-efcf.test-efcf.example.opentlc.com/ws/data/load</code></pre>
</div>
</div>
<div class="paragraph">
<p>And the result?</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-bash" data-lang="bash">Items inserted in database: 2893</code></pre>
</div>
</div>
<div class="paragraph">
<p>If you then go back to <code>/ws/data/all</code> you will see tons of JSON data now.
That’s great. Our parks map should finally work!</p>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<div class="title">Note</div>
</td>
<td class="content">
There are some errors reported with browsers like Firefox 54 that don’t properly parse the resulting JSON. It’s
a browser problem, and the application is working properly.
</td>
</tr>
</table>
</div>
<div class="listingblock copypaste">
<div class="content">
<pre class="highlight"><code class="language-bash" data-lang="bash">https://parksmap-user3.apps.cluster-test-efcf.test-efcf.example.opentlc.com</code></pre>
</div>
</div>
<div class="paragraph">
<p>Hmm…​ There’s just one thing. The main map <strong>STILL</strong> isn’t displaying the parks.
That’s because the front end parks map only tries to talk to services that have
the right <strong>Label</strong>.</p>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<div class="title">Note</div>
</td>
<td class="content">
<div class="paragraph">
<p>You are probably wondering how the database connection magically started
working? When deploying applications to OpenShift, it is always best to use
environment variables, secrets, or configMaps to define connections to dependent systems. This allows
for application portability across different environments. The source file that
performs the connection as well as creates the database schema can be viewed
here:</p>
</div>
<div class="listingblock copypaste">
<div class="content">
<pre class="highlight"><code class="language-bash" data-lang="bash">http://www.github.com/openshift-roadshow/nationalparks/blob/master/src/main/java/com/openshift/evg/roadshow/parks/db/MongoDBConnection.java#L44-l48</code></pre>
</div>
</div>
<div class="paragraph">
<p>In short summary: By referring to bindings to connect to services
(like databases), it can be trivial to promote applications throughout different
lifecycle environments on OpenShift without having to modify application code.</p>
</div>
</td>
</tr>
</table>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_exercise_working_with_labels">Exercise: Working With Labels</h2>
<div class="sectionbody">
<div class="paragraph">
<p>We explored how a <strong>Label</strong> is just a key=value pair earlier when looking at
<strong>Services</strong> and <strong>Routes</strong> and <strong>Selectors</strong>. In general, a <strong>Label</strong> is simply an
arbitrary key=value pair. It could be anything.</p>
</div>
<div class="ulist">
<ul>
<li>
<p><code>pizza=pepperoni</code></p>
</li>
<li>
<p><code>pet=dog</code></p>
</li>
<li>
<p><code>openshift=awesome</code></p>
</li>
</ul>
</div>
<div class="paragraph">
<p>In the case of the parks map, the application is actually querying the OpenShift
API and asking about the <strong>Routes</strong> and <strong>Services</strong> in the project. If any of them have a
<strong>Label</strong> that is <code>type=parksmap-backend</code>, the application knows to interrogate
the endpoints to look for map data.
You can see the code that does this
<a href="https://github.com/openshift-roadshow/parksmap-web/blob/latest/src/main/java/com/openshift/evg/roadshow/rest/RouteWatcher.java#L20">here</a>.</p>
</div>
<div class="paragraph">
<p>Fortunately, the command line provides a convenient way for us to manipulate
labels. <code>describe</code> the <code>nationalparks</code> service:</p>
</div>
<div class="listingblock execute-1">
<div class="content">
<pre class="highlight"><code class="language-bash" data-lang="bash">oc describe route nationalparks</code></pre>
</div>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-bash" data-lang="bash">Name: nationalparks
Namespace: user3
Created: 2 hours ago
Labels: app=workshop
app.kubernetes.io/component=nationalparks
app.kubernetes.io/instance=nationalparks
app.kubernetes.io/name=nodejs
app.kubernetes.io/part-of=workshop
app.openshift.io/runtime=nodejs
app.openshift.io/runtime-version=10
component=nationalparks
role=backend
Annotations: openshift.io/host.generated=true
Requested Host: nationalparks-user3.apps.cluster-test-efcf.test-efcf.example.opentlc.com
exposed on router router 2 hours ago
Path: <none>
TLS Termination: <none>
Insecure Policy: <none>
Endpoint Port: 8080-tcp
Service: nationalparks
Weight: 100 (100%)
Endpoints: 10.1.9.8:8080</code></pre>
</div>
</div>
<div class="paragraph">
<p>You see that it already has some labels. Now, use <code>oc label</code>:</p>
</div>
<div class="listingblock execute-1">
<div class="content">
<pre class="highlight"><code class="language-bash" data-lang="bash">oc label route nationalparks type=parksmap-backend</code></pre>
</div>
</div>
<div class="paragraph">
<p>You will see something like:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-bash" data-lang="bash">route.route.openshift.io/nationalparks labeled</code></pre>
</div>
</div>
<div class="paragraph">
<p>If you check your browser now:</p>
</div>
<div class="listingblock copypaste">
<div class="content">
<pre class="highlight"><code class="language-bash" data-lang="bash">https://parksmap-user3.apps.cluster-test-efcf.test-efcf.example.opentlc.com/</code></pre>
</div>
</div>
<div class="imageblock">
<div class="content">
<img src="images/nationalparks-databases-new-parks.png" alt="MongoDB">
</div>
</div>
<div class="paragraph">
<p>You’ll notice that the parks suddenly are showing up. That’s really cool!</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='nationalparks-java-application-health';" 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>