$schema: "pipeline.schema.v1"
serviceGroup: Microsoft.Azure.ARO.HCP.Management.Infra.Solo
rolloutName: Management Cluster Rollout
resourceGroups:
- name: '{{ .global.rg  }}'
  subscription: '{{ .global.subscription  }}'
  steps:
  - name: global-output
    action: ARM
    template: templates/output-global.bicep
    parameters: configurations/output-global.tmpl.bicepparam
    deploymentLevel: ResourceGroup
    outputOnly: true
- name: '{{ .regionRG  }}'
  subscription: '{{ .svc.subscription  }}'
  steps:
  - name: region-output
    action: ARM
    template: templates/output-region.bicep
    parameters: configurations/output-region.tmpl.bicepparam
    deploymentLevel: ResourceGroup
    outputOnly: true
- name: '{{ .mgmt.rg  }}'
  subscription: '{{ .mgmt.subscription  }}'
  steps:
  - name: mgmt-infra
    action: ARM
    template: templates/mgmt-infra.bicep
    parameters: configurations/mgmt-infra.tmpl.bicepparam
    deploymentLevel: ResourceGroup
    variables:
    - name: clusterServiceMIResourceId
      # we don't need to grant KV permissions to CS as there is no CS in the MC solo deployment
      value: "-"
    - name: logAnalyticsWorkspaceId
      input:
        step: region-output
        name: logAnalyticsWorkspaceId
  # Build the MC
  - name: mgmt-cluster
    action: ARM
    template: templates/mgmt-cluster.bicep
    parameters: configurations/mgmt-cluster.tmpl.bicepparam
    deploymentLevel: ResourceGroup
    variables:
    - name: ocpAcrResourceId
      input:
        step: global-output
        name: ocpAcrResourceId
    - name: svcAcrResourceId
      input:
        step: global-output
        name: svcAcrResourceId
    - name: azureMonitoringWorkspaceId
      input:
        step: region-output
        name: azureMonitoringWorkspaceId
    - name: maestroEventGridNamespaceId
      input:
        step: region-output
        name: maestroEventGridNamespaceId
    - name: logAnalyticsWorkspaceId
      input:
        step: region-output
        name: logAnalyticsWorkspaceId
    dependsOn:
    - mgmt-infra
    - region-output
    - global-output
- name: '{{ .mgmt.rg  }}'
  subscription: '{{ .mgmt.subscription  }}'
  aksCluster: '{{ .mgmt.aks.name  }}'
  steps:
  # Install ACRpull
  - name: acrpull
    action: Shell
    command: make -C ../acrpull deploy
    dryRun:
      variables:
      - name: DRY_RUN
        value: "true"
    variables:
    - name: ACRPULL_DIGEST
      configRef: acrPull.image.digest
    - name: ACRPULL_REPO
      configRef: acrPull.image.repository
    - name: ACRPULL_REGISTRY
      configRef: acrPull.image.registry
    dependsOn:
    - mgmt-cluster
  # Install cluster patches
  - name: mgmt-fixes
    action: Shell
    command: make -C ../mgmt-fixes deploy
    dryRun:
      variables:
      - name: DRY_RUN
        value: "true"
    variables:
    - name: APPLY_KUBELET_FIXES
      configRef: mgmt.applyKubeletFixes
    dependsOn:
    - mgmt-cluster
