-
Notifications
You must be signed in to change notification settings - Fork 34
/
cd_template.yaml
99 lines (83 loc) · 3.82 KB
/
cd_template.yaml
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
jobs:
- job: "Deploy"
displayName: "Release: Pull Helm -> Deploy to EKS"
continueOnError: false
steps:
- task: HelmInstaller@1
displayName: 'Install Helm'
inputs:
helmVersionToInstall: ${{ parameters.helmVersion }}
- task: AWSShellScript@1
displayName: 'ECR login'
inputs:
awsCredentials: ${{ parameters.serviceConnectionName }}
regionName: ${{ parameters.awsRegion }}
failOnStandardError: true
scriptType: 'inline'
inlineScript: |
echo 'Using identity'
aws sts get-caller-identity
## ECR Login
export HELM_EXPERIMENTAL_OCI=1
# Login with Helm
echo 'HELM Login to ECR...'
aws ecr get-login-password \
--region $(awsECRRegion) | helm registry login \
--username AWS \
--password-stdin $(repositoryURI)
- task: AWSShellScript@1
displayName: 'Pull and deploy Helm Chart'
inputs:
awsCredentials: ${{ parameters.serviceConnectionName }}
regionName: ${{ parameters.awsRegion }}
failOnStandardError: true
scriptType: 'inline'
inlineScript: |
# # Confirm caller identity
# echo 'Using identity'
# aws sts get-caller-identity
# Pull Helm Chart
echo "Pulling helm chart from $(repositoryURI)"
helm pull oci://$(repositoryURI) --version $(helmChartVersion)
# Get Kubeconfig
echo 'Connect to Amazon EKS cluster'
aws eks update-kubeconfig --region $(awsEKSRegion) --name ${{ parameters.awsEKSClusterName }}
# Deploy Helm Chart
echo 'Deploy Helm chart to EKS...'
chartPackage=${{ parameters.projectName }}-$(helmChartVersion).tgz
echo $(pwd)
echo "chart package to be installed - $chartPackage"
helm upgrade \
--namespace $(K8sNamespace) \
--create-namespace \
--install \
--wait \
--version $(helmChartVersion) \
--set application.name=${{ parameters.projectName }} \
--set image.repository=$(repositoryURI) \
--set appversion="$(Build.BuildNumber)" \
${{ parameters.projectName }} \
$chartPackage \
- task: AWSShellScript@1
displayName: 'Display Kubectl & Helm Outputs'
inputs:
awsCredentials: ${{ parameters.serviceConnectionName }}
regionName: ${{ parameters.awsRegion }}
scriptType: 'inline'
inlineScript: |
echo "##[section]kubectl get all -n $(K8sNamespace)"
kubectl get all -n $(K8sNamespace)
echo "##[section]kubectl get deploy -n $(K8sNamespace)"
kubectl get deploy -n $(K8sNamespace)
echo "##[section]kubectl get services -n $(K8sNamespace)"
kubectl get services -n $(K8sNamespace)
echo "##[section]kubectl get pods -n $(K8sNamespace)"
kubectl get pods -n $(K8sNamespace)
echo "##[section]kubectl describe service webapp -n $(K8sNamespace)"
kubectl describe service webapp -n $(K8sNamespace)
echo "##[section]kubectl kubectl get secrets -n $(K8sNamespace)"
kubectl get secrets -n $(K8sNamespace)
echo "##[section]helm list -n $(K8sNamespace)"
helm list -n $(K8sNamespace)
echo "##[section]helm status ${{ parameters.projectName }} -n $(K8sNamespace)"
helm status ${{ parameters.projectName }} -n $(K8sNamespace)