зеркало из https://github.com/Azure/ARO-RP.git
Scaffolding for CI environment setup in Azure (#3838)
* adding CI dev template files and scripts
This commit is contained in:
Родитель
c75e175821
Коммит
68bc93250c
|
@ -0,0 +1,25 @@
|
|||
# Prepare the CI environment
|
||||
|
||||
Follow these steps to build a shared CI environment.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
1. You will need `Contributor` and `User Access Administrator` roles on your
|
||||
Azure subscription.
|
||||
|
||||
1. Set the az account
|
||||
```bash
|
||||
az account set -n "<your-azure-subscription>"
|
||||
```
|
||||
|
||||
1. You will need to set the proper resource group for global infrastructure
|
||||
```bash
|
||||
export GLOBAL_RESOURCEGROUP=global-infra
|
||||
```
|
||||
|
||||
1. Run the following shell script to configure and deploy the CI components.
|
||||
|
||||
```bash
|
||||
./hack/devtools/deploy-ci-env.sh
|
||||
|
||||
```
|
|
@ -0,0 +1,29 @@
|
|||
#!/bin/bash -e
|
||||
######## Helper file to set up CI Environment ########
|
||||
|
||||
create_infra_rg() {
|
||||
echo "########## Creating RG $RESOURCEGROUP in $LOCATION ##########"
|
||||
az group create -g "$RESOURCEGROUP" -l "$LOCATION" --tags persist=true >/dev/null
|
||||
}
|
||||
|
||||
deploy_aro_ci_acr() {
|
||||
echo "########## Creating CI ACR in RG $RESOURCEGROUP ##########"
|
||||
az deployment group create \
|
||||
--name aro-ci-acr \
|
||||
--resource-group $RESOURCEGROUP \
|
||||
--template-file pkg/deploy/assets/ci-development.json
|
||||
}
|
||||
|
||||
echo "##########################################"
|
||||
echo "##### ARO V4 CI Env helper sourced ######"
|
||||
echo "##########################################"
|
||||
echo "########## Current settings : ############"
|
||||
echo "RESOURCEGROUP=$RESOURCEGROUP"
|
||||
echo
|
||||
echo "AZURE_SUBSCRIPTION_ID=$AZURE_SUBSCRIPTION_ID"
|
||||
echo
|
||||
echo "LOCATION=$LOCATION"
|
||||
echo "######################################"
|
||||
|
||||
[ "$LOCATION" ] || ( echo ">> LOCATION is not set please validate your ./secrets/env"; exit 128 )
|
||||
[ "$RESOURCEGROUP" ] || ( echo ">> RESOURCEGROUP is not set please validate your ./secrets/env"; exit 128 )
|
|
@ -0,0 +1,32 @@
|
|||
{
|
||||
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
|
||||
"contentVersion": "1.0.0.0",
|
||||
"parameters": {
|
||||
"acrLocationOverride": {
|
||||
"type": "string",
|
||||
"defaultValue": "eastus"
|
||||
},
|
||||
"acrName": {
|
||||
"type": "string",
|
||||
"defaultValue": "arosvcdev"
|
||||
},
|
||||
"acrResourceId": {
|
||||
"type": "string",
|
||||
"defaultValue": "Microsoft.ContainerRegistry/registries"
|
||||
}
|
||||
},
|
||||
"resources": [
|
||||
{
|
||||
"sku": {
|
||||
"name": "Premium"
|
||||
},
|
||||
"properties": {
|
||||
"dataEndpointEnabled": true
|
||||
},
|
||||
"name": "[parameters('acrName')]",
|
||||
"type": "Microsoft.ContainerRegistry/registries",
|
||||
"location": "[if(equals(parameters('acrLocationOverride'), ''), resourceGroup().location, parameters('acrLocationOverride'))]",
|
||||
"apiVersion": "2020-11-01-preview"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -27,6 +27,7 @@ const (
|
|||
fileRPDevelopment = "rp-development.json"
|
||||
|
||||
fileMiwiDevelopment = "rp-development-miwi.json"
|
||||
fileCIDevelopment = "ci-development.json"
|
||||
|
||||
// Tag constants
|
||||
tagKeyExemptPublicBlob = "Az.Sec.AnonymousBlobAccessEnforcement::Skip"
|
||||
|
|
|
@ -108,6 +108,10 @@ func (g *generator) Artifacts() error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = g.writeTemplate(g.ciDevelopmentTemplate(), fileCIDevelopment)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
package generator
|
||||
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the Apache License 2.0.
|
||||
|
||||
import (
|
||||
mgmtcontainerregistry "github.com/Azure/azure-sdk-for-go/services/preview/containerregistry/mgmt/2020-11-01-preview/containerregistry"
|
||||
"github.com/Azure/go-autorest/autorest/to"
|
||||
|
||||
"github.com/Azure/ARO-RP/pkg/util/arm"
|
||||
"github.com/Azure/ARO-RP/pkg/util/azureclient"
|
||||
)
|
||||
|
||||
func (g *generator) ciACR() *arm.Resource {
|
||||
return &arm.Resource{
|
||||
Resource: &mgmtcontainerregistry.Registry{
|
||||
Sku: &mgmtcontainerregistry.Sku{
|
||||
Name: mgmtcontainerregistry.Premium,
|
||||
},
|
||||
RegistryProperties: &mgmtcontainerregistry.RegistryProperties{
|
||||
DataEndpointEnabled: to.BoolPtr(true),
|
||||
},
|
||||
Name: to.StringPtr("[parameters('acrName')]"),
|
||||
Type: to.StringPtr("Microsoft.ContainerRegistry/registries"),
|
||||
Location: to.StringPtr("[if(equals(parameters('acrLocationOverride'), ''), resourceGroup().location, parameters('acrLocationOverride'))]"),
|
||||
},
|
||||
APIVersion: azureclient.APIVersion("Microsoft.ContainerRegistry"),
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
package generator
|
||||
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the Apache License 2.0.
|
||||
|
||||
import (
|
||||
"github.com/Azure/ARO-RP/pkg/util/arm"
|
||||
)
|
||||
|
||||
func (g *generator) ciDevelopmentTemplate() *arm.Template {
|
||||
t := templateStanza()
|
||||
|
||||
params := []string{
|
||||
"acrName",
|
||||
"acrLocationOverride",
|
||||
"acrResourceId",
|
||||
}
|
||||
|
||||
for _, param := range params {
|
||||
p := &arm.TemplateParameter{Type: "string"}
|
||||
switch param {
|
||||
case "acrLocationOverride":
|
||||
p.DefaultValue = "eastus"
|
||||
case "acrName":
|
||||
p.DefaultValue = "arosvcdev"
|
||||
case "acrResourceId":
|
||||
p.DefaultValue = "Microsoft.ContainerRegistry/registries"
|
||||
}
|
||||
t.Parameters[param] = p
|
||||
}
|
||||
t.Resources = append(t.Resources,
|
||||
g.ciACR(),
|
||||
)
|
||||
|
||||
return t
|
||||
}
|
Загрузка…
Ссылка в новой задаче