microsoft / bedrock

Automation for Production Kubernetes Clusters with a GitOps Workflow
MIT License
129 stars 12 forks source link

CLI pipeline should support AzDO yaml templating to allow easier extension #1423

Open andrebriggs opened 4 years ago

andrebriggs commented 4 years ago

As a: Developer

I want: The Bedrock CLI to support templating when generating pipelines such as:

So that: I can customize and extend GitOps pipeline logic.

Describe the solution you'd like: The end solution should allow conditional configuration. This can be in the form of conditional yaml statements in the AzDO yaml pipeline that can enable/disable reusable templates. I've created a proof of concept here.

An example of what build-update-hld.yaml could be:

# File: azure-pipelines.yml
trigger:
- master

variables:
  - group: quick-start-vg
  - name: APP_NAME
    value: quick-start-app

stages:
  - stage: build
    jobs:
      - job: run_build_push_acr
        pool:
          vmImage: ubuntu-latest
        steps:
        - template: templates/azure-login.yml  # Template reference
          parameters:
            appId: $(SP_APP_ID)
            password: $(SP_PASS)
            tenantId: $(SP_TENANT)
        - template: templates/container-build-strategy.yml  # Template reference
          parameters:
            downloadTools: false
            imageRepoType: ACR
            imageName: "$(APP_NAME)-$(Build.SourceBranchName)"
            imageTag: $(Build.BuildNumber)
            buildArgs:
            - AZP_POOL
            - ACR_NAME
  - stage: hld_update
    dependsOn: build
    condition: succeeded('build')
    jobs:
      - job: update_image_tag
        pool:
          vmImage: ubuntu-latest
        steps:
        - template: templates/git-update-strategy.yml  # Template reference
          parameters:
            downloadFab: true
            downloadTools: true
            azureContainerRegistry: $(ACR_NAME)
            gitUpdateType: HLD
            gitRepoURL: $(HLD_REPO)
            gitAccessToken: $(PAT)
            imageName: "$(APP_NAME)-$(Build.SourceBranchName)"
            imageTag: $(Build.BuildNumber)

I would also consider maintaining a library of GitOps focused AzDO templates (and possibly bash scripts) that can be hosted from Bedrock, can be optionally downloaded to local repositories, or be hosted on a user's private repository.

If applicable it might make sense to encapsulate heavily re-used components of the Bedrock CLI GitOps pipelines in Azure DevOps Extension Tasks.

Acceptance Criteria:

Does this require updates to documentation?: Yes