Lab 4.6: Update the Application Build Project and Deploy to Production

Keyboard Time: 20 mins, Automation Wait Time: 5 mins

Scenarios: Instructor-Led, Self-Paced

In this Lab you will update the background color of the application and track the progress of the automation through both repositories and both environments.

Target Outcomes

Observe an end-to-end application change:

  1. Update the background color of the application

  2. Track the progress of the automation through the Application Build project and

  3. Through both environments of the Environment Deployment project using the background page color.

  1. Open ‘yourpersonalgroup/hello-world’

  2. In the left navigation, Click Repository => Files

  3. On the upper right of the Project page, Click Web IDE

  4. Navigate to the file src/microwebserver.py

  5. Around line 11, locate the text <BODY style="background:lightsalmon">

  6. Change the color after the word background: to lightgreen

    Result: <BODY style="background:lightgreen">

    If you need a different color, other available color values are listed here

  7. Click Create commit…

  8. Select Commit to main branch (not selected by default)

  9. Click Commit

  10. In the very bottom left, immediately after the text ‘Pipeline’ Click [the pipeline number which is preceeded with a #]

  11. [Automation wait: ~2 min] Wait for the pipeline to complete.

  12. Click Packages & Registries => Container Registry

  13. Click [the line ending in ‘/main’]

  14. Scan for the latest-prod tag

    It should have been built moments ago. There should also be a new version tag with the same value for ‘Digest’

    Accomplished Outcome
    You just observed the automatic creation of a new production ready container based on the normal development activity of changing the application files.
  15. Open ‘yourpersonalgroup/world-greetings-env-1’ project.

  16. Click CI/CD => Schedules

  17. On the right side of schedule called ‘CheckForNewContainerVersion’, Click [the play button]

    If the schedule is missing, simply Click CI/CD => Pipelines => Run Pipeline = and then => Run Pipeline

  18. On the left navigation, Click CI/CD => Pipelines

  19. Open the most recent non-skipped pipeline by clicking [the pipeline Status badge] or [the pipeline #]

  20. Expand the Downstream pipeline - next to the deploy job, Click [the small right arrow]

  21. [Automation wait: ~3 min] Wait for the ‘update-staging-manifests’ job to complete successfully.

  22. In the pipeline, Click update-staging-manifests

  23. Search the job log (manually or with your brower’s ‘in page search’ feature) for the text “Changes to be committed” (near the bottom)

    Observation
    This job only did a commit back to the World Greetings Environment 1 project - it did not do any CD push operations. Since we are also using CI processes in this workshop it can be easy to mistakenly think this job pushed the changes, rather than the GitLab Agent in the cluster pulling them.
  24. In the left navigation, Click Repository => Files

  25. In the main page body, in the files and directories list, Click manifests

  26. Click hello-world.staging.yaml

  27. Find - image:

  28. Note the version number at the very end of the image string should match the image registry version you just saw. Keep this version in mind so you can compare to production in the next steps .

  29. Click [the browers back button]

  30. Click hello-world.production.yaml

  31. Find - image:

    Tip
    The version differences between the current state of these two manifests is what explains the results you will see when viewing the active environments in the next steps.
  32. Click Deployments => Environments

  33. [Automation wait: ~3 min] Keep refreshing until staging deployment activities complete.

    Warning
    For all GitOps mode projects, when the deployment shows complete in the Environments page, it only means the manifests are completely setup, the Gitlab Agent for Kubernetes still has to find and deploy the changed manifests.
    Warning

    If you are in an instructor-led workshop, the instructor may need to access the cluster for you. If you were to run into unusual deployment problems, you would need to login to the Kubernetes Cluster and run the below command. To do this, login to the EKS Bastion host the same was as was done in “Prep Lab 2.3: Use GitLab K8s Agent to Integrate The Cluster with GitLab” to install the GitLab Agent. Then run this command kubectl logs -f -l=app=gitlab-agent -n gitlab-agent

    For common errors and more troubleshooting information visit Troubleshooting the GitLab agent for Kubernetes

  34. On the ‘staging’ line, to the right, Click Open

    You should see that the staging environment is now the new color.

  35. To approve the production deployment, in the left navigation, Click CI/CD => Pipelines

  36. Open the most recent non-skipped pipeline by clicking [the pipeline Status badge] or [the pipeline #]

  37. Next to the deploy job, Click [the small right arrow]

  38. Locate the update-production-manifests job

You may have to horizontally scroll right to see this final job.

  1. Click [the play button in a circle]

  2. [Automation wait: ~3 min] Keep refreshing until production deployment activities complete.

    Warning
    For all GitOps mode projects, when the deployment shows complete in the Environments page, it only means the manifests are completely setup, the Gitlab Agent for Kubernetes still has to find and deploy the changed manifests.
  3. Click Deployments => Environments

  4. [Automation wait: ~3 min] Keep refreshing until staging deployment activities complete.

  5. On the ‘production’’ line, to the right, Click Open

    Observation
    You should see that the production environment is now the new color.
Tip
While it is not necessarily easy to observe directly from GitLab, it is the GitLab Agent that is pulling the changes into the cluster. You can understand more about this flow by examining the box ‘GitLab K8s Agent Channel’ in the GitLab K8s Agent Connections and Flows diagram.
Accomplished Outcomes
  1. Update the background color of the application

  2. Track the progress of the automation through the Application Build project and

  3. Through both environments of the Environment Deployment project using the background page color.