If you would like to deploy the azure voting app using bedrock, follow the guide below. Follow the GitOps tutorial on this page to understand the overall Bedrock pipelines infrastructure.
The following diagram describes overview of the various challenges You will be working with three repos for this exercise - code repo, HLD (high level definition) repo and manifest repo
The first step is to build a container image of this azure voting app and push it to Azure Container Registry. Go to Azure portal and provision a Azure Container Registry in the same resource group where you provisioned your cluster from Challenge 1.
There's already a Dockerfile provided to you in this path that needs to be used by the continuous integration pipelines to create the docker build.
- Enable multistage pipelines in your Azure Dev Ops.
- Create a fork of the repository located here.
- Click on
New pipeline
in your Azure DevOps Project under Pipelines - Select your forked repository under the repositories section.
- Next, it should show you a page with a list of pre-defined tasks. Select
Docker Build and push an image to Azure Container Registry
. - It should load all your available subscriptions. Select the appropriate subscription.
- Select an available container registry and enter an image name.
- Click on
Validate and configure
and run the pipeline. - You should be able to see a new repository created under your ACR for this new image.
Before we begin, you need to create a fork of the HLD repository.
Assuming that we're using multi-stage pipelines for the purpose of this voting app, go into editing mode for your first source pipeline and you should be able to edit the yaml file inline.
Insert the following stage towards the end of the yaml file. This will perform the following steps:
- Run when the build stage passes
- Download the bedrock release and build scripts, and source them
- Execute the release script
- stage: hld_update
displayName: ACR to HLD Stage
dependsOn: Build
condition: succeeded('Build')
jobs:
- job: hld_update
displayName: HLD Update
pool:
vmImage: $(vmImageName)
steps:
- bash: |
# Download build.sh
curl https://raw.githubusercontent.com/Microsoft/bedrock/master/gitops/azure-devops/build.sh > build.sh
chmod +x ./build.sh
curl https://raw.githubusercontent.com/Microsoft/bedrock/master/gitops/azure-devops/release.sh > release.sh
chmod +x ./release.sh
# Execute release.sh
. release.sh
displayName: Bash step
env:
ACCESS_TOKEN_SECRET: $(ACCESS_TOKEN)
COMMIT_MESSAGE: Update front end image tag to $(Build.BuildId)
SUBCOMPONENT: azure-vote
YAML_PATH: azureVoteFront.deployment.imageTag
YAML_PATH_VALUE: $(Build.BuildId)
REPO: https://github.com/<your user name>/azure-voting-app.git
Create a personal access token for your GitHub account and save it someplace
Add a Variable called ACCESS_TOKEN
and enter your personal access token for GitHub, and make this variable a secret.
Click on Save
button, it will prompt you to push the changes to the repository. Click commit and watch the logs for the running pipeline. You should be able to see a new commit in your HLD repository after the stage is complete.
Create a new empty repository in your GitHub, call it something like azure-voting-manifest
The Manifest generation pipeline needs to be triggered off any changes on the HLD repository.
-
Go into pipelines in your Azure DevOps project and click on new pipeline.
-
Select your forked HLD repository (
<username>/azure-voting-app
). -
Choose the
azure-pipelines.yml
file located in the root directory and click on Continue. -
It should start to run the pipeline. Since the variables are not yet defined, this may fail, so you will need to click on
Edit
for this pipeline and add the following variables:Make sure that the
MANIFEST_REPO
variable is set to your newly created repository for storing kubernetes manifests. -
You need to make changes to ACR url so that it points to your ACR. To do this go to your HLD repo and update the ACR in the following file azure-voting-app/charts/azure-voting-app/values.yaml
-
Run the pipeline once again and it should succeed.
Your basic setup of Bedrock is now complete. You should be able to deploy a cluster and point it to the manifest repository, based on instructions here.
If you make a change to the source code, it should propogate to the manifest, and to the cluster. Try changing cats and dogs in the source repo to something else!