From a40992b120504ea9c511335c76bd16f7b9947a36 Mon Sep 17 00:00:00 2001 From: Gerd Oberlechner Date: Mon, 2 Dec 2024 12:07:28 +0100 Subject: [PATCH] pipeline chaining example (#913) * pipeline chaining example propose a format for pipeline chaining to be used in both EV2 and local runner. * introduce the concept for output bicep templates that provide relevant metadata for a certain scope (e.g. region, global, mgmt), to be consumed by other scopes * provide a format to declare output consumption for an ARM step in pipeline.yaml this PR also contains an example how the CS MSI ID is provided to the mgmt-cluster.bicep template to setup KV access for CS. Signed-off-by: Gerd Oberlechner --- .../configurations/outputs/region.tmpl.bicepparam | 2 ++ dev-infrastructure/mgmt-pipeline.yaml | 11 +++++++++++ dev-infrastructure/templates/outputs/region.bicep | 10 ++++++++++ tooling/templatize/pkg/pipeline/types.go | 7 +++++++ 4 files changed, 30 insertions(+) create mode 100644 dev-infrastructure/configurations/outputs/region.tmpl.bicepparam create mode 100644 dev-infrastructure/templates/outputs/region.bicep diff --git a/dev-infrastructure/configurations/outputs/region.tmpl.bicepparam b/dev-infrastructure/configurations/outputs/region.tmpl.bicepparam new file mode 100644 index 000000000..ed6a89cce --- /dev/null +++ b/dev-infrastructure/configurations/outputs/region.tmpl.bicepparam @@ -0,0 +1,2 @@ +using '../../templates/outputs/region.bicep' + diff --git a/dev-infrastructure/mgmt-pipeline.yaml b/dev-infrastructure/mgmt-pipeline.yaml index 07d998bb7..dd87f03ec 100644 --- a/dev-infrastructure/mgmt-pipeline.yaml +++ b/dev-infrastructure/mgmt-pipeline.yaml @@ -1,6 +1,13 @@ serviceGroup: Microsoft.Azure.ARO.Test rolloutName: Management Cluster Rollout resourceGroups: +- name: {{ .svc.rg }} + subscription: {{ .svc.subscription }} + steps: + - name: regionOutput + action: ARM + template: templates/outputs/region.bicep + parameters: configurations/outputs/region.tmpl.bicepparam - name: {{ .mgmt.rg }} subscription: {{ .mgmt.subscription }} aksCluster: {{ .aksName }} @@ -9,6 +16,10 @@ resourceGroups: action: ARM template: templates/mgmt-cluster.bicep parameters: configurations/mgmt-cluster.tmpl.bicepparam + inputs: + - name: clusterServiceMIResourceId + step: regionOutput + output: cs.msi.resourceID - name: enable-metrics action: Shell command: ["scripts/enable-aks-metrics.sh"] diff --git a/dev-infrastructure/templates/outputs/region.bicep b/dev-infrastructure/templates/outputs/region.bicep new file mode 100644 index 000000000..2f4bbaa54 --- /dev/null +++ b/dev-infrastructure/templates/outputs/region.bicep @@ -0,0 +1,10 @@ +resource csMSI 'Microsoft.ManagedIdentity/userAssignedIdentities@2023-01-31' = { + name: 'clusters-service' + location: resourceGroup().location +} + +output cs object = { + msi: { + resourceID: csMSI.id + } +} diff --git a/tooling/templatize/pkg/pipeline/types.go b/tooling/templatize/pkg/pipeline/types.go index 6f8bf2b61..ec66d83bf 100644 --- a/tooling/templatize/pkg/pipeline/types.go +++ b/tooling/templatize/pkg/pipeline/types.go @@ -29,6 +29,7 @@ type Step struct { Parameters string `yaml:"parameters,omitempty"` DependsOn []string `yaml:"dependsOn,omitempty"` DryRun DryRun `yaml:"dryRun,omitempty"` + Inputs []Input `yaml:"inputs,omitempty"` outputFunc outPutHandler } @@ -42,3 +43,9 @@ type EnvVar struct { ConfigRef string `yaml:"configRef,omitempty"` Value string `yaml:"value,omitempty"` } + +type Input struct { + Name string `yaml:"name"` + Step string `yaml:"step"` + Output string `yaml:"output"` +}