This repository has been archived by the owner on Jan 15, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
82 lines (72 loc) · 3.03 KB
/
deploy.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
# This workflow will build a docker container, publish it to Azure Container Registry, and deploy it to Azure Kubernetes Service using a helm chart.
#
# To configure this workflow:
#
# 1. Set up the following secrets in your workspace:
# a. REGISTRY_USERNAME with ACR username
# b. REGISTRY_PASSWORD with ACR Password
# c. AZURE_CREDENTIALS with the output of `az ad sp create-for-rbac --sdk-auth`
#
# 2. Change the values for the REGISTRY_NAME, CLUSTER_NAME, CLUSTER_RESOURCE_GROUP and NAMESPACE environment variables (below).
on: [push]
# Environment variables available to all jobs and steps in this workflow
env:
REGISTRY_NAME: evryflaatten
CLUSTER_NAME: aks-demo
CLUSTER_RESOURCE_GROUP: aks-demo
NAMESPACE: default
IMAGE_NAME: azure-vote
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
# Connect to Azure Container registry (ACR)
- uses: azure/docker-login@v1
with:
login-server: ${{ env.REGISTRY_NAME }}.azurecr.io
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
# Container build and push to a Azure Container registry (ACR)
- run: |
docker build . -t ${{ env.REGISTRY_NAME }}.azurecr.io/${{ env.IMAGE_NAME }}:${{ github.sha }}
docker push ${{ env.REGISTRY_NAME }}.azurecr.io/${{ env.IMAGE_NAME }}:${{ github.sha }}
# Set the target Azure Kubernetes Service (AKS) cluster.
- uses: azure/aks-set-context@v1
with:
creds: '${{ secrets.AZURE_CREDENTIALS }}'
cluster-name: ${{ env.CLUSTER_NAME }}
resource-group: ${{ env.CLUSTER_RESOURCE_GROUP }}
# Create namespace if doesn't exist
- run: |
kubectl create namespace ${{ env.NAMESPACE }} --dry-run -o json | kubectl apply -f -
# Create imagepullsecret for Azure Container registry (ACR)
- uses: azure/k8s-create-secret@v1
with:
container-registry-url: ${{ env.REGISTRY_NAME }}.azurecr.io
container-registry-username: ${{ secrets.REGISTRY_USERNAME }}
container-registry-password: ${{ secrets.REGISTRY_PASSWORD }}
secret-name: ${{ env.REGISTRY_NAME }}-registry-connection
namespace: ${{ env.NAMESPACE }}
# Baking the helm chart to generate the manifests to deploy
- uses: azure/k8s-bake@v1
with:
renderEngine: 'helm'
helmChart: './mychart/'
helm-version: 'latest'
releaseName: 'azure-vote'
overrideFiles: 'values.yaml'
overrides: |
image.repository:${{ env.REGISTRY_NAME }}.azurecr.io/${{ env.IMAGE_NAME }}
image.tag:${{ github.sha }}
imagePullSecrets[0].name:${{ env.REGISTRY_NAME }}-registry-connection
id: bake
# Deploy app to AKS
- uses: azure/k8s-deploy@v1
with:
manifests: ${{ steps.bake.outputs.manifestsBundle }}
#images: |
# ${{ env.REGISTRY_NAME }}.azurecr.io/${{ env.IMAGE_NAME }}:${{ github.sha }}
#imagepullsecrets: |
# ${{ env.REGISTRY_NAME }}-registry-connection
namespace: ${{ env.NAMESPACE }}