Skip to main contentCloud-Native Toolkit

Workshop - Promote an Application using CD with GitOps and ArgoCD

Promote an Application using CD with GitOps and ArgoCD

  1. Prerequisites

  2. Set TOOLKIT_USERNAME environment variable. If you are participation in a workshop replace userdemo with your assigned username (ex. user01).

    TOOLKIT_USERNAME=userdemo
  3. Set TOOLKIT_PROJECT environment variable. If you are participation in a workshop replace projectdemo based on your assigned username (ex. project01).

    TOOLKIT_PROJECT=projectdemo
  4. Verify Application is deployed in QA

    • Select ArgoCD from the Console Link and login using OpenShift login
    • Filter Applications by name ${TOOLKIT_PROJECT}-qa (ie project01-qa)
    • Select the application master-qa-${TOOLKIT_PROJECT}-app (ie master-qa-project01-app) Argo CD App
  5. Verify Application is running in the QA namespace corresponding to your username ${TOOLKIT_PROJECT}-qa

    • Select Developer perspective, select project ${TOOLKIT_PROJECT}-qa and then select Topology from the Console and see the application running Deploy QA
  6. Setup environment variable GIT_OPS_URL for the git url using the value from previous step or as following

    GIT_OPS_URL=http://${TOOLKIT_USERNAME}:password@$(oc get route -n tools gogs --template='{{.spec.host}}')/toolkit/gitops
    echo GIT_OPS_URL=${GIT_OPS_URL}
  7. Clone the git repository and change directory

    cd $HOME
    git clone $GIT_OPS_URL
    cd gitops
  8. Review the qa and staging directory in the git repository

    ls -l qa/
    ls -l staging/
  9. Promote the application from QA to STAGING by copying the app manifest files using git

    git config --local user.email "${TOOLKIT_USERNAME}@example.com"
    git config --local user.name "${TOOLKIT_USERNAME}"
    cp -a qa/${TOOLKIT_PROJECT}/ staging/${TOOLKIT_PROJECT}/
    git add .
    git commit -m "Promote Application from QA to STAGING environment for $TOOLKIT_PROJECT"
    git push -u origin master
  10. Verify Application is deployed in STAGING

    • Select ArgoCD from the Console Link and login using OpenShift login
    • Filter Applications by namespace ${TOOLKIT_PROJECT}-staging (ie project01-staging)
    • It might take a couple minutes for the application to show up
    • Select the application master-staging-${TOOLKIT_PROJECT}-app (ie master-staging-project01-app)
    • Click Refresh Argo CD App staging
  11. Verify Application is running in the STAGING namespace corresponding to your username ${TOOLKIT_PROJECT}

    • Select Developer perspective, select project ${TOOLKIT_PROJECT}-staging and then select Topology from the Console and see the application running Deploy Staging
  12. Propose a change for the Application in STAGING

    • Update the replica count and create a new git branch in remote repo
    cat > staging/${TOOLKIT_PROJECT}/app/values.yaml <<EOF
    global: {}
    app:
    replicaCount: 2
    EOF
    git diff
    git add .
    • Open Git Ops from Console Link
    • Select toolkit/gitops git repository
    • Create a Pull Request
    • Select Pull Request
    • Click New Pull Request
    • Select from compare dropdown the branch ${TOOLKIT_PROJECT}-pr1
    • Enter a title like Update replica count for app in namespace $TOOLKIT_PROJECT
    • Enter a Comment like We need more instances business is growing Yay!
    • click Create Pull Request Pull Request 1
  13. Review the PR follow the change management process established by your team.

    • Click Merge Pull Request
    • Click Delete Branch
  14. Review that application scales out

    • Review in ArgoCD UI, notice there are now two pods, it takes about 4 minutes to sync, you can click Refresh Argo Stagaing 2 pods
    • Review in OpenShift Console, click the Deployment circle details shows 2 Pods. Openshift Stagaing 2 pods
  15. Congratulations you finished this activity, continue with the lab Deploy a 3 tier Microservice using React, Node.js, and Java