2022-03-11 19:20:08 +03:00
2022-03-30 13:39:18 +03:00
name : 'Deploy CARML based AKS Cluster'
2022-03-11 19:20:08 +03:00
on :
workflow_dispatch :
2022-03-23 13:35:50 +03:00
inputs :
2022-03-30 13:37:14 +03:00
ENVIRONMENT :
description : 'A GitHub Environment to pull action secrets from'
2022-03-23 13:35:50 +03:00
required : true
2022-03-30 13:37:14 +03:00
type : environment
REGION :
description : 'The Azure region to deploy to'
2022-03-23 13:35:50 +03:00
required : true
2022-03-30 13:37:14 +03:00
default : eastus
2022-03-11 19:20:08 +03:00
env :
event_sha : +refs/pull/${{ github.event.issue.number }}/merge
jobs :
2022-03-23 14:15:58 +03:00
prereqs :
runs-on : ubuntu-latest
2022-03-30 13:37:14 +03:00
environment : ${{ inputs.ENVIRONMENT }}
2022-03-23 14:21:31 +03:00
name : Prerequisite Checks
2022-03-23 14:15:58 +03:00
steps :
- name : "Checkout"
uses : actions/checkout@v2
with :
fetch-depth : 0
- name : "Azure Login"
uses : azure/login@v1
with :
2022-03-30 13:37:14 +03:00
creds : ${{ secrets.AZURE_CREDENTIALS }}
2022-03-23 14:15:58 +03:00
#Helps with errors that can occur during deployment: OIDCIssuerFeatureFlagNotEnabled: Enabling OIDC issuer is not allowed since feature 'Microsoft.ContainerService/EnableOIDCIssuerPreview' is not enabled
# AzureDefenderFeatureFlagNotEnabled: AzureDefender installation is not allowed since feature 'Microsoft.ContainerService/AKS-AzureDefender' is not enabled.
- name : "Check Preview Features"
shell : pwsh
run : |
2022-03-28 17:27:54 +03:00
write-output "Verifying required Resource Providers Features are registered"
2022-03-23 14:15:58 +03:00
$aksfeatures = az feature list --query "[?contains(name, 'Microsoft.ContainerService')]" | ConvertFrom-Json
2022-03-28 17:27:54 +03:00
$featureName='AKS-ExtensionManager'
write-output "-- $featureName"
$feature = $aksfeatures | Where-Object {$_.name -like "*$featureName"}
$feature.properties.state
if ($feature.properties.state -ne 'Registered') {
Write-Output $feature
Write-Error "$featureName NOT registered"
}
2022-03-23 14:21:31 +03:00
$featureName='EnableOIDCIssuerPreview'
write-output "-- $featureName"
$feature = $aksfeatures | Where-Object {$_.name -like "*$featureName"}
$feature.properties.state
if ($feature.properties.state -ne 'Registered') {
Write-Output $feature
Write-Error "$featureName NOT registered"
}
$featureName='AKS-AzureDefender'
write-output "-- $featureName"
$feature = $aksfeatures | Where-Object {$_.name -like "*$featureName"}
$feature.properties.state
if ($feature.properties.state -ne 'Registered') {
Write-Output $feature
Write-Error "$featureName NOT registered"
2022-03-23 14:15:58 +03:00
}
2022-03-11 19:20:08 +03:00
deployment :
runs-on : ubuntu-latest
2022-03-30 13:37:14 +03:00
environment : ${{ inputs.ENVIRONMENT }}
2022-03-28 17:28:37 +03:00
name : Deployment
2022-03-23 14:15:58 +03:00
needs : [ prereqs]
2022-03-11 19:20:08 +03:00
steps :
- name : "Checkout"
uses : actions/checkout@v2
with :
fetch-depth : 0
2022-03-23 13:16:53 +03:00
2022-03-11 19:20:08 +03:00
- name : "Azure Login"
uses : azure/login@v1
with :
2022-03-30 13:37:14 +03:00
creds : ${{ secrets.AZURE_CREDENTIALS }}
2022-03-23 13:16:53 +03:00
2022-03-11 19:20:08 +03:00
- name : "Deploy Hub"
id : hub
uses : azure/arm-deploy@v1
with :
2022-03-30 13:37:14 +03:00
subscriptionId : ${{ secrets.SUBSCRIPTION_ID }}
region : ${{ inputs.REGION }}
2022-03-11 19:20:08 +03:00
scope : subscription
template : ./IaC/bicep/rg-hub/hub-default.bicep
2022-03-23 12:14:58 +03:00
parameters : ./IaC/bicep/rg-hub/hub-default.parameters.json
2022-03-11 19:20:08 +03:00
failOnStdErr : false
2022-03-23 13:16:53 +03:00
2022-03-11 19:20:08 +03:00
- name : "Deploy Spoke"
id : spoke
uses : azure/arm-deploy@v1
with :
2022-03-30 13:37:14 +03:00
subscriptionId : ${{ secrets.SUBSCRIPTION_ID }}
region : ${{ inputs.REGION }}
2022-03-11 19:20:08 +03:00
scope : subscription
template : ./IaC/bicep/rg-spoke/spoke.bicep
2022-03-23 12:14:58 +03:00
parameters : ./IaC/bicep/rg-spoke/spoke.parameters.json hubVnetResourceId=${{ steps.hub.outputs.hubVnetId }} hubLaWorkspaceResourceId=${{ steps.hub.outputs.hubLaWorkspaceResourceId }} hubFwResourceId=${{ steps.hub.outputs.hubFwResourceId }}
2022-03-11 19:20:08 +03:00
failOnStdErr : false
2022-03-23 13:16:53 +03:00
2022-03-11 19:20:08 +03:00
- name : "Deploy Cluster"
id : cluster
uses : azure/arm-deploy@v1
with :
2022-03-30 13:37:14 +03:00
subscriptionId : ${{ secrets.SUBSCRIPTION_ID }}
region : ${{ inputs.REGION }}
2022-03-11 19:20:08 +03:00
scope : subscription
template : ./IaC/bicep/rg-spoke/cluster.bicep
2022-03-30 13:37:14 +03:00
parameters : ./IaC/bicep/rg-spoke/cluster.parameters.json targetVnetResourceId=${{ steps.spoke.outputs.clusterVnetResourceId }}
#clusterAdminAadGroupObjectId=${{ github.event.inputs.clusterAdminAadGroupObjectId }} a0008NamespaceReaderAadGroupObjectId=${{ github.event.inputs.a0008NamespaceReaderAadGroupObjectId }}
2022-03-11 19:20:08 +03:00
failOnStdErr : false
2022-03-23 13:16:53 +03:00
2022-03-11 19:20:08 +03:00
- name : "Deploy Registry"
id : registry
uses : azure/arm-deploy@v1
with :
2022-03-30 13:37:14 +03:00
subscriptionId : ${{ secrets.SUBSCRIPTION_ID }}
region : ${{ inputs.REGION }}
2022-03-11 19:20:08 +03:00
scope : subscription
template : ./IaC/bicep/rg-spoke/acr.bicep
2022-03-23 12:14:58 +03:00
parameters : ./IaC/bicep/rg-spoke/acr.parameters.json targetVnetResourceId=${{ steps.spoke.outputs.clusterVnetResourceId }}
2022-03-11 19:20:08 +03:00
failOnStdErr : false