Skip to content

Deploy an Application using CI Pipelines with Tekton

  1. Prerequisites

  2. Instructor will provide the following info:

    • OpenShift Console URL (OCP_CONSOLE_URL)
    • The username and password for OpenShift and Git Server (default values are user1, user2, etc.. for users and password for password).
  3. Set TOOLKIT_USERNAME environment variable. If you are participation in a workshop replace userdemo with your assigned username (ex. user01).

    TOOLKIT_USERNAME=userdemo
    

  4. (Skip if using KubeAdmin or IBM Cloud) Login to OpenShift using oc

    • If using IBM Cloud cluster then login with your IBM account email and IAM API Key or Token by using the Copy Login Command Login
    • If using a cluster that was configured with the workshop scripts outside IBM Cloud then use respective assigned username (ex. user01), and the password is password
      oc login $OCP_URL -u $TOOLKIT_USERNAME -p password
      
  5. Set TOOLKIT_PROJECT environment variable If you are participation in a workshop replace projectdemo based on your assigned username (ex. project01).

    TOOLKIT_PROJECT=projectdemo
    

  6. Create a project/namespace using your project as prefix, and -dev and suffix

    oc sync $TOOLKIT_PROJECT-dev
    
  7. Fork application template git repo

    • Open Developer Dashboard from the OpenShift Console Developer Dashboard
    • Select Starter Kits Starter Kits
    • Select One in our case Go Gin Microservice
    • Click Fork
    • Login into GIT Sever using the provided username and password (ie userdemo and password)
    • Click Fork Repository
  8. Setup environment variable GIT_URL for the git url using the value from previous step or as following

    GIT_REPO=go-gin
    GIT_URL=http://${TOOLKIT_USERNAME}:password@$(oc get route -n tools gogs --template='{{.spec.host}}')/${TOOLKIT_USERNAME}/${GIT_REPO}
    echo GIT_URL=${GIT_URL}
    

  9. Clone the git repository and change directory

    cd $HOME
    git clone $GIT_URL app
    cd app
    

  10. Create a pipeline for the application

    oc pipeline --tekton
    

    • Use down/up arrow and select ibm-golang
    • Hit Enter to enable image scanning
    • Open the url to see the pipeline running in the OpenShift Console
  11. Verify that Pipeline Run completed successfully

    • On the OpenShift web console select Pipelines
    • At the top of the page select your development project/namespace created above (ex. project01-dev)
    • The app pipeline last run status should be Succeeded Pipeline Run
  12. Review the Pipeline Tasks/Stages.

    • Click on the last run Last pipeline run
    • Click on the Test task and view the logs Test task
    • Open SonarQube from Console Link
    • Open Registry from Console Link
    • Open Artifactory from Console Link
  13. The gitops step of the pipeline triggers Argo CD to deploy the app to QA. Select Developer perspective, select project $TOOLKIT_PROJECT-qa and then select Topology from the Console and verify the application running Last pipeline run

  14. Open the application route url and try out the application using the swagger UI

  15. Make a change to the application in the git repository and see the pipeline running again from the Console.

    git config --local user.email "${TOOLKIT_USERNAME}@example.com"
    git config --local user.name "${TOOLKIT_USERNAME}"
    echo "A change to trigger a new PipelineRun $(date)" >> README.md
    git add .
    git commit -m "update readme"
    git push -u origin master
    
  16. Verify that change in Git Server and Git WebHook

    • Open Git Dev from Console Link
    • Navigate to user app git repository
    • Review the recent commit
    • Review the webhook recent delivery webhook
  17. Verify that a new Pipeline starts successfully

  18. Verify that the App manifests are being updated in the gitops repo in the git account toolkit under the qa directory.

    • Open Git Ops from Console Link
    • Select toolkit/gitops git repository gitops
  19. Congratulations you finished this lab, continue with lab Promote an Application using CD with GitOps and ArgoCD