-
-
Save GbengaElebs/3ff0b801e1ca88ac430c268d5253dd9d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Deploy to Azure Kubernetes Service | |
# Build and push image to Azure Container Registry; Deploy to Azure Kubernetes Service | |
# https://docs.microsoft.com/azure/devops/pipelines/languages/docker | |
trigger: | |
- main | |
variables: | |
# Container registry service connection established during pipeline creation | |
dockerRegistryServiceConnection: 'your-id-32268283c490' | |
imageRepository: 'testapi_api' | |
imageRepository2: 'mysql' | |
containerRegistry: 'gbengaelebs.azurecr.io' | |
dockerfilePath: '**/Dockerfile' | |
tag: '$(Build.BuildNumber)' | |
mysqltag: '8.0.22' | |
# Agent VM image name | |
# vmImageName: 'My-Ubuntu-Agent' | |
stages: | |
- stage: Build | |
displayName: Build stage | |
jobs: | |
- job: Build | |
displayName: Build | |
pool: | |
My-Ubuntu-Agent | |
steps: | |
- task: Docker@2 | |
displayName: Build and push an image to container registry | |
inputs: | |
command: buildAndPush | |
repository: $(imageRepository) | |
dockerfile: $(dockerfilePath) | |
containerRegistry: $(dockerRegistryServiceConnection) | |
tags: | | |
$(tag) | |
- task: Docker@2 | |
displayName: Build and push an image to container registry | |
inputs: | |
command: buildAndPush | |
repository: $(imageRepository2) | |
dockerfile: $(dockerfilePath) | |
containerRegistry: $(dockerRegistryServiceConnection) | |
tags: | | |
$(mysqltag) | |
- publish: manifests | |
artifact: manifests | |
- stage: Deploy | |
displayName: Deploy stage | |
dependsOn: Build | |
jobs: | |
- deployment: Deploy | |
displayName: Deploy | |
pool: | |
My-Ubuntu-Agent | |
environment: 'GbengaElebsDevAksTutorial-3184.default' | |
strategy: | |
runOnce: | |
deploy: | |
steps: | |
- task: KubernetesManifest@0 | |
displayName: Deploy to Kubernetes cluster | |
inputs: | |
action: deploy | |
manifests: | | |
$(Pipeline.Workspace)/manifests/mysql-pv-claim.yaml | |
$(Pipeline.Workspace)/manifests/mysqlDeployment.yaml | |
$(Pipeline.Workspace)/manifests/mysqlService.yaml | |
containers: | | |
$(containerRegistry)/$(imageRepository2):$(mysqltag) | |
- task: KubernetesManifest@0 | |
displayName: Deploy to Kubernetes cluster | |
inputs: | |
action: deploy | |
manifests: | | |
$(Pipeline.Workspace)/manifests/deployment.yaml | |
$(Pipeline.Workspace)/manifests/service.yaml | |
containers: | | |
$(containerRegistry)/$(imageRepository):$(tag) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment