Page
Run your pipeline and evaluate the results
In the previous lesson, you started a workspace and and populated it with tasks. Now you're ready to run your pipeline and observe the results.
In order to get full benefit from taking this lesson, you need:
- A web browser.
In this lesson, you will:
- Create the workspace.
- Create its necessary tasks.
Run your pipeline
It's time to execute your pipeline. Here are the steps.
Execute the following command to run the pipeline:
tkn pipeline start qotd-build-and-deploy -w name=shared-workspace,claimName=source-pvc -p git-url=https://github.com/redhat-developer-demos/qotd.git -p IMAGE=image-registry.openshift-image-registry.svc:5000/<<yourworkspacename>>/qotd:latest
Info alert: You will need to replace
<<yourworkspacename>>
with the name of your OpenShift Sandbox project name that you noted in the Preparing for Run the pipeline section of this activity.Here’s an example of the command that I used:
tkn pipeline start qotd-build-and-deploy -w name=shared-workspace,claimName=source-pvc -p git-url=https://github.com/redhat-developer-demos/qotd.git -p IMAGE=image-registry.openshift-image-registry.svc:5000/rhn-engineering-dschenck-dev/qotd:latest
Two other GitHub repos can be used in the command. You can substitute them if you wish to work with C# or Nodejs.
The pipeline run will be visible in the OpenShift dashboard (Figure 4).
When you started the run at the command line, it immediately returned with a command that you can use to observe your pipeline run from the command line. The command will be very similar to the following results. In order to track the PipelineRun progress, run:
tkn pipelinerun logs qotd-build-and-deploy-run-7wl4v -f -n rhn-engineering-dschenck-dev
- Paste your command into your command line and press Enter to observe the pipeline run from your command line.
You should see a fair amount of activity, while in the background, in the OpenShift dashboard, the progress is displayed at a less granular level.
View the results
Run the following command to get the URL of the service:
oc get route qotd
- Using the URL from the previous command, use the
cURL
command to get a random quote. Substituting your URL as needed, run the following command to see the results:PowerShell
(curl <<route_URL>>/quotes/random).Content
Bash
curl <<route_URL>>/quotes/random
Here are examples:
$ oc get routes qotd NAME HOST/PORT PATH SERVICES PORT TERMINATION WILDCARD qotd qotd-rhn-engineering-dschenck-dev.apps.sandbox-m2.ll9k.p1.openshiftapps.com qotd 10000-tcp None
$ (curl http://qotd-rhn-engineering-dschenck-dev.apps.sandbox-m2.ll9k.p1.openshiftapps.com/quotes/random).Content
{"id":1,"quotation":"Yeah, well, that's just like, your opinion ... man.","author":"The Dude"}
Bonus
- Use a
cURL
endless loop to view your results.PowerShell
While($true) { $(curl http://qotd-rhn-engineering-dschenck-dev.apps.sandbox-m2.ll9k.p1.openshiftapps.com/quotes/random).Content;sleep 1 }
Bash
while $true; do curl http://qotd-rhn-engineering-dschenck-dev.apps.sandbox-m2.ll9k.p1.openshiftapps.com/quotes/random; sleep 1; done;
Developer notes
- The qotd application is written in Go.
Move it, remove it, improve it
Move
If you have another cluster, such as a Red Hat OpenShift Service on AWS instance, you can install the OpenShift Pipelines operator and run this activity there. If you do this, consider creating a project for this activity.
Remove
You can remove all or part of this activity by using one of the following commands:
- To remove only the qotd app:
oc delete all -l learn-pipelines=qotd
- To remove only the pipeline:
oc delete all -l learn-pipelines=pipeline
- To remove only the task:
oc delete all -l learn-pipelines-task
- To remove only the workspace:
oc delete all -l learn-pipelines=workspace
- To remove all of the objects associated with this activity:
oc delete all -l sandbox=learn-pipelines
Improve
The following are ideas to improve this activity:
- Write your qotd app in a different language.
- After building the app using your source code, create an endless loop using
cURL
at the command line to get random quotes. Next, change the source code and re-run the pipeline to see the new version implemented. This is a rolling update. - Add a health check to the deployment.
- Read the quotes from the text file that is stored in a PVC.
Congratulations. Now you know the basics of OpenShift Pipelines. Ready to learn more? Try this Getting Started with OpenShift Pipelines lesson.