-
Notifications
You must be signed in to change notification settings - Fork 411
/
azure-pipelines.yml
86 lines (82 loc) · 2.38 KB
/
azure-pipelines.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
trigger:
- main
resources:
- repo: self
variables:
imageRepo: sampleapp
tag: '$(Build.BuildId)'
stages:
- stage: Build
displayName: Build image
jobs:
- job: Build
displayName: Build
pool:
vmImage: ubuntu-latest
steps:
- task: Docker@2
displayName: Build an image
inputs:
containerRegistry: 'K8SExamplesACR'
repository: '$(imageRepo)'
command: 'buildAndPush'
Dockerfile: '$(Build.SourcesDirectory)/app/Dockerfile'
tags: |
$(tag)
- task: PublishPipelineArtifact@1
inputs:
targetPath: '$(Pipeline.Workspace)/s/kubernetes'
artifact: 'manifests'
publishLocation: 'pipeline'
- stage: Deploy
displayName: Deploy to Dev
dependsOn: Build
variables:
acrsecret: k8sexamplesacrauth
acrdevurl: 'k8sexamplesacr.azurecr.io'
replicaNo: 3
jobs:
- deployment: Deploy
displayName: Deploy to AKS
environment: 'k8sdev.default'
pool:
vmImage: ubuntu-latest
strategy:
runOnce:
deploy:
steps:
- task: DownloadPipelineArtifact@2
inputs:
buildType: 'current'
artifactName: 'manifests'
targetPath: '$(Pipeline.Workspace)/manifests'
- task: KubernetesManifest@0
inputs:
action: 'createSecret'
namespace: 'default'
secretType: 'dockerRegistry'
secretName: '$(acrsecret)'
dockerRegistryEndpoint: 'K8SExamplesACR'
- task: replacetokens@3
displayName: Replace Tokens
inputs:
rootDirectory: '$(Pipeline.Workspace)/manifests/'
targetFiles: 'deployment.yml'
encoding: 'auto'
writeBOM: true
actionOnMissing: 'warn'
keepToken: false
tokenPrefix: '#'
tokenSuffix: '#'
useLegacyPattern: false
enableTransforms: false
enableTelemetry: true
- task: KubernetesManifest@0
inputs:
action: 'deploy'
namespace: 'default'
manifests: |
$(Pipeline.Workspace)/manifests/deployment.yml
$(Pipeline.Workspace)/manifests/service.yml
containers: '$(acrdevurl)/$(imageRepo):$(tag)'
imagePullSecrets: '$(acrsecret)'