Skip to content

Commit

Permalink
feat: Onboard Azure Linux 3.0 to AKS (Azure#4808)
Browse files Browse the repository at this point in the history
Signed-off-by: Aadhar Agarwal <[email protected]>
  • Loading branch information
aadhar-agarwal authored Sep 3, 2024
1 parent 2d670df commit 3523ef6
Show file tree
Hide file tree
Showing 471 changed files with 3,413 additions and 1,898 deletions.
150 changes: 150 additions & 0 deletions .pipelines/.vsts-vhd-builder-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ parameters:
displayName: Build AzureLinuxV2 Gen1
type: boolean
default: true
- name: buildAzureLinuxV3gen1
displayName: Build AzureLinuxV3 Gen1
type: boolean
default: false
- name: buildMarinerV2gen2
displayName: Build MarinerV2 Gen2
type: boolean
Expand All @@ -50,6 +54,10 @@ parameters:
displayName: Build AzureLinuxV2 Gen2
type: boolean
default: true
- name: buildAzureLinuxV3gen2
displayName: Build AzureLinuxV3 Gen2
type: boolean
default: true
- name: buildMarinerV2gen1fips
displayName: Build MarinerV2 Gen1 FIPS
type: boolean
Expand All @@ -58,6 +66,10 @@ parameters:
displayName: Build AzureLinuxV2 Gen1 FIPS
type: boolean
default: true
- name: buildAzureLinuxV3gen1fips
displayName: Build AzureLinuxV3 Gen1 FIPS
type: boolean
default: false
- name: buildMarinerV2gen2fips
displayName: Build MarinerV2 Gen2 FIPS
type: boolean
Expand All @@ -66,6 +78,10 @@ parameters:
displayName: Build AzureLinuxV2 Gen2 FIPS
type: boolean
default: true
- name: buildAzureLinuxV3gen2fips
displayName: Build AzureLinuxV3 Gen2 FIPS
type: boolean
default: false
- name: buildMarinerV2gen2kata
displayName: Build MarinerV2 Gen2 Kata
type: boolean
Expand All @@ -82,6 +98,10 @@ parameters:
displayName: Build AzureLinuxV2 Gen2 - ARM64
type: boolean
default: true
- name: buildAzureLinuxV3ARM64
displayName: Build AzureLinuxV3 Gen2 - ARM64
type: boolean
default: false
- name: buildMarinerV2gen2TrustedLaunch
displayName: Build MarinerV2 Gen2 - Trusted Launch
type: boolean
Expand Down Expand Up @@ -330,6 +350,32 @@ stages:
useOverrides: ${{ parameters.useOverrides }}
overrideBranch: ${{ parameters.overrideBranch }}
artifactName: azurelinuxv2-gen1
- job: buildAzureLinuxV3gen1
condition: eq('${{ parameters.buildAzureLinuxV3gen1 }}', true)
dependsOn: [ ]
timeoutInMinutes: 180
steps:
- bash: |
echo '##vso[task.setvariable variable=DRY_RUN]${{parameters.dryrun}}'
echo '##vso[task.setvariable variable=OS_SKU]AzureLinux'
echo '##vso[task.setvariable variable=OS_VERSION]V3'
echo '##vso[task.setvariable variable=IMG_PUBLISHER]MicrosoftCBLMariner'
echo '##vso[task.setvariable variable=IMG_OFFER]azure-linux-3'
echo '##vso[task.setvariable variable=IMG_SKU]azure-linux-3'
echo '##vso[task.setvariable variable=IMG_VERSION]latest'
echo '##vso[task.setvariable variable=HYPERV_GENERATION]V1'
echo '##vso[task.setvariable variable=AZURE_VM_SIZE]Standard_D16ds_v5'
echo '##vso[task.setvariable variable=FEATURE_FLAGS]None'
echo '##vso[task.setvariable variable=CONTAINER_RUNTIME]containerd'
echo '##vso[task.setvariable variable=ARCHITECTURE]X86_64'
echo '##vso[task.setvariable variable=ENABLE_FIPS]false'
echo '##vso[task.setvariable variable=ENABLE_TRUSTED_LAUNCH]False'
echo '##vso[task.setvariable variable=SGX_INSTALL]True'
echo '##vso[task.setvariable variable=ENABLE_CGROUPV2]True'
displayName: Setup Build Variables
- template: ./templates/.builder-release-template.yaml
parameters:
artifactName: azurelinuxv3-gen1
- job: buildMarinerV2gen2
condition: eq('${{ parameters.buildMarinerV2gen2 }}', true)
dependsOn: [ ]
Expand Down Expand Up @@ -386,6 +432,32 @@ stages:
useOverrides: ${{ parameters.useOverrides }}
overrideBranch: ${{ parameters.overrideBranch }}
artifactName: azurelinuxv2-gen2
- job: buildAzureLinuxV3gen2
condition: eq('${{ parameters.buildAzureLinuxV3gen2 }}', true)
dependsOn: [ ]
timeoutInMinutes: 180
steps:
- bash: |
echo '##vso[task.setvariable variable=DRY_RUN]${{parameters.dryrun}}'
echo '##vso[task.setvariable variable=OS_SKU]AzureLinux'
echo '##vso[task.setvariable variable=OS_VERSION]V3'
echo '##vso[task.setvariable variable=IMG_PUBLISHER]MicrosoftCBLMariner'
echo '##vso[task.setvariable variable=IMG_OFFER]azure-linux-3'
echo '##vso[task.setvariable variable=IMG_SKU]azure-linux-3-gen2'
echo '##vso[task.setvariable variable=IMG_VERSION]latest'
echo '##vso[task.setvariable variable=HYPERV_GENERATION]V2'
echo '##vso[task.setvariable variable=AZURE_VM_SIZE]Standard_D16ds_v5'
echo '##vso[task.setvariable variable=FEATURE_FLAGS]None'
echo '##vso[task.setvariable variable=CONTAINER_RUNTIME]containerd'
echo '##vso[task.setvariable variable=ARCHITECTURE]X86_64'
echo '##vso[task.setvariable variable=ENABLE_FIPS]false'
echo '##vso[task.setvariable variable=ENABLE_TRUSTED_LAUNCH]False'
echo '##vso[task.setvariable variable=SGX_INSTALL]True'
echo '##vso[task.setvariable variable=ENABLE_CGROUPV2]True'
displayName: Setup Build Variables
- template: ./templates/.builder-release-template.yaml
parameters:
artifactName: azurelinuxv3-gen2
- job: buildMarinerV2gen1fips
condition: eq('${{ parameters.buildMarinerV2gen1fips }}', true)
dependsOn: [ ]
Expand Down Expand Up @@ -442,6 +514,32 @@ stages:
useOverrides: ${{ parameters.useOverrides }}
overrideBranch: ${{ parameters.overrideBranch }}
artifactName: azurelinuxv2-gen1-fips
- job: buildAzureLinuxV3gen1fips
condition: eq('${{ parameters.buildAzureLinuxV3gen1fips }}', true)
dependsOn: [ ]
timeoutInMinutes: 180
steps:
- bash: |
echo '##vso[task.setvariable variable=DRY_RUN]${{parameters.dryrun}}'
echo '##vso[task.setvariable variable=OS_SKU]AzureLinux'
echo '##vso[task.setvariable variable=OS_VERSION]V3'
echo '##vso[task.setvariable variable=IMG_PUBLISHER]MicrosoftCBLMariner'
echo '##vso[task.setvariable variable=IMG_OFFER]azure-linux-3'
echo '##vso[task.setvariable variable=IMG_SKU]azure-linux-3'
echo '##vso[task.setvariable variable=IMG_VERSION]latest'
echo '##vso[task.setvariable variable=HYPERV_GENERATION]V1'
echo '##vso[task.setvariable variable=AZURE_VM_SIZE]Standard_D16ds_v5'
echo '##vso[task.setvariable variable=FEATURE_FLAGS]None'
echo '##vso[task.setvariable variable=CONTAINER_RUNTIME]containerd'
echo '##vso[task.setvariable variable=ARCHITECTURE]X86_64'
echo '##vso[task.setvariable variable=ENABLE_FIPS]True'
echo '##vso[task.setvariable variable=ENABLE_TRUSTED_LAUNCH]False'
echo '##vso[task.setvariable variable=SGX_INSTALL]True'
echo '##vso[task.setvariable variable=ENABLE_CGROUPV2]True'
displayName: Setup Build Variables
- template: ./templates/.builder-release-template.yaml
parameters:
artifactName: azurelinuxv3-gen1-fips
- job: buildMarinerV2gen2fips
condition: eq('${{ parameters.buildMarinerV2gen2fips }}', true)
dependsOn: [ ]
Expand Down Expand Up @@ -498,6 +596,32 @@ stages:
useOverrides: ${{ parameters.useOverrides }}
overrideBranch: ${{ parameters.overrideBranch }}
artifactName: azurelinuxv2-gen2-fips
- job: buildAzureLinuxV3gen2fips
condition: eq('${{ parameters.buildAzureLinuxV3gen2fips }}', true)
dependsOn: [ ]
timeoutInMinutes: 180
steps:
- bash: |
echo '##vso[task.setvariable variable=DRY_RUN]${{parameters.dryrun}}'
echo '##vso[task.setvariable variable=OS_SKU]AzureLinux'
echo '##vso[task.setvariable variable=OS_VERSION]V3'
echo '##vso[task.setvariable variable=IMG_PUBLISHER]MicrosoftCBLMariner'
echo '##vso[task.setvariable variable=IMG_OFFER]azure-linux-3'
echo '##vso[task.setvariable variable=IMG_SKU]azure-linux-3-gen2'
echo '##vso[task.setvariable variable=IMG_VERSION]latest'
echo '##vso[task.setvariable variable=HYPERV_GENERATION]V2'
echo '##vso[task.setvariable variable=AZURE_VM_SIZE]Standard_D16ds_v5'
echo '##vso[task.setvariable variable=FEATURE_FLAGS]None'
echo '##vso[task.setvariable variable=CONTAINER_RUNTIME]containerd'
echo '##vso[task.setvariable variable=ARCHITECTURE]X86_64'
echo '##vso[task.setvariable variable=ENABLE_FIPS]True'
echo '##vso[task.setvariable variable=ENABLE_TRUSTED_LAUNCH]False'
echo '##vso[task.setvariable variable=SGX_INSTALL]True'
echo '##vso[task.setvariable variable=ENABLE_CGROUPV2]True'
displayName: Setup Build Variables
- template: ./templates/.builder-release-template.yaml
parameters:
artifactName: azurelinuxv3-gen2-fips
- job: buildMarinerV2ARM64
condition: eq('${{ parameters.buildMarinerV2ARM64 }}', true)
dependsOn: [ ]
Expand Down Expand Up @@ -554,6 +678,32 @@ stages:
useOverrides: ${{ parameters.useOverrides }}
overrideBranch: ${{ parameters.overrideBranch }}
artifactName: azurelinuxv2-gen2-arm64
- job: buildAzureLinuxV3ARM64
condition: eq('${{ parameters.buildAzureLinuxV3ARM64 }}', true)
dependsOn: [ ]
timeoutInMinutes: 180
steps:
- bash: |
echo '##vso[task.setvariable variable=DRY_RUN]${{parameters.dryrun}}'
echo '##vso[task.setvariable variable=OS_SKU]AzureLinux'
echo '##vso[task.setvariable variable=OS_VERSION]V3'
echo '##vso[task.setvariable variable=IMG_PUBLISHER]MicrosoftCBLMariner'
echo '##vso[task.setvariable variable=IMG_OFFER]azure-linux-3'
echo '##vso[task.setvariable variable=IMG_SKU]azure-linux-3-arm64'
echo '##vso[task.setvariable variable=IMG_VERSION]latest'
echo '##vso[task.setvariable variable=HYPERV_GENERATION]V2'
echo '##vso[task.setvariable variable=AZURE_VM_SIZE]Standard_D16pds_v5'
echo '##vso[task.setvariable variable=FEATURE_FLAGS]None'
echo '##vso[task.setvariable variable=CONTAINER_RUNTIME]containerd'
echo '##vso[task.setvariable variable=ARCHITECTURE]ARM64'
echo '##vso[task.setvariable variable=ENABLE_FIPS]false'
echo '##vso[task.setvariable variable=ENABLE_TRUSTED_LAUNCH]False'
echo '##vso[task.setvariable variable=SGX_INSTALL]False'
echo '##vso[task.setvariable variable=ENABLE_CGROUPV2]True'
displayName: Setup Build Variables
- template: ./templates/.builder-release-template.yaml
parameters:
artifactName: azurelinuxv3-gen2-arm64
- job: buildMarinerV2gen2kata
condition: eq('${{ parameters.buildMarinerV2gen2kata }}', true)
dependsOn: [ ]
Expand Down
4 changes: 2 additions & 2 deletions .pipelines/templates/.builder-release-template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,10 @@ steps:
- bash: |
SKU_NAME=${OS_VERSION} && \
if [[ "${HYPERV_GENERATION,,}" == "v2" ]]; then SKU_NAME="${SKU_NAME}gen2"; fi && \
if [[ ${OS_VERSION} == "V2" && ${ARCHITECTURE,,} == "arm64" ]]; then SKU_NAME="${SKU_NAME}arm64"; fi && \
if [[ "${IMG_PUBLISHER}" == "MicrosoftCBLMariner" && ${ARCHITECTURE,,} == "arm64" ]]; then SKU_NAME="${SKU_NAME}arm64"; fi && \
if [[ (${OS_VERSION} == "22.04" || ${OS_VERSION} == "24.04") && ${ARCHITECTURE,,} == "arm64" ]]; then SKU_NAME="${SKU_NAME}arm64"; fi && \
if [[ (${OS_VERSION} == "18.04" || ${OS_VERSION} == "20.04" || ${OS_VERSION} == "22.04") && ${ENABLE_FIPS,,} == "true" ]]; then SKU_NAME="${SKU_NAME}fips"; fi && \
if [[ ${OS_VERSION} == "V2" && ${ENABLE_FIPS,,} == "true" ]]; then SKU_NAME="${SKU_NAME}fips"; fi && \
if [[ "${IMG_PUBLISHER}" == "MicrosoftCBLMariner" && ${ENABLE_FIPS,,} == "true" ]]; then SKU_NAME="${SKU_NAME}fips"; fi && \
if [[ "$(FEATURE_FLAGS)" == *"fullgpu"* ]]; then SKU_NAME="${SKU_NAME}gpu"; fi && \
if [[ "${IMG_SKU}" == "20_04-lts-cvm" ]]; then SKU_NAME="${SKU_NAME}CVM"; fi && \
if [[ "${IMG_SKU}" == *"minimal"* ]]; then SKU_NAME="${SKU_NAME}minimal"; fi && \
Expand Down
14 changes: 8 additions & 6 deletions parts/linux/cloud-init/artifacts/cis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ fixUmaskSettings() {
replaceOrAppendLoginDefs UMASK 027

# It also requires that nothing in etc/profile.d sets umask to anything less restrictive than that.
# Mariner sets umask directly in /etc/profile after sourcing everything in /etc/profile.d. But it also has /etc/profile.d/umask.sh
# Mariner/AzureLinux sets umask directly in /etc/profile after sourcing everything in /etc/profile.d. But it also has /etc/profile.d/umask.sh
# which sets umask (but is then ignored). We don't want to simply delete /etc/profile.d/umask.sh, because if we take an update to
# the package that supplies it, it would just be copied over again.
# This is complicated by an oddity/bug in the auditing script cis uses, which will flag line in a file with the work umask in the file name
Expand All @@ -173,25 +173,27 @@ fixUmaskSettings() {
# it does no harm and works with the tools.
# Note that we use printf to avoid a trailing newline.
local umask_sh="/etc/profile.d/umask.sh"
if [[ "${OS}" == "${MARINER_OS_NAME}" && "${OS_VERSION}" == "2.0" && -f "${umask_sh}" ]]; then
printf "umask 027" >${umask_sh}
if isMarinerOrAzureLinux "$OS"; then
if [[ -f "${umask_sh}" ]]; then
printf "umask 027" >${umask_sh}
fi
fi
}

function maskNfsServer() {
# If nfs-server.service exists, we need to mask it per CIS requirement.
# Note that on ubuntu systems, it isn't installed but on mariner we need it
# Note that on ubuntu systems, it isn't installed but on mariner/azurelinux we need it
# due to a dependency, but disable it by default.
if systemctl list-unit-files nfs-server.service >/dev/null; then
systemctl --now mask nfs-server || $ERR_SYSTEMCTL_MASK_FAIL
fi
}

function addFailLockDir() {
# Mariner V2 uses pamd faillocking, which requires a directory to store the faillock files.
# Mariner/AzureLinux uses pamd faillocking, which requires a directory to store the faillock files.
# Default is /var/run/faillock, but that's a tmpfs, so we need to use /var/log/faillock instead.
# But we need to leave settings alone for other skus.
if [[ "${OS}" == "${MARINER_OS_NAME}" && "${OS_VERSION}" == "2.0" ]]; then
if isMarinerOrAzureLinux "$OS" ; then
# Replace or append the dir setting in /etc/security/faillock.conf
# Docs: https://www.man7.org/linux/man-pages/man5/faillock.conf.5.html
#
Expand Down
14 changes: 14 additions & 0 deletions parts/linux/cloud-init/artifacts/components.json
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,13 @@
"1.1.9-5.cm2"
]
}
},
"azurelinux": {
"current": {
"versions": [
"1.1.12-1.azl3"
]
}
}
}
},
Expand Down Expand Up @@ -454,6 +461,13 @@
]
}
},
"azurelinux": {
"current": {
"versions": [
"1.7.13-3.azl3"
]
}
},
"default": {
"current": {
"versions": [
Expand Down
8 changes: 4 additions & 4 deletions parts/linux/cloud-init/artifacts/cse_config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ EOF
}

configureHTTPProxyCA() {
if [[ $OS == $MARINER_OS_NAME ]]; then
if isMarinerOrAzureLinux "$OS"; then
cert_dest="/usr/share/pki/ca-trust-source/anchors"
update_cmd="update-ca-trust"
else
Expand Down Expand Up @@ -680,9 +680,9 @@ configGPUDrivers() {
fi
docker rmi $NVIDIA_DRIVER_IMAGE:$NVIDIA_DRIVER_IMAGE_TAG
fi
elif [[ $OS == $MARINER_OS_NAME ]]; then
elif isMarinerOrAzureLinux "$OS"; then
downloadGPUDrivers
installNvidiaContainerRuntime
installNvidiaContainerToolkit
enableNvidiaPersistenceMode
else
echo "os $OS not supported at this time. skipping configGPUDrivers"
Expand All @@ -694,7 +694,7 @@ configGPUDrivers() {
retrycmd_if_failure 120 5 25 ldconfig || exit $ERR_GPU_DRIVERS_START_FAIL

# Fix the NVIDIA /dev/char link issue
if [[ $OS == $MARINER_OS_NAME ]]; then
if isMarinerOrAzureLinux "$OS"; then
createNvidiaSymlinkToAllDeviceNodes
fi

Expand Down
20 changes: 15 additions & 5 deletions parts/linux/cloud-init/artifacts/cse_helpers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,11 @@ ERR_CREDENTIAL_PROVIDER_DOWNLOAD_TIMEOUT=205 # Timeout waiting for credential pr

ERR_CNI_VERSION_INVALID=206 # reference CNI (not azure cni) needs a valid version in components.json

# For both Ubuntu and Mariner, /etc/*-release should exist.
# For both Ubuntu and Mariner/AzureLinux, /etc/*-release should exist.
# In AzureLinux 3.0, /etc/*-release are symlinks to /usr/lib/*-release, so the find command includes -type f,l.
# For unit tests, the OS and OS_VERSION will be set in the unit test script.
# So whether it's if or else actually doesn't matter to our unit test.
if find /etc -type f -name "*-release" -print -quit 2>/dev/null | grep -q '.'; then
if find /etc -type f,l -name "*-release" -print -quit 2>/dev/null | grep -q '.'; then
OS=$(sort -r /etc/*-release | gawk 'match($0, /^(ID_LIKE=(coreos)|ID=(.*))$/, a) { print toupper(a[2] a[3]); exit }')
OS_VERSION=$(sort -r /etc/*-release | gawk 'match($0, /^(VERSION_ID=(.*))$/, a) { print toupper(a[2] a[3]); exit }' | tr -d '"')
else
Expand All @@ -123,6 +124,7 @@ fi
UBUNTU_OS_NAME="UBUNTU"
MARINER_OS_NAME="MARINER"
MARINER_KATA_OS_NAME="MARINERKATA"
AZURELINUX_OS_NAME="AZURELINUX"
KUBECTL=/usr/local/bin/kubectl
DOCKER=/usr/bin/docker
# this will be empty during VHD build
Expand Down Expand Up @@ -398,14 +400,22 @@ should_skip_nvidia_drivers() {
echo "$should_skip"
}

isMarinerOrAzureLinux() {
local os=$1
if [[ $os == $MARINER_OS_NAME ]] || [[ $os == $MARINER_KATA_OS_NAME ]] || [[ $os == $AZURELINUX_OS_NAME ]]; then
return 0
fi
return 1
}

installJq() {
# jq is not available until downloaded in install-dependencies.sh with the installDeps function
# but it is needed earlier to call the capture_benchmarks function in pre-install-dependencies.sh
output=$(jq --version)
if [ -n "$output" ]; then
echo "$output"
else
if [[ $OS == $MARINER_OS_NAME ]]; then
if isMarinerOrAzureLinux "$OS"; then
sudo tdnf install -y jq && echo "jq was installed: $(jq --version)"
else
apt_get_install 5 1 60 jq && echo "jq was installed: $(jq --version)"
Expand Down Expand Up @@ -474,8 +484,8 @@ returnRelease() {
local osVersionWithoutDot=$(echo "${osVersion}" | sed 's/\.//g')
#For UBUNTU, if $osVersion is 18.04 and "r1804" is also defined in components.json, then $release is set to "r1804"
#Similarly for 20.04 and 22.04. Otherwise $release is set to .current.
#For MARINER, the release is always set to "current" now.
if [[ "${os}" == "${MARINER_KATA_OS_NAME}" || "${os}" == "${MARINER_OS_NAME}" ]]; then
#For MARINER/AZURELINUX, the release is always set to "current" now.
if isMarinerOrAzureLinux "${os}"; then
return 0
fi
if [[ $(echo "${package}" | jq ".downloadURIs.ubuntu.\"r${osVersionWithoutDot}\"") != "null" ]]; then
Expand Down
Loading

0 comments on commit 3523ef6

Please sign in to comment.