lab-tekton-pipelines icon indicating copy to clipboard operation
lab-tekton-pipelines copied to clipboard

Add Task to Deploy MongoDB Database for nodejs Sample App

Open danielhelfand opened this issue 5 years ago • 2 comments

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.

danielhelfand avatar Aug 15 '19 21:08 danielhelfand

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.

danielhelfand avatar Aug 26 '19 14:08 danielhelfand

This can be accomplished by doing the following:

  1. 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.

  1. Set the MONGO_URL environment variable to the ip of the deployed MongoDB database

danielhelfand avatar Aug 28 '19 19:08 danielhelfand