Lab 4.5: Setup the GitOps CD Pull Agent

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

Scenarios: Instructor-Led, Self-Paced

GitOps Conventions
  1. Monitoring manifests by an agent running in a Kubernetes cluster. This lab configures the GitLab Agent to monitor the manifests in this repository.
Target Outcomes
  1. Configure the Kubernetes Agent to monitor the CI constructed kubernetes manifests.

  2. Observe the initial deployment of staging and production via tailing the Kubernetes Agent log and the appearance of the target environments.

Warning

For instructor-led classes, this portion will be done by the instructor.

If you are not in an instructor-led course, perform the lab as described.

Done By Instructor for Instructor-Led Courses
  1. Logon the cluster administration machine => Instructions for SSM Session Manager for EKS

  2. Run the following command to tail the kubernetes agent log while deployments are happening:

    kubectl logs -f -l=app=gitlab-agent -n gitlab-agent

    Leave this view open as you will be instructed to consult it to see the deployment logging activity when the GItLab Agent pulls and processes the kubernetes manifest.

  3. In a web browser Navigate to classgroup/cluster-management

  4. Near the upper right of the page, Click Web IDE (button)

  5. Navigate to the file .gitlab/agents/spotazuseast2-agent/config.yml

  6. Add the following to the file only once:

    gitops:
      manifest_projects:
       
    
  7. Under “gitops:manifest_projects:” add as below - replacing _classgroup_ and _yourpersonalgroup_ with the actual names for your project. Ensure indenting and “gitops:manifest_projects” should only appear once in the entire file.

    For Instructors: add one of these sections per participant. Ensure indentation is perserved.

       
      - id: _classgroup_/_yourpersonalgroup_/world-greetings-env-1
        default_namespace: default
        paths:
        - glob: '/manifests/**/*.yaml'
        reconcile_timeout: 3600s # 1 hour by default
        dry_run_strategy: none # 'none' by default
        prune: true # enabled by default
        prune_timeout: 360s # 1 hour by default
        prune_propagation_policy: foreground # 'foreground' by default
        inventory_policy: must_match # 'must_match' by default
    
  8. Final result should be something like this (including indentation - with repeating “id” sections for each participant if in a classroom):

    gitops:
      manifest_projects:
      - id: _classgroup_/_yourpersonalgroup_/world-greetings-env-1
        default_namespace: default
        paths:
        - glob: '/manifests/**/*.yaml'
        reconcile_timeout: 3600s # 1 hour by default
        dry_run_strategy: none # 'none' by default
        prune: true # enabled by default
        prune_timeout: 360s # 1 hour by default
        prune_propagation_policy: foreground # 'foreground' by default
        inventory_policy: must_match # 'must_match' by default
    
  9. Click Create commit…

  10. Select Commit to master branch (change from “Create a new branch”)

  11. Click Commit

  1. Watch the previously opened view of the GitLab Agent log for deployment activity.

    For Instructor-Led: the instructor may have this view displayed for everyone

  2. To watch the progress, navigate to classgroup/yourpersonalgroup/world-greetings-env-1

  3. Click Deployments => Environments

  4. [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
  5. [Automation wait: ~3 min] Wait after the status shows complete…

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

    You can see the staging deployed application.

  7. In the browser tabs, Click [the tab with the Environments page]

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

    You can see the production deployed application

  9. If there an error indicating there is no site yet, keep refreshing the browser window until the site displays.

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. Also note that on the very first time the agent is configured to monitor your manifests - all environments are deployed. From this point forward the manifests will be updated sequentially and will require approval for production.
Critical Mindfulness: Only Pull Deployment In Environment Deployment Project
Subsequent labs will be adding many Runner Based jobs to enable security scanning and dynamic environments. However, the deployment of this application will always be accomplished by a Pull Deployment through the GitLab Agent as you have seen in this lab. You may consult the job log (to see a manifest commit only) and/or the Kubernetes Agent log to verify this.
Accomplished Outcomes
  1. Configure the Kubernetes Agent to monitor the CI constructed kubernetes manifests.

  2. Observe the initial deployment of staging and production via tailing the Kubernetes Agent log and the appearance of the target environments.