generated from kubernetes/kubernetes-template-project
-
Notifications
You must be signed in to change notification settings - Fork 395
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add pipeline for Azure community gallery image publishing
- Loading branch information
Showing
22 changed files
with
494 additions
and
923 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
# Required pipeline variables: | ||
# - BUILD_POOL - Azure DevOps build pool to use | ||
# - KUBERNETES_VERSION - version of Kubernetes to build the image with, e.g. `1.31.1` | ||
# - OS - operating system distro, such as 'Ubuntu', 'AzureLinux', or `Windows` | ||
# - OS_VERSION - version of distro, such as `24.04` or `2022-containerd` | ||
# - SERVICE_CONNECTION - Azure DevOps service connection to use for the Azure CLI | ||
# Optional pipeline variables: | ||
# - RESOURCE_GROUP - name of the Azure resource group to use for the compute galleries | ||
# - STAGING_GALLERY_NAME - name of the Azure compute gallery for initial image publishing | ||
|
||
jobs: | ||
- job: build_sig | ||
timeoutInMinutes: 120 | ||
strategy: | ||
maxParallel: 0 | ||
pool: | ||
name: $(BUILD_POOL) | ||
steps: | ||
- template: k8s-config.yaml | ||
- script: | | ||
set -euo pipefail | ||
[[ -n ${DEBUG:-} ]] && set -o xtrace | ||
kube_proxy_url="sigwindowstools/kube-proxy:v${KUBERNETES_VERSION/+/_}-calico-hostprocess" | ||
echo "Checking for Windows kube-proxy image $kube_proxy_url" | ||
if ! stderr="$(docker pull $kube_proxy_url 2>&1 > /dev/null)"; then | ||
# It's a Windows image, so expect an error after pulling it on Linux | ||
if [[ $stderr != *"cannot be used on this platform"* ]]; then | ||
echo "Failed to pull kube-proxy image: $stderr" | ||
exit 1 | ||
fi | ||
fi | ||
displayName: Check for Windows kube-proxy image | ||
condition: and(eq(variables['PREFLIGHT_CHECKS'], 'true'), eq(variables['OS'], 'Windows')) | ||
- task: AzureCLI@2 | ||
displayName: Build SIG Image | ||
inputs: | ||
azureSubscription: '$(SERVICE_CONNECTION)' | ||
scriptLocation: inlineScript | ||
scriptType: bash | ||
workingDirectory: '$(system.defaultWorkingDirectory)/images/capi' | ||
inlineScript: | | ||
set -euo pipefail | ||
[[ -n ${DEBUG:-} ]] && set -o xtrace | ||
# Generate locales properly on Azure Linux or ansible will complain | ||
sudo tdnf -y install glibc-i18n | ||
sudo locale-gen.sh | ||
export LC_ALL=en_US.UTF-8 | ||
export PATH=$PATH:$HOME/.local/bin | ||
os=$(echo "${OS}" | tr '[:upper:]' '[:lower:]') | ||
version=$(echo "${OS_VERSION}" | tr '[:upper:]' '[:lower:]' | tr -d .) | ||
export RESOURCE_GROUP="${RESOURCE_GROUP:-cluster-api-gallery}" | ||
export RESOURCE_GROUP_NAME="${RESOURCE_GROUP}" | ||
export SIG_OFFER="reference-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-sig-${os}-${version}"}" | ||
export TAGS="${TAGS:-creationTimestamp=${TIMESTAMP} jobName=${JOB_NAME} DO-NOT-DELETE=UpstreamInfra}" | ||
printf "${TAGS}" | tee packer/azure/tags.out | ||
export GALLERY_NAME="${STAGING_GALLERY_NAME:-staging_gallery}" | ||
DISTRO="${os}-${version}" | ||
echo "##vso[task.setvariable variable=DISTRO]$DISTRO" | ||
# Add build tags in ADO | ||
echo "##vso[build.addbuildtag]$KUBERNETES_VERSION" | ||
echo "##vso[build.addbuildtag]$DISTRO" | ||
export PACKER_FLAGS="${PACKER_FLAGS} --var sig_image_version=${KUBERNETES_VERSION}" | ||
export USE_AZURE_CLI_AUTH="True" | ||
make build-azure-sig-$os-$version | tee packer/azure/packer.out | ||
- template: sig-publishing-info.yaml | ||
- task: PublishPipelineArtifact@1 | ||
inputs: | ||
artifact: 'publishing-info' | ||
path: '$(system.defaultWorkingDirectory)/images/capi/packer/azure/sig-publishing-info.json' |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# Required pipeline variables: | ||
# - BUILD_POOL - Azure DevOps build pool to use | ||
# - SERVICE_CONNECTION - Azure DevOps service connection to use for the Azure CLI | ||
# Optional pipeline variables: | ||
# - RESOURCE_GROUP - name of the Azure resource group to use for the compute galleries | ||
# - STAGING_GALLERY_NAME - name of the Azure compute gallery for initial image publishing | ||
|
||
jobs: | ||
- job: clean_sig | ||
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/sig/ | ||
- script: | | ||
set -euo pipefail | ||
[[ -n ${DEBUG:-} ]] && set -o xtrace | ||
SHARED_IMAGE_GALLERY_IMAGE_NAME=$(jq -r .shared_image_gallery_image_name $(system.defaultWorkingDirectory)/images/capi/packer/azure/sig/sig-publishing-info.json) | ||
SHARED_IMAGE_GALLERY_IMAGE_VERSION=$(jq -r .shared_image_gallery_image_version $(system.defaultWorkingDirectory)/images/capi/packer/azure/sig/sig-publishing-info.json) | ||
echo "##vso[task.setvariable variable=SHARED_IMAGE_GALLERY_IMAGE_NAME]$SHARED_IMAGE_GALLERY_IMAGE_NAME" | ||
echo "##vso[task.setvariable variable=SHARED_IMAGE_GALLERY_IMAGE_VERSION]$SHARED_IMAGE_GALLERY_IMAGE_VERSION" | ||
displayName: Import variables from build SIG job | ||
- task: AzureCLI@2 | ||
displayName: Clean up staging resources | ||
inputs: | ||
azureSubscription: '$(SERVICE_CONNECTION)' | ||
scriptLocation: inlineScript | ||
scriptType: bash | ||
workingDirectory: '$(system.defaultWorkingDirectory)/images/capi' | ||
inlineScript: | | ||
set -euo pipefail | ||
GALLERY_NAME="${STAGING_GALLERY_NAME:-staging_gallery}" | ||
RESOURCE_GROUP="${RESOURCE_GROUP:-cluster-api-gallery}" | ||
az sig image-version delete \ | ||
--resource-group ${RESOURCE_GROUP} \ | ||
--gallery-name ${GALLERY_NAME} \ | ||
--gallery-image-definition ${SHARED_IMAGE_GALLERY_IMAGE_NAME} \ | ||
--gallery-image-version ${SHARED_IMAGE_GALLERY_IMAGE_VERSION} |
This file was deleted.
Oops, something went wrong.
36 changes: 0 additions & 36 deletions
36
images/capi/packer/azure/.pipelines/create-disk-version.yaml
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
17 changes: 0 additions & 17 deletions
17
images/capi/packer/azure/.pipelines/delete-storage-account.yaml
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.