-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathazure-pipelines.yml
132 lines (110 loc) · 3.78 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
trigger:
- master
pool:
#vmImage: ubuntu-latest
name: pool-anext
parameters:
- name: tagName
displayName: "Containers image tag"
type: string
default: latest
- name: containerRegistry
displayName: "Container registry service connection"
type: string
default: anext.azurecr.io
- name: kubernetesCluster
displayName: "Kubernetes service connection"
type: string
default: k8s-test
- name: namespace
displayName: "Kubernetes Namespace"
type: string
default: test-app
- name: repositoryName
displayName: "Container repository name"
type: string
default: container-test-app
stages:
- stage: Build
jobs:
- job: build
steps:
- checkout: self
- task: Bash@3
inputs:
targetType: 'inline'
script: |
pwd
ls -laFh
- task: Docker@2
displayName: "Build frontend"
inputs:
containerRegistry: '${{ parameters.containerRegistry }}'
repository: '${{ parameters.repositoryName }}'
command: 'buildAndPush'
Dockerfile: 'frontend.Dockerfile'
buildContext: 'frontend'
tags: 'frontend-${{ parameters.tagName }}'
- task: Docker@2
displayName: "Build backend"
inputs:
containerRegistry: '${{ parameters.containerRegistry }}'
repository: '${{ parameters.repositoryName }}'
command: 'buildAndPush'
Dockerfile: 'backend.Dockerfile'
buildContext: 'backend'
tags: 'backend-${{ parameters.tagName }}'
- stage: Deploy
jobs:
- job: build
steps:
- checkout: self
- task: Kubernetes@1
inputs:
connectionType: 'Kubernetes Service Connection'
kubernetesServiceEndpoint: '${{ parameters.kubernetesCluster }}'
namespace: '${{ parameters.namespace }}'
command: 'login'
- task: KubernetesManifest@0
inputs:
action: 'createSecret'
kubernetesServiceConnection: '${{ parameters.kubernetesCluster }}'
secretType: 'dockerRegistry'
namespace: '${{ parameters.namespace }}'
secretName: '${{ parameters.containerRegistry }}'
dockerRegistryEndpoint: '${{ parameters.containerRegistry }}'
- task: HelmInstaller@0
inputs:
helmVersion: '2.14.1'
installKubectl: true
- task: HelmDeploy@0
inputs:
command: 'package'
chartPath: 'helm/sample-app'
chartVersion: '1.0'
- task: HelmDeploy@0
displayName: "Deploy Frontend"
inputs:
connectionType: 'Kubernetes Service Connection'
kubernetesServiceConnection: '${{ parameters.kubernetesCluster }}'
namespace: '${{ parameters.namespace }}'
command: 'upgrade'
chartType: 'FilePath'
chartPath: '$(Build.ArtifactStagingDirectory)/sample-app-1.0.tgz'
chartVersion: '1.0'
releaseName: '${{ parameters.repositoryName }}-front'
valueFile: 'helm/values/frontend.yaml'
resetValues: true
- task: HelmDeploy@0
displayName: "Deploy Backend"
inputs:
connectionType: 'Kubernetes Service Connection'
kubernetesServiceConnection: '${{ parameters.kubernetesCluster }}'
namespace: '${{ parameters.namespace }}'
command: 'upgrade'
chartType: 'FilePath'
chartPath: '$(Build.ArtifactStagingDirectory)/sample-app-1.0.tgz'
chartVersion: '1.0'
releaseName: '${{ parameters.repositoryName }}-back'
valueFile: 'helm/values/backend.yaml'
resetValues: true