The purpose of this repository is to get a sample microservices application comprised of a frontend, a backend, and a database up and running as quickly as possible. Once installed, this sample application can then be used to demonstrate any specific feature/function of OpenShift.
This repository and application are based on the Red Hat OpenShift sample application - Parksmap. Parksmap is a microservices application that displays the location of National Parks on a map.
This application is made up of a frontend with source code here, and a backend with source code here. Detailed instructions with steps to deploy this application via the OpenShift web console can be found here or via the OpenShift CLI here. The YAML files in this repository are simply a snapshot of the application after completing one of these two sets of instructions for ease of deployment with a single oc create
command.
- National Parks Sample OpenShift Application
- OpenShift cluster (amd64, ppc64le, or s390x)
- Ability to create a new project in OpenShift
- Access to the OpenShift command line interface (CLI) or web console
Note: if you want to use the OpenShift web console to deploy the application instead, see the Troubleshooting Section below.
-
Create a new project in OpenShift, for example
national-parks
oc new-project national-parks
-
Deploy the full application (combined frontend and backend)
oc create -f https://raw.githubusercontent.com/mmondics/national-parks/main/yaml/combined/national-parks-combined.yaml
-
Load the backend database with data.
oc exec $(oc get pods -l component=nationalparks | tail -n 1 | awk '{print $1;}') -- curl -s http://localhost:8080/ws/data/load
Note: you should see
"Items inserted in database: 204"
if you did everything right. -
Navigate to your
parksmap
route in a web browser.You can print the URL with the command.
echo "http://$(oc get route parksmap -n national-parks -o=jsonpath='{.spec.host}')"
You should now see the National Parks map with US locations loaded.
Some notable changes from the source repositories include:
- Rebuilt container images to be multiarchitecture (amd64, s390x, ppc64le) rather than solely amd64
- Added new default layer "Outdoors" that is more relevant to a National Parks map
- Added links to relevant National Parks Service website in each location marker
- Added smooth zoom when clicking on map or marker
- Added zoom in/out and "home" buttons to map legend
- Centered map to USA locations
- Included USA parks only (feel free to submit a pull request adding more locations to nationalparks.json. You can use nationalparks-all.json as a source, adding in appropriate links.)
- amd64
- includes OCP local
- s390x
- includes OCP on zCX
- ppc64le
If your OpenShift credential does not have the required role to create a new project, you can use any existing project that you have access to. However, you will need to modify the commands above to reflect the new project name.
If you cannot create a new project and you do not have an existing project, you should reach out to your OpenShift cluster administrator to provide this for you.
Check the status of the pods in the national-parks project: oc get pods -n national-parks
. All 3 pods should be running and say 1/1 are ready.
NAME READY STATUS RESTARTS AGE
mongodb-nationalparks-569d8f967b-vkkgp 1/1 Running 0 72m
nationalparks-6f4b8858d5-wfns2 1/1 Running 0 72m
parksmap-84c87669d7-pf8ps 1/1 Running 0 72m
If any pods are not in this state, you need to investigate and find the source of the error. Some helpful commands will be:
oc get events -n national-parks
oc logs <POD_NAME> -n national-parks
Where you replace <POD_NAME>
with the name of the pod showing errors from oc get pods -n national-parks
.
Yes, delete the national-parks
project, wait a few minutes for the objects to be deleted, then start over from step 1 of the procedure.
oc delete project national-parks
You can deploy this application via the OpenShift web console.
-
Create a new project: Administrator -> Home -> Projects -> New Project
-
Open the Import Yaml page by clicking the button in the top bar of the OpenShift console.
-
Double check that you are in the national-parks project and change into it from the dropdown menu if you are not.
-
Paste the contents of national-parks-combined.yaml into the Import Yaml page and click Create.
-
Navigate to the Developer Topology page (Developer -> Topology)
-
Click the link button associated with the
national-parks
icon -
In the URL for the new page that opens in your browser, add
/ws/data/load
to the end (e.g.http://nationalparks-national-parks.apps.example.com/ws/data/load
)You should see
Welcome to the National Parks data service.
returned in the web browser. -
Back in the Topology Page, click the link associated with the
parksmap
icon
You should now see the National Parks map with US locations loaded.