Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(pipeline): Changed AKS cluster #715

Merged
merged 33 commits into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
e82976a
update build steps to new cr
HansDahle Nov 1, 2024
e25e761
Updated deployment steps
HansDahle Nov 1, 2024
2b29ed8
changed service connection to inline instead of variable as var is no…
HansDahle Nov 1, 2024
a1aaf8c
Updated dns
HansDahle Nov 1, 2024
7b11c88
fixed manifest name
HansDahle Nov 1, 2024
5b658ba
updated pr deployment to be isolated by name
HansDahle Nov 1, 2024
388f42e
Added poc step for container app deploy
HansDahle Nov 4, 2024
4dc686a
Added checkout step for depl file
HansDahle Nov 4, 2024
b011c71
removed docker credentials in move to managed ident
HansDahle Nov 4, 2024
24039c8
Fixed missing parameter
HansDahle Nov 4, 2024
cf57a53
Finalized container app deployment for res api
HansDahle Nov 4, 2024
3b78a9d
changed to wildcard in test env
HansDahle Nov 4, 2024
9ec737d
aligned dns
HansDahle Nov 4, 2024
b207356
Updated pr pipeline
HansDahle Nov 5, 2024
36ccdb8
Fixed incorrect tag
HansDahle Nov 5, 2024
e931ed4
updated cache step
HansDahle Nov 5, 2024
29ac949
Commit to test caching
HansDahle Nov 5, 2024
9911eac
added cache-from arg
HansDahle Nov 5, 2024
7e23c78
changed to two steps for docker build
HansDahle Nov 5, 2024
9c1e448
Added debug step to list images on agent
HansDahle Nov 5, 2024
b6510a1
Removed caching as it did not work
HansDahle Nov 5, 2024
787c0ed
Cleanup, remove set cache
HansDahle Nov 5, 2024
70be5de
changed to wildcard cert
HansDahle Nov 5, 2024
d5365b0
Updated summary api deployment
HansDahle Nov 5, 2024
0ace189
fixed dockerfile
HansDahle Nov 5, 2024
1c7c7f9
Fixed deployment manifest name
HansDahle Nov 5, 2024
a4ec36d
Updated dns
HansDahle Nov 5, 2024
b320b10
Aligned dns
HansDahle Nov 5, 2024
af4f1a5
Fixed incorrect ingress
HansDahle Nov 5, 2024
ceb6b16
Fixed incorrect manifest name
HansDahle Nov 5, 2024
6626a3a
Reverted changes to unrelated file
HansDahle Nov 6, 2024
0b7757c
reverted unrelated change
HansDahle Nov 6, 2024
bc7dbc1
Merge remote-tracking branch 'origin/master' into chore/move-aks-cluster
HansDahle Nov 6, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
103 changes: 63 additions & 40 deletions pipelines/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'
imageRepo: resources/fusion-resouces-api
fusionAcr: 'crfsharedhostingall.azurecr.io'
imageRepo: fra/resouces-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: resources

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/backend
dockerfile: src/backend/api/Fusion.Resources.Api/Dockerfile
dockerPush: true
disableCache: true
tags: |
$(imageTag)
dockerfile: ./src/backend/api/Fusion.Resources.Api/Dockerfile
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/backend/api/Fusion.Resources.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 @@ -113,23 +110,26 @@ stages:
variableName: envKeyVaultUrl
azureSubscription: $(subscriptionServiceNonProd)


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

- template: templates/execute-sql-migration.yml
parameters:
artifact: 'k8s-deployment'
environment: $(envName)
azureSubscription: $(subscriptionServiceNonProd)
dbTagPrefix: $(dbTagPrefix)
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,10 +139,11 @@ stages:
envName: 'fqa'
fusionEnvironment: 'fqa'
clientId: '5a842df8-3238-415d-b168-9f16a6a6031b'
aks-namespace: 'fusion-resource-allocation-fqa'

jobs:
- deployment: DeployFQA
environment: fusion-fqa.fusion-resources-app-fqa
environment: fusion-fqa
strategy:
runOnce:
deploy:
Expand Down Expand Up @@ -172,20 +173,24 @@ stages:

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

- template: templates/execute-sql-migration.yml
parameters:
artifact: 'k8s-deployment'
environment: $(envName)
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,10 +200,11 @@ stages:
envName: 'fprd'
fusionEnvironment: 'fprd'
clientId: '97978493-9777-4d48-b38a-67b0b9cd88d2'
aks-namespace: 'fusion-resource-allocation-prod'

jobs:
- deployment: DeployFPRD
environment: fusion-prod.fusion-resources-app-fprd
environment: fusion-prod
strategy:
runOnce:
deploy:
Expand Down Expand Up @@ -228,7 +234,7 @@ stages:

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

- template: templates/execute-sql-migration.yml
parameters:
Expand All @@ -237,19 +243,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-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/backend/api/Fusion.Resources.Api/Deployment/deploy-webapp.ps1
ScriptArguments: >
-environment $(envName)
-clientId $(clientId)
-fusionEnvironment $(fusionEnvironment)
-imageName $(fullImageName)

- stage: DeployTR
displayName: 'Deploy to TR'
Expand All @@ -259,10 +277,11 @@ stages:
envName: 'tr'
fusionEnvironment: 'tr'
clientId: '5a842df8-3238-415d-b168-9f16a6a6031b'
aks-namespace: 'fusion-resource-allocation-tr'

jobs:
- deployment: DeployTR
environment: fusion-tr.fusion-resources-app-tr
environment: fusion-tr
strategy:
runOnce:
deploy:
Expand Down Expand Up @@ -292,7 +311,7 @@ stages:

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

- template: templates/execute-sql-migration.yml
parameters:
Expand All @@ -302,8 +321,12 @@ stages:

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
47 changes: 20 additions & 27 deletions pipelines/api-pr-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ resources:

variables:
prNumber: $(System.PullRequest.PullRequestNumber)
fusionAcr: 'fusioncr.azurecr.io'
imageRepo: resources/fusion-resouces-api
fusionAcr: 'crfsharedhostingall.azurecr.io'
imageRepo: fra/resouces-api-pr
imageName: $(imageRepo):$(prNumber)
subscriptionService: 'FRA Automation Non-Prod'
subscriptionServiceCore: PROJECT_PORTAL (63b791ae-b2bc-41a1-ac66-806c4e69bffe)
deploymentManifest: '$(Pipeline.Workspace)/k8s-deployment/deployment-pr-env.yml'
deploymentManifest: '$(Pipeline.Workspace)/k8s-deployment/pr-deployment-env.yml'
fullImageName: $(fusionAcr)/$(imageName)
buildNr: $(Build.BuildNumber)

Expand All @@ -34,28 +34,17 @@ stages:
jobs:
- job: BuildImage
steps:

- task: Docker@2
displayName: Login to fusioncr
inputs:
command: login
containerRegistry: fusioncr
- task: Docker@2
displayName: Login to fusioncachecr
displayName: 'Build docker image'
inputs:
command: login
containerRegistry: fusioncachecr
- template: templates/docker-buildx.yml@infra
parameters:
containerRegistry: 'fusion-aks-cr'
repository: $(imageRepo)
command: buildAndPush
buildContext: ./src/backend
dockerfile: src/backend/api/Fusion.Resources.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:
initBuilderInstance: false
Expand All @@ -65,13 +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=crfsharedhostingall.azurecr.io/$(imageRepo):$(prNumber)

- task: CopyFiles@2
displayName: 'Copy Files to: $(Build.ArtifactStagingDirectory)'
inputs:
SourceFolder: 'src/backend/api/Fusion.Resources.Api/Deployment/k8s'
Contents: |
deployment-pr-env.yml
pr-deployment-env.yml
TargetFolder: '$(Build.ArtifactStagingDirectory)'
- publish: $(Build.ArtifactStagingDirectory)
artifact: 'k8s-deployment'
Expand All @@ -84,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 @@ -162,9 +153,11 @@ stages:
azureSubscription: $(subscriptionService)
dbTagPrefix: resources


- 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)
Loading