This commit is contained in:
50
packer/azure/.pipelines/build-vhd.yaml
Normal file
50
packer/azure/.pipelines/build-vhd.yaml
Normal file
@ -0,0 +1,50 @@
|
||||
# Required pipeline variables:
|
||||
# - BUILD_POOL - Azure DevOps build pool to use
|
||||
# - CONTAINER_IMAGE - Dev container image URL to use. Should have Azure CLI, Packer and Ansible.
|
||||
# - AZURE_TENANT_ID - tenant ID
|
||||
# - AZURE_CLIENT_ID - Service principal ID
|
||||
# - AZURE_CLIENT_SECRET - Service principal secret
|
||||
# - AZURE_SUBSCRIPTION_ID - Subscription ID used by the pipeline
|
||||
# - KUBERNETES_VERSION - version of Kubernetes to build the image with, e.g. `1.16.2`
|
||||
# - OS - target of build e.g. `Ubuntu/Windows`
|
||||
# - OS_VERSION - target of build e.g. `18.04/2004/2019`
|
||||
|
||||
jobs:
|
||||
- job: build_vhd
|
||||
container: $[ variables['CONTAINER_IMAGE'] ]
|
||||
timeoutInMinutes: 120
|
||||
strategy:
|
||||
maxParallel: 0
|
||||
pool:
|
||||
name: $(BUILD_POOL)
|
||||
steps:
|
||||
- template: k8s-config.yaml
|
||||
- script: |
|
||||
set -o pipefail
|
||||
make deps-azure
|
||||
os=$(echo "${OS}" | tr '[:upper:]' '[:lower:]')
|
||||
version=$(echo "${OS_VERSION}" | tr '[:upper:]' '[:lower:]' | tr -d .)
|
||||
export RESOURCE_GROUP_NAME="cluster-api-images"
|
||||
|
||||
# timestamp is in RFC-3339 format to match kubetest
|
||||
export TIMESTAMP="$(date -u '+%Y-%m-%dT%H:%M:%SZ')"
|
||||
export JOB_NAME="${JOB_NAME:-"image-builder-vhd"}"
|
||||
export TAGS="creationTimestamp=${TIMESTAMP} jobName=${JOB_NAME}"
|
||||
printf "${TAGS}" | tee packer/azure/tags.out
|
||||
make build-azure-vhd-$os-$version | tee packer/azure/packer.out
|
||||
displayName: Building VHD
|
||||
workingDirectory: '$(system.defaultWorkingDirectory)/images/capi'
|
||||
env:
|
||||
AZURE_CLIENT_SECRET: $(AZURE_CLIENT_SECRET)
|
||||
- template: generate-sas.yaml
|
||||
- template: vhd-publishing-info.yaml
|
||||
- task: PublishPipelineArtifact@1
|
||||
inputs:
|
||||
artifact: 'publishing-info'
|
||||
path: '$(system.defaultWorkingDirectory)/images/capi/packer/azure/vhd-publishing-info.json'
|
||||
condition: eq(variables.CLEANUP, 'False')
|
||||
- template: delete-storage-account.yaml
|
||||
- script: |
|
||||
chown -R $USER:$USER .
|
||||
displayName: cleanup - chown all files in work directory
|
||||
condition: always()
|
38
packer/azure/.pipelines/create-disk-version.yaml
Normal file
38
packer/azure/.pipelines/create-disk-version.yaml
Normal file
@ -0,0 +1,38 @@
|
||||
# Required pipeline variables:
|
||||
# - BUILD_POOL - Azure DevOps build pool to use
|
||||
# - CONTAINER_IMAGE - Dev container image URL to use. Should have Azure CLI, Packer and Ansible.
|
||||
# - AZURE_TENANT_ID - tenant ID
|
||||
# - AZURE_CLIENT_ID - Service principal ID
|
||||
# - AZURE_CLIENT_SECRET - Service principal secret
|
||||
# - OS - target of build e.g. `Ubuntu/Windows`
|
||||
# - OS_VERSION - target of build e.g. `18.04/2004/2019`
|
||||
|
||||
jobs:
|
||||
- job: create_disk_version
|
||||
container: $[ variables['CONTAINER_IMAGE'] ]
|
||||
timeoutInMinutes: 120
|
||||
strategy:
|
||||
maxParallel: 0
|
||||
pool:
|
||||
name: $(BUILD_POOL)
|
||||
steps:
|
||||
- task: DownloadPipelineArtifact@2
|
||||
inputs:
|
||||
source: current
|
||||
artifact: publishing-info
|
||||
path: $(system.defaultWorkingDirectory)/images/capi/packer/azure/vhd/
|
||||
- task: DownloadPipelineArtifact@2
|
||||
inputs:
|
||||
source: current
|
||||
artifact: sku-info
|
||||
path: $(system.defaultWorkingDirectory)/images/capi/packer/azure/sku/
|
||||
- script: |
|
||||
./scripts/new-disk-version.sh
|
||||
displayName: Create a new marketplace SKU
|
||||
workingDirectory: '$(system.defaultWorkingDirectory)/images/capi/packer/azure'
|
||||
env:
|
||||
AZURE_CLIENT_SECRET: $(AZURE_CLIENT_SECRET)
|
||||
- task: PublishPipelineArtifact@1
|
||||
inputs:
|
||||
artifact: 'version_info'
|
||||
path: '$(system.defaultWorkingDirectory)/images/capi/packer/azure/version.json'
|
34
packer/azure/.pipelines/create-sku.yaml
Normal file
34
packer/azure/.pipelines/create-sku.yaml
Normal file
@ -0,0 +1,34 @@
|
||||
# Required pipeline variables:
|
||||
# - BUILD_POOL - Azure DevOps build pool to use
|
||||
# - CONTAINER_IMAGE - Dev container image URL to use. Should have Azure CLI, Packer and Ansible.
|
||||
# - AZURE_CLIENT_ID - Service principal ID
|
||||
# - AZURE_CLIENT_SECRET - Service principal secret
|
||||
# - AZURE_TENANT_ID - tenant ID
|
||||
# - KUBERNETES_VERSION - version of Kubernetes to create the sku for, e.g. `1.16.2`
|
||||
# - OFFER - the name of the offer to create the sku for
|
||||
# - OS - target of build e.g. `Ubuntu/Windows`
|
||||
# - OS_VERSION - target of build e.g. `18.04/2004/2019/2022-containerd`
|
||||
# - PUBLISHER - the name of the publisher to create the sku for
|
||||
# - SKU_TEMPLATE_FILE - the base template file to use for the sku
|
||||
# - VM_GENERATION - VM generation to use, e.g. `gen2`
|
||||
|
||||
jobs:
|
||||
- job: create_sku
|
||||
container: $[ variables['CONTAINER_IMAGE'] ]
|
||||
timeoutInMinutes: 120
|
||||
strategy:
|
||||
maxParallel: 0
|
||||
pool:
|
||||
name: $(BUILD_POOL)
|
||||
steps:
|
||||
- script: |
|
||||
./scripts/new-sku.sh
|
||||
displayName: Create a new marketplace SKU
|
||||
workingDirectory: '$(system.defaultWorkingDirectory)/images/capi/packer/azure'
|
||||
env:
|
||||
AZURE_CLIENT_SECRET: $(AZURE_CLIENT_SECRET)
|
||||
- task: PublishPipelineArtifact@1
|
||||
inputs:
|
||||
artifact: 'sku-info'
|
||||
path: '$(system.defaultWorkingDirectory)/images/capi/packer/azure/sku-publishing-info.json'
|
||||
|
13
packer/azure/.pipelines/delete-storage-account.yaml
Normal file
13
packer/azure/.pipelines/delete-storage-account.yaml
Normal file
@ -0,0 +1,13 @@
|
||||
steps:
|
||||
- script: |
|
||||
set -o pipefail
|
||||
RESOURCE_GROUP_NAME=$(jq -r '.builds[-1].custom_data.resource_group_name' manifest.json | cut -d ":" -f2)
|
||||
STORAGE_ACCOUNT_NAME=$(jq -r '.builds[-1].custom_data.storage_account_name' manifest.json | cut -d ":" -f2)
|
||||
az login --service-principal -u ${AZURE_CLIENT_ID} -p ${AZURE_CLIENT_SECRET} --tenant ${AZURE_TENANT_ID}
|
||||
az account set -s ${AZURE_SUBSCRIPTION_ID}
|
||||
az storage account delete -n ${STORAGE_ACCOUNT_NAME} -g ${RESOURCE_GROUP_NAME} --yes
|
||||
displayName: cleanup - delete storage account
|
||||
workingDirectory: '$(system.defaultWorkingDirectory)/images/capi'
|
||||
condition: eq(variables.CLEANUP, 'True')
|
||||
env:
|
||||
AZURE_CLIENT_SECRET: $(AZURE_CLIENT_SECRET)
|
21
packer/azure/.pipelines/generate-sas.yaml
Normal file
21
packer/azure/.pipelines/generate-sas.yaml
Normal file
@ -0,0 +1,21 @@
|
||||
steps:
|
||||
- script: |
|
||||
set -o pipefail
|
||||
RESOURCE_GROUP_NAME=$(jq -r '.builds[-1].custom_data.resource_group_name' manifest.json | cut -d ":" -f2)
|
||||
STORAGE_ACCOUNT_NAME=$(jq -r '.builds[-1].custom_data.storage_account_name' manifest.json | cut -d ":" -f2)
|
||||
OS_DISK_URI=$(cat packer/azure/packer.out | grep "OSDiskUri:" -m 1 | cut -d " " -f 2)
|
||||
printf "${STORAGE_ACCOUNT_NAME}" | tee packer/azure/storage-account-name.out
|
||||
printf "${OS_DISK_URI}" | tee packer/azure/vhd-base-url.out
|
||||
printf "${OS_DISK_URI}?" | tee packer/azure/vhd-url.out
|
||||
printf "${RESOURCE_GROUP_NAME}" | tee packer/azure/resource-group-name.out
|
||||
az login --service-principal -u ${AZURE_CLIENT_ID} -p ${AZURE_CLIENT_SECRET} --tenant ${AZURE_TENANT_ID}
|
||||
az account set -s ${AZURE_SUBSCRIPTION_ID}
|
||||
ACCOUNT_KEY=$(az storage account keys list -g ${RESOURCE_GROUP_NAME} --subscription ${AZURE_SUBSCRIPTION_ID} --account-name ${STORAGE_ACCOUNT_NAME} --query '[0].value')
|
||||
start_date=$(date +"%Y-%m-%dT00:00Z" -d "-1 day")
|
||||
expiry_date=$(date +"%Y-%m-%dT00:00Z" -d "+1 year")
|
||||
az storage container generate-sas --name system --permissions lr --account-name ${STORAGE_ACCOUNT_NAME} --account-key ${ACCOUNT_KEY} --start $start_date --expiry $expiry_date | tr -d '\"' | tee -a packer/azure/vhd-url.out
|
||||
displayName: Getting OS VHD URL
|
||||
workingDirectory: '$(system.defaultWorkingDirectory)/images/capi'
|
||||
condition: eq(variables.CLEANUP, 'False')
|
||||
env:
|
||||
AZURE_CLIENT_SECRET: $(AZURE_CLIENT_SECRET)
|
15
packer/azure/.pipelines/k8s-config.yaml
Normal file
15
packer/azure/.pipelines/k8s-config.yaml
Normal file
@ -0,0 +1,15 @@
|
||||
steps:
|
||||
- script: |
|
||||
KUBERNETES_RELEASE=$(echo ${KUBERNETES_VERSION} | cut -d "." -f -2)
|
||||
sed -i "s/.*kubernetes_series.*/ \"kubernetes_series\": \"v${KUBERNETES_RELEASE}\",/g" kubernetes.json
|
||||
sed -i "s/.*kubernetes_semver.*/ \"kubernetes_semver\": \"v${KUBERNETES_VERSION}\",/g" kubernetes.json
|
||||
if [[ "${KUBERNETES_VERSION:-}" == "1.16.11" || "${KUBERNETES_VERSION:-}" == "1.17.7" || "${KUBERNETES_VERSION:-}" == "1.18.4" ]]; then
|
||||
sed -i "s/.*kubernetes_rpm_version.*/ \"kubernetes_rpm_version\": \"${KUBERNETES_VERSION}-1\",/g" kubernetes.json
|
||||
sed -i "s/.*kubernetes_deb_version.*/ \"kubernetes_deb_version\": \"${KUBERNETES_VERSION}-01\",/g" kubernetes.json
|
||||
else
|
||||
sed -i "s/.*kubernetes_rpm_version.*/ \"kubernetes_rpm_version\": \"${KUBERNETES_VERSION}-0\",/g" kubernetes.json
|
||||
sed -i "s/.*kubernetes_deb_version.*/ \"kubernetes_deb_version\": \"${KUBERNETES_VERSION}-00\",/g" kubernetes.json
|
||||
fi
|
||||
cat kubernetes.json
|
||||
displayName: Write configuration files
|
||||
workingDirectory: '$(system.defaultWorkingDirectory)/images/capi/packer/config'
|
59
packer/azure/.pipelines/smoke-test.yaml
Normal file
59
packer/azure/.pipelines/smoke-test.yaml
Normal file
@ -0,0 +1,59 @@
|
||||
# Required pipeline variables:
|
||||
# - BUILD_POOL - Azure DevOps build pool to use
|
||||
# - CONTAINER_IMAGE - Dev container image URL to use. Should have Azure CLI, Packer and Ansible.
|
||||
# - AZURE_TENANT_ID_VHD - tenant ID to build the vhd
|
||||
# - AZURE_CLIENT_ID_VHD - Service principal ID to build the vhd
|
||||
# - AZURE_CLIENT_SECRET_VHD - Service principal secret to build the vhd
|
||||
# - AZURE_SUBSCRIPTION_ID_VHD - Subscription ID to build the vhd
|
||||
# - KUBERNETES_VERSION - version of Kubernetes to create the sku for, e.g. `1.21.3`
|
||||
# - CLEANUP - whether or not to clean up resources created in the run
|
||||
|
||||
trigger: none
|
||||
|
||||
schedules:
|
||||
- cron: "0 1 * * *"
|
||||
displayName: "nightly build"
|
||||
always: true
|
||||
branches:
|
||||
include:
|
||||
- master
|
||||
|
||||
stages:
|
||||
- stage: vhd
|
||||
jobs:
|
||||
- job:
|
||||
container: $[ variables['CONTAINER_IMAGE'] ]
|
||||
timeoutInMinutes: 120
|
||||
pool:
|
||||
name: $(BUILD_POOL)
|
||||
steps:
|
||||
- template: k8s-config.yaml
|
||||
- script: |
|
||||
set -o pipefail
|
||||
make deps-azure
|
||||
os=$(echo "$OS" | tr '[:upper:]' '[:lower:]')
|
||||
version=$(echo "$OS_VERSION" | tr '[:upper:]' '[:lower:]' | tr -d .)
|
||||
make build-azure-vhd-$os-$version | tee packer/azure/packer.out
|
||||
displayName: Building VHD
|
||||
workingDirectory: '$(system.defaultWorkingDirectory)/images/capi'
|
||||
env:
|
||||
AZURE_CLIENT_SECRET: $(AZURE_CLIENT_SECRET)
|
||||
- template: delete-storage-account.yaml
|
||||
- script: |
|
||||
chown -R $USER:$USER .
|
||||
displayName: cleanup - chown all files in work directory
|
||||
condition: always()
|
||||
strategy:
|
||||
maxParallel: 0
|
||||
matrix:
|
||||
Windows:
|
||||
OS: Windows
|
||||
OS_VERSION: 2019
|
||||
Linux:
|
||||
OS: Ubuntu
|
||||
OS_VERSION: 2004
|
||||
variables:
|
||||
AZURE_TENANT_ID: $(AZURE_TENANT_ID_VHD)
|
||||
AZURE_CLIENT_ID: $(AZURE_CLIENT_ID_VHD)
|
||||
AZURE_CLIENT_SECRET: $(AZURE_CLIENT_SECRET_VHD)
|
||||
AZURE_SUBSCRIPTION_ID: $(AZURE_SUBSCRIPTION_ID_VHD)
|
57
packer/azure/.pipelines/stages.yaml
Normal file
57
packer/azure/.pipelines/stages.yaml
Normal file
@ -0,0 +1,57 @@
|
||||
# Required pipeline variables:
|
||||
# - BUILD_POOL - Azure DevOps build pool to use
|
||||
# - CONTAINER_IMAGE - Dev container image URL to use. Should have Azure CLI, Packer and Ansible.
|
||||
# - AZURE_TENANT_ID_VHD - tenant ID to build the vhd
|
||||
# - AZURE_CLIENT_ID_VHD - Service principal ID to build the vhd
|
||||
# - AZURE_CLIENT_SECRET_VHD - Service principal secret to build the vhd
|
||||
# - AZURE_SUBSCRIPTION_ID_VHD - Subscription ID to build the vhd
|
||||
# - AZURE_TENANT_ID_SKU - tenant ID to PUT the SKU
|
||||
# - AZURE_CLIENT_ID_SKU - Service principal ID to PUT the SKU
|
||||
# - AZURE_CLIENT_SECRET_SKU - Service principal secret to PUT the SKU
|
||||
# - KUBERNETES_VERSION - version of Kubernetes to create the sku for, e.g. `1.16.2`
|
||||
# - PUBLISHER - the name of the publisher to create the sku for
|
||||
# - OFFER - the name of the offer to create the sku for
|
||||
# - SKU_TEMPLATE_FILE - the base template file to use for the sku
|
||||
# - OS - target of build e.g. `Ubuntu/Windows`
|
||||
# - OS_VERSION - target of build e.g. `18.04/2004/2019`
|
||||
|
||||
trigger: none
|
||||
pr: none
|
||||
|
||||
stages:
|
||||
- stage: vhd
|
||||
jobs:
|
||||
- template: build-vhd.yaml
|
||||
variables:
|
||||
AZURE_TENANT_ID: $(AZURE_TENANT_ID_VHD)
|
||||
AZURE_CLIENT_ID: $(AZURE_CLIENT_ID_VHD)
|
||||
AZURE_CLIENT_SECRET: $(AZURE_CLIENT_SECRET_VHD)
|
||||
AZURE_SUBSCRIPTION_ID: $(AZURE_SUBSCRIPTION_ID_VHD)
|
||||
|
||||
- stage: test
|
||||
condition: and(succeeded(), eq(variables.CLEANUP, 'False'))
|
||||
jobs:
|
||||
- template: test-vhd.yaml
|
||||
variables:
|
||||
AZURE_TENANT_ID: $(AZURE_TENANT_ID_VHD)
|
||||
AZURE_CLIENT_ID: $(AZURE_CLIENT_ID_VHD)
|
||||
AZURE_CLIENT_SECRET: $(AZURE_CLIENT_SECRET_VHD)
|
||||
AZURE_SUBSCRIPTION_ID: $(AZURE_SUBSCRIPTION_ID_VHD)
|
||||
|
||||
- stage: sku
|
||||
condition: and(succeeded(), eq(variables.CLEANUP, 'False'))
|
||||
jobs:
|
||||
- template: create-sku.yaml
|
||||
variables:
|
||||
AZURE_TENANT_ID: $(AZURE_TENANT_ID_SKU)
|
||||
AZURE_CLIENT_ID: $(AZURE_CLIENT_ID_SKU)
|
||||
AZURE_CLIENT_SECRET: $(AZURE_CLIENT_SECRET_SKU)
|
||||
|
||||
- stage: disk_version
|
||||
condition: and(succeeded(), eq(variables.CLEANUP, 'False'))
|
||||
jobs:
|
||||
- template: create-disk-version.yaml
|
||||
variables:
|
||||
AZURE_TENANT_ID: $(AZURE_TENANT_ID_SKU)
|
||||
AZURE_CLIENT_ID: $(AZURE_CLIENT_ID_SKU)
|
||||
AZURE_CLIENT_SECRET: $(AZURE_CLIENT_SECRET_SKU)
|
143
packer/azure/.pipelines/test-vhd.yaml
Normal file
143
packer/azure/.pipelines/test-vhd.yaml
Normal file
@ -0,0 +1,143 @@
|
||||
# Required pipeline variables:
|
||||
# - BUILD_POOL - Azure DevOps build pool to use
|
||||
# - CONTAINER_IMAGE - Dev container image URL to use. Should have Azure CLI, Packer, and Ansible.
|
||||
# - AZ_CAPI_EXTENSION_URL - URL to the Azure CAPI extension build.
|
||||
# - AZURE_TENANT_ID - tenant ID
|
||||
# - AZURE_CLIENT_ID - Service principal ID
|
||||
# - AZURE_CLIENT_SECRET - Service principal secret
|
||||
# - AZURE_SUBSCRIPTION_ID - Subscription ID used by the pipeline
|
||||
# - KUBERNETES_VERSION - version of Kubernetes to build the image with, e.g. `1.16.2`
|
||||
# - OS - target of build e.g. `Ubuntu/Windows`
|
||||
# - OS_VERSION - target of build e.g. `18.04/2004/2019`
|
||||
|
||||
jobs:
|
||||
- job: test_vhd
|
||||
container: $[ variables['CONTAINER_IMAGE'] ]
|
||||
timeoutInMinutes: 120
|
||||
strategy:
|
||||
maxParallel: 0
|
||||
pool:
|
||||
name: $(BUILD_POOL)
|
||||
steps:
|
||||
- task: DownloadPipelineArtifact@2
|
||||
inputs:
|
||||
source: current
|
||||
artifact: publishing-info
|
||||
path: $(system.defaultWorkingDirectory)/images/capi/packer/azure/vhd/
|
||||
- script: |
|
||||
set -x
|
||||
set -e -o pipefail
|
||||
|
||||
VHD_RESOURCE_ID=$(jq -r .vhd_base_url $(system.defaultWorkingDirectory)/images/capi/packer/azure/vhd/vhd-publishing-info.json)
|
||||
STORAGE_ACCOUNT_NAME=$(jq -r .storage_account_name $(system.defaultWorkingDirectory)/images/capi/packer/azure/vhd/vhd-publishing-info.json)
|
||||
TAGS=$(jq -r .tags $(system.defaultWorkingDirectory)/images/capi/packer/azure/vhd/vhd-publishing-info.json)
|
||||
|
||||
echo "##vso[task.setvariable variable=VHD_RESOURCE_ID]$VHD_RESOURCE_ID"
|
||||
echo "##vso[task.setvariable variable=STORAGE_ACCOUNT_NAME]$STORAGE_ACCOUNT_NAME"
|
||||
echo "##vso[task.setvariable variable=TAGS;]$TAGS"
|
||||
displayName: Import variables from build vhd job
|
||||
env:
|
||||
AZURE_CLIENT_SECRET: $(AZURE_CLIENT_SECRET)
|
||||
- script: |
|
||||
set -x
|
||||
set -e -o pipefail
|
||||
|
||||
RANDOM=$(bash -c 'echo $RANDOM')
|
||||
RESOURCE_GROUP="capi-testvmimage-${RANDOM}"
|
||||
echo "${RESOURCE_GROUP}" is the group
|
||||
|
||||
# Azure CLI login
|
||||
az login -u $AZURE_CLIENT_ID -p $AZURE_CLIENT_SECRET --service-principal --tenant $AZURE_TENANT_ID
|
||||
|
||||
# Find the VHD blob location from its storage account
|
||||
AZURE_LOCATION=$(az storage account show --name "${STORAGE_ACCOUNT_NAME}" --query '[location]' -o tsv)
|
||||
|
||||
# Create the resource group
|
||||
az group create --name "${RESOURCE_GROUP}" --location "${AZURE_LOCATION}" --tags "${TAGS}"
|
||||
|
||||
# Create a managed image from the VHD blob
|
||||
OS_TYPE="Linux"
|
||||
if [ "$OS" == "Windows" ]; then
|
||||
OS_TYPE="Windows"
|
||||
fi
|
||||
az image create -n testvmimage -g "${RESOURCE_GROUP}" --os-type "${OS_TYPE}" --source "${VHD_RESOURCE_ID}"
|
||||
|
||||
# Pass the managed image resource ID on to the next step
|
||||
IMAGE_ID=$(az image show -g "${RESOURCE_GROUP}" -n testvmimage --query '[id]' --output tsv)
|
||||
echo "##vso[task.setvariable variable=RESOURCE_GROUP;]$RESOURCE_GROUP"
|
||||
echo "##vso[task.setvariable variable=MANAGED_IMAGE_ID;]$IMAGE_ID"
|
||||
echo "##vso[task.setvariable variable=AZURE_LOCATION;]$AZURE_LOCATION"
|
||||
displayName: promote VHD blob to managed image
|
||||
env:
|
||||
AZURE_CLIENT_SECRET: $(AZURE_CLIENT_SECRET)
|
||||
- template: k8s-config.yaml
|
||||
- script: |
|
||||
set -x
|
||||
set -e -o pipefail
|
||||
|
||||
export PATH=${PATH}:.local/bin
|
||||
./packer/azure/scripts/ensure-kustomize.sh
|
||||
|
||||
# Generate cluster template with kustomize
|
||||
if [ "$OS" == "Windows" ]; then
|
||||
kustomize build --load-restrictor LoadRestrictionsNone $(system.defaultWorkingDirectory)/images/capi/packer/azure/scripts/test-templates/windows/ > $(system.defaultWorkingDirectory)/images/capi/packer/azure/scripts/test-templates/cluster-template.yaml
|
||||
else
|
||||
kustomize build --load-restrictor LoadRestrictionsNone $(system.defaultWorkingDirectory)/images/capi/packer/azure/scripts/test-templates/linux/ > $(system.defaultWorkingDirectory)/images/capi/packer/azure/scripts/test-templates/cluster-template.yaml
|
||||
fi
|
||||
TEST_TEMPLATE=$(system.defaultWorkingDirectory)/images/capi/packer/azure/scripts/test-templates/cluster-template.yaml
|
||||
echo "##vso[task.setvariable variable=TEST_TEMPLATE;]$TEST_TEMPLATE"
|
||||
displayName: generate cluster template
|
||||
workingDirectory: '$(system.defaultWorkingDirectory)/images/capi'
|
||||
env:
|
||||
AZURE_CLIENT_SECRET: $(AZURE_CLIENT_SECRET)
|
||||
- script: |
|
||||
set -x
|
||||
set -e -o pipefail
|
||||
|
||||
os=$(echo "$OS" | tr '[:upper:]' '[:lower:]')
|
||||
|
||||
# Set up the Azure CLI Cluster API extension
|
||||
# https://github.com/Azure/azure-capi-cli-extension/releases/download/az-capi-nightly/capi-0.0.vnext-py2.py3-none-any.whl
|
||||
az extension add --yes --source "${AZ_CAPI_EXTENSION_URL}"
|
||||
|
||||
# Install required binaries
|
||||
mkdir ~/test-binaries
|
||||
export PATH=${PATH}:~/test-binaries
|
||||
az capi install -a -ip ~/test-binaries
|
||||
|
||||
echo "##vso[task.setvariable variable=PATH;]$PATH"
|
||||
displayName: Install and configure az capi extension
|
||||
env:
|
||||
AZURE_CLIENT_SECRET: $(AZURE_CLIENT_SECRET)
|
||||
- script: |
|
||||
params=()
|
||||
if [ "$OS" == "Windows" ]; then
|
||||
params+=(--windows)
|
||||
fi
|
||||
|
||||
# Create a cluster
|
||||
az capi create \
|
||||
--yes \
|
||||
--debug \
|
||||
--name testvm \
|
||||
--kubernetes-version="${KUBERNETES_VERSION}" \
|
||||
--location="${AZURE_LOCATION}" \
|
||||
--resource-group="${RESOURCE_GROUP}" \
|
||||
--management-cluster-resource-group-name="${RESOURCE_GROUP}" \
|
||||
--control-plane-machine-count=1 \
|
||||
--node-machine-count=1 \
|
||||
--template="${TEST_TEMPLATE}" \
|
||||
--tags="${TAGS}" \
|
||||
--wait-for-nodes=2 \
|
||||
"${params[@]}"
|
||||
displayName: Create a cluster
|
||||
env:
|
||||
AZURE_CLIENT_SECRET: $(AZURE_CLIENT_SECRET)
|
||||
- script: |
|
||||
set -x
|
||||
set -e -o pipefail
|
||||
|
||||
# Clean up the test resource group
|
||||
az group delete -n "${RESOURCE_GROUP}" --yes --no-wait
|
||||
displayName: Clean up test resource group
|
||||
condition: always()
|
19
packer/azure/.pipelines/vhd-publishing-info.yaml
Normal file
19
packer/azure/.pipelines/vhd-publishing-info.yaml
Normal file
@ -0,0 +1,19 @@
|
||||
steps:
|
||||
- script: |
|
||||
VHD_BASE_URL="$(cat packer/azure/vhd-base-url.out)"
|
||||
VHD_URL="$(cat packer/azure/vhd-url.out)"
|
||||
STORAGE_ACCOUNT_NAME="$(cat packer/azure/storage-account-name.out)"
|
||||
RESOURCE_GROUP_NAME="$(cat packer/azure/resource-group-name.out)"
|
||||
TAGS="$(cat packer/azure/tags.out)"
|
||||
cat <<EOF > packer/azure/vhd-publishing-info.json
|
||||
{
|
||||
"vhd_base_url": "${VHD_BASE_URL}",
|
||||
"vhd_url": "${VHD_URL}",
|
||||
"storage_account_name": "${STORAGE_ACCOUNT_NAME}",
|
||||
"resource_group_name": "${RESOURCE_GROUP_NAME}",
|
||||
"tags": "${TAGS}"
|
||||
}
|
||||
EOF
|
||||
displayName: Generating publishing info for VHD
|
||||
workingDirectory: '$(system.defaultWorkingDirectory)/images/capi'
|
||||
condition: eq(variables.CLEANUP, 'False')
|
Reference in New Issue
Block a user