Skip to content

Commit

Permalink
Updated summary api deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
HansDahle committed Nov 5, 2024
1 parent 70be5de commit d5365b0
Show file tree
Hide file tree
Showing 10 changed files with 169 additions and 176 deletions.
88 changes: 56 additions & 32 deletions pipelines/summary-api-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ resources:

variables:
imageTag: $(Build.BuildNumber)
fusionAcr: 'fusioncr.azurecr.io'
fusionAcr: 'crfsharedhostingall.azurecr.io'
imageRepo: fra/fusion-summary-api
imageName: $(imageRepo):$(imageTag)
subscriptionServiceNonProd: 'FRA Automation Non-Prod'
subscriptionServiceProd: 'FRA Automation Prod'
deploymentManifest: '$(Pipeline.Workspace)/k8s-deployment/deployment-test-env.yml'
deploymentManifestFolder: '$(Pipeline.Workspace)/k8s-deployment'
fullImageName: $(fusionAcr)/$(imageName)
dbTagPrefix: summary

Expand All @@ -38,19 +38,15 @@ stages:
- job: BuildImage
steps:
- task: Docker@2
displayName: Login to fusioncr
displayName: 'Build docker image'
inputs:
command: login
containerRegistry: fusioncr
- template: templates/docker-buildx.yml@infra
parameters:
containerRegistry: 'fusion-aks-cr'
repository: $(imageRepo)
command: 'buildAndPush'
buildContext: ./src
dockerfile: src/Fusion.Summary.Api/Dockerfile
dockerPush: true
disableCache: true
tags: |
$(imageTag)
tags: $(imageTag)

- template: templates/docker-buildx.yml@infra
parameters:
initBuilderInstance: false
Expand All @@ -60,14 +56,14 @@ stages:
arguments: |
--target=export
--output=type=local,dest=$(Build.ArtifactStagingDirectory)
--cache-from=type=registry,ref=fusioncachecr.azurecr.io/$(imageRepo):$(imageTag)
--cache-from=type=registry,ref=crfsharedhostingall.azurecr.io/$(imageRepo):$(imageTag)
- task: CopyFiles@2
displayName: 'Copy Files to: $(Build.ArtifactStagingDirectory)'
inputs:
SourceFolder: 'src/Fusion.Summary.Api/Deployment/k8s'
Contents: |
deployment-test-env.yml
deployment-*.yml
TargetFolder: '$(Build.ArtifactStagingDirectory)'

- publish: $(Build.ArtifactStagingDirectory)
Expand All @@ -81,10 +77,11 @@ stages:
envName: 'ci'
fusionEnvironment: 'ci'
clientId: '5a842df8-3238-415d-b168-9f16a6a6031b'
aks-namespace: 'fusion-resource-allocation-ci'

jobs:
- deployment: DeployCI
environment: fusion-ci.fusion-resources-app-ci
environment: fusion-ci
strategy:
runOnce:
deploy:
Expand Down Expand Up @@ -116,7 +113,7 @@ stages:

- template: templates/replace-tokens.yml
parameters:
targetFiles: '$(deploymentManifest)'
targetFiles: $(deploymentManifestFolder)/*.yml

- template: templates/execute-sql-migration.yml
parameters:
Expand All @@ -125,11 +122,15 @@ stages:
azureSubscription: $(subscriptionServiceNonProd)
dbTagPrefix: $(dbTagPrefix)

- task: KubernetesManifest@0
- task: KubernetesManifest@1
displayName: Deploy to Kubernetes cluster
inputs:
kubernetesServiceConnection: fra-k8s-ci
namespace: $(aks-namespace)
action: deploy
manifests: $(deploymentManifest)
manifests: |
$(deploymentManifestFolder)/deployment-service.yml
$(deploymentManifestFolder)/deployment-ingress-test.yml
- stage: DeployFQA
displayName: 'Deploy to FQA'
Expand All @@ -139,6 +140,7 @@ stages:
envName: 'fqa'
fusionEnvironment: 'fqa'
clientId: '5a842df8-3238-415d-b168-9f16a6a6031b'
aks-namespace: 'fusion-resource-allocation-fqa'

jobs:
- deployment: DeployFQA
Expand Down Expand Up @@ -172,7 +174,7 @@ stages:

- template: templates/replace-tokens.yml
parameters:
targetFiles: '$(deploymentManifest)'
targetFiles: $(deploymentManifestFolder)/*.yml

- template: templates/execute-sql-migration.yml
parameters:
Expand All @@ -181,11 +183,15 @@ stages:
azureSubscription: $(subscriptionServiceNonProd)
dbTagPrefix: $(dbTagPrefix)

- task: KubernetesManifest@0
- task: KubernetesManifest@1
displayName: Deploy to Kubernetes cluster
inputs:
kubernetesServiceConnection: fra-k8s-fqa
namespace: $(aks-namespace)
action: deploy
manifests: $(deploymentManifest)
manifests: |
$(deploymentManifestFolder)/deployment-service.yml
$(deploymentManifestFolder)/deployment-ingress-test.yml
- stage: DeployFPRD
displayName: 'Deploy to FPRD'
Expand All @@ -195,6 +201,7 @@ stages:
envName: 'fprd'
fusionEnvironment: 'fprd'
clientId: '97978493-9777-4d48-b38a-67b0b9cd88d2'
aks-namespace: 'fusion-resource-allocation-prod'

jobs:
- deployment: DeployFPRD
Expand Down Expand Up @@ -228,7 +235,7 @@ stages:

- template: templates/replace-tokens.yml
parameters:
targetFiles: '$(deploymentManifest)'
targetFiles: $(deploymentManifestFolder)/*.yml

- template: templates/execute-sql-migration.yml
parameters:
Expand All @@ -237,19 +244,31 @@ stages:
azureSubscription: $(subscriptionServiceProd)
dbTagPrefix: $(dbTagPrefix)

- task: KubernetesManifest@0
- task: KubernetesManifest@1
displayName: Deploy to Kubernetes cluster
inputs:
kubernetesServiceConnection: fra-k8s-prod
namespace: $(aks-namespace)
action: deploy
manifests: $(deploymentManifest)
manifests: |
$(deploymentManifestFolder)/deployment-service.yml
$(deploymentManifestFolder)/deployment-ingress-prod.yml
- template: templates/deploy-summary-container-app.yml
parameters:
## Must check out code to get deployment file
- checkout: self
- task: AzurePowerShell@5
displayName: 'Deploy ARM template'
inputs:
azureSubscription: $(subscriptionServiceProd)
environment: $(envName)
fusionEnvironment: $(fusionEnvironment)
clientId: $(clientId)
imageName: $(fullImageName)
ScriptType: FilePath
FailOnStandardError: true
azurePowerShellVersion: 'LatestVersion'
ScriptPath: src/Fusion.Summary.Api/Deployment/deploy-webapp.ps1
ScriptArguments: >
-environment $(envName)
-clientId $(clientId)
-fusionEnvironment $(fusionEnvironment)
-imageName $(fullImageName)
- stage: DeployTR
displayName: 'Deploy to TR'
Expand All @@ -259,6 +278,7 @@ stages:
envName: 'tr'
fusionEnvironment: 'tr'
clientId: '5a842df8-3238-415d-b168-9f16a6a6031b'
aks-namespace: 'fusion-resource-allocation-tr'

jobs:
- deployment: DeployTR
Expand Down Expand Up @@ -292,7 +312,7 @@ stages:

- template: templates/replace-tokens.yml
parameters:
targetFiles: '$(deploymentManifest)'
targetFiles: $(deploymentManifestFolder)/*.yml

- template: templates/execute-sql-migration.yml
parameters:
Expand All @@ -301,8 +321,12 @@ stages:
azureSubscription: $(subscriptionServiceNonProd)
dbTagPrefix: $(dbTagPrefix)

- task: KubernetesManifest@0
- task: KubernetesManifest@1
displayName: Deploy to Kubernetes cluster
inputs:
kubernetesServiceConnection: fra-k8s-tr
namespace: $(aks-namespace)
action: deploy
manifests: $(deploymentManifest)
manifests: |
$(deploymentManifestFolder)/deployment-service.yml
$(deploymentManifestFolder)/deployment-ingress-test.yml
43 changes: 16 additions & 27 deletions pipelines/summary-api-pr-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ resources:

variables:
prNumber: $(System.PullRequest.PullRequestNumber)
fusionAcr: 'fusioncr.azurecr.io'
imageRepo: resources/fusion-summary-api
fusionAcr: 'crfsharedhostingall.azurecr.io'
imageRepo: fra/summary-api-pr
imageName: $(imageRepo):$(prNumber)
subscriptionService: 'FRA Automation Non-Prod'
subscriptionServiceCore: PROJECT_PORTAL (63b791ae-b2bc-41a1-ac66-806c4e69bffe)
Expand All @@ -36,29 +36,14 @@ stages:
steps:

- task: Docker@2
displayName: Login to fusioncr
displayName: 'Build docker image'
inputs:
command: login
containerRegistry: fusioncr

- task: Docker@2
displayName: Login to fusioncachecr
inputs:
command: login
containerRegistry: fusioncachecr

- template: templates/docker-buildx.yml@infra
parameters:
containerRegistry: 'fusion-aks-cr'
repository: $(imageRepo)
command: buildAndPush
buildContext: ./src
dockerfile: src/Fusion.Summary.Api/Dockerfile
dockerPush: true
cacheFrom: |
latest
cacheTo: |
$(prNumber)
tags: |
$(prNumber)
dockerfile: ./src/backend/api/Fusion.Resources.Api/Dockerfile
tags: $(prNumber)

- template: templates/docker-buildx.yml@infra
parameters:
Expand All @@ -69,14 +54,14 @@ stages:
arguments: |
--target=export
--output=type=local,dest=$(Build.ArtifactStagingDirectory)
--cache-from=type=registry,ref=fusioncachecr.azurecr.io/$(imageRepo):$(prNumber)
--cache-from=type=registry,ref=$(fusionAcr)/$(imageRepo):$(prNumber)
- task: CopyFiles@2
displayName: 'Copy Files to: $(Build.ArtifactStagingDirectory)'
inputs:
SourceFolder: 'src/Fusion.Summary.Api/Deployment/k8s'
Contents: |
deployment-pr-env.yml
pr-deployment-env.yml
TargetFolder: '$(Build.ArtifactStagingDirectory)'
- publish: $(Build.ArtifactStagingDirectory)
artifact: 'k8s-deployment'
Expand All @@ -89,11 +74,12 @@ stages:
envName: 'pr'
fusionEnvironment: 'ci'
clientId: '5a842df8-3238-415d-b168-9f16a6a6031b'
aks-namespace: 'fusion-resource-allocation-pr'

jobs:
- deployment: DeployPR
displayName: 'Deploy API to PR'
environment: fra-pr.fusion-resources-app-pr
environment: fra-pr
strategy:
runOnce:
deploy:
Expand Down Expand Up @@ -165,8 +151,11 @@ stages:
azureSubscription: $(subscriptionService)
dbTagPrefix: 'summary'

- task: KubernetesManifest@0
- task: KubernetesManifest@1
displayName: Deploy to Kubernetes cluster
inputs:
kubernetesServiceConnection: fra-k8s-pr
namespace: $(aks-namespace)
action: deploy
manifests: $(deploymentManifest)
manifests: |
$(deploymentManifest)
24 changes: 0 additions & 24 deletions pipelines/templates/deploy-container-app.yml

This file was deleted.

23 changes: 0 additions & 23 deletions pipelines/templates/deploy-summary-container-app.yml

This file was deleted.

16 changes: 2 additions & 14 deletions src/Fusion.Summary.Api/Deployment/deploy-webapp.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,8 @@ $hostingPlan = New-HostingResource


Write-Host "Using resource group $resourceGroup"

$adClientSecret = Get-AzKeyVaultSecret -VaultName $envKeyVault -Name "AzureAd--ClientSecret"
$acrPullToken = Get-AzKeyVaultSecret -VaultName $envKeyVault -Name "ACR-PullToken" -AsPlainText

##
## ACR Pull secret
##
## The ACR password must be generated on the fusioncr resource and added to the env key vault.
## No automatic generation of this for now.

$dockerCredentials = @{ username="Resources-fprd-pull"; password=$acrPullToken }
$dockerInfo = @{
url = "https://fusioncr.azurecr.io"
url = "https://crfsharedhostingall.azurecr.io"
image = $imageName
startupCommand = ""
}
Expand All @@ -66,9 +55,8 @@ $templateFile = "$($env:BUILD_SOURCESDIRECTORY)/src/Fusion.Summary.Api/Deploymen
New-AzResourceGroupDeployment -Mode Incremental -Name "fusion-app-summary-webapp" -ResourceGroupName $resourceGroup -TemplateFile $templateFile `
-env-name $environment `
-fusion-env-name $fusionEnvironment `
-clientsecret-secret-id $adClientSecret.Id `
-clientsecret-secret-id "https://$envKeyVault.vault.azure.net:443/secrets/AzureAd--ClientSecret" `
-client-id $clientId `
-docker-credentials $dockerCredentials `
-docker $dockerInfo `
-hosting @{ name = $hostingPlan.Name; id = $hostingPlan.Id }

Loading

0 comments on commit d5365b0

Please sign in to comment.