lab-tekton-pipelines
lab-tekton-pipelines copied to clipboard
Add Task to Deploy MongoDB Database for nodejs Sample App
The sample app used in this workshop uses a MongoDB database as a way to track the page views of the application.
This is an opportunity to add a task
that would run in parallel to other tasks
as part of the pipeline
used in the workshop. The goal would be to have a new task
for deploying a MongoDB database with the appropriate environment variables set as described here.
This database deploy step would run alongside the build task
of the pipeline
and also make the deployed sample app more interesting.
This step should be able to be run conditionally. Tekton does support conditional tasks. Not sure how this would work with tkn
at this point, and there may need to be an option added to the CLI that would allow a pipelinerun
to be triggered that specifies if a conditional task should be run.
This can be accomplished by doing the following:
- Add this
task
to the deploy-pipeline:
- name: deploy-mongo
taskRef:
name: openshift-client
params:
- name: ARGS
value: "new-app centos/mongodb-36-centos7 -e MONGODB_USER=admin MONGODB_DATABASE=mongo_db MONGODB_PASSWORD=secret MONGODB_ADMIN_PASSWORD=super-secret"
The above task would execute in parallel to the build task
on the deploy-pipeline.
- Set the
MONGO_URL
environment variable to the ip of the deployed MongoDB database