|
1 | | -# This Github Action will build and publish images to Azure Container Registry(ACR), from where the published images will be |
2 | | -# automatically pushed to the trusted registry, Microsoft Container Registry(MCR). |
| 1 | +# This Github Action will build and publish images to Azure Container Registry (ACR), from where the published images will be |
| 2 | +# automatically pushed to the trusted registry, Microsoft Container Registry (MCR). |
| 3 | + |
| 4 | +# TO-DO (chenyu1): evaluate if we need to hide arch-specific images in ACR. |
3 | 5 |
|
4 | 6 | name: Building and Pushing to MCR |
5 | 7 | on: |
6 | | - pull_request: |
7 | | - branches: |
8 | | - - main |
| 8 | + workflow_dispatch: |
| 9 | + inputs: |
| 10 | + releaseTag: |
| 11 | + description: 'Release tag to publish images, defaults to the latest one' |
| 12 | + type: string |
9 | 13 |
|
10 | 14 | permissions: |
11 | 15 | id-token: write |
@@ -52,66 +56,203 @@ jobs: |
52 | 56 | # NOTE: As exporting a variable from a secret is not possible, the shared variable registry obtained |
53 | 57 | # from AZURE_REGISTRY secret is not exported from here. |
54 | 58 |
|
| 59 | + publish-images-amd64: |
| 60 | + runs-on: |
| 61 | + labels: [self-hosted, "1ES.Pool=1es-aks-fleet-pool-ubuntu"] |
| 62 | + needs: prepare-variables |
| 63 | + steps: |
| 64 | + - uses: actions/checkout@v5 |
| 65 | + with: |
| 66 | + ref: ${{ needs.prepare-variables.outputs.release_tag }} |
| 67 | + - name: 'Login the ACR' |
| 68 | + run: | |
| 69 | + az login --identity |
| 70 | + az acr login -n ${{ secrets.AZURE_REGISTRY }} |
| 71 | + - name: Build and publish hub-agent |
| 72 | + run: | |
| 73 | + make docker-build-hub-agent |
| 74 | + env: |
| 75 | + HUB_AGENT_IMAGE_VERSION: ${{ needs.prepare-variables.outputs.release_tag }}-amd64 |
| 76 | + REGISTRY: ${{ secrets.AZURE_REGISTRY }}/${{ env.REGISTRY_REPO}} |
| 77 | + - name: Build and publish member-agent |
| 78 | + run: | |
| 79 | + make docker-build-member-agent |
| 80 | + env: |
| 81 | + MEMBER_AGENT_IMAGE_VERSION: ${{ needs.prepare-variables.outputs.release_tag }}-amd64 |
| 82 | + REGISTRY: ${{ secrets.AZURE_REGISTRY }}/${{ env.REGISTRY_REPO}} |
| 83 | + - name: Build and publish refresh-token |
| 84 | + run: | |
| 85 | + make docker-build-refresh-token |
| 86 | + env: |
| 87 | + REFRESH_TOKEN_IMAGE_VERSION: ${{ needs.prepare-variables.outputs.release_tag }}-amd64 |
| 88 | + REGISTRY: ${{ secrets.AZURE_REGISTRY }}/${{ env.REGISTRY_REPO}} |
| 89 | + - name: Build and publish crd-installer |
| 90 | + run: | |
| 91 | + make docker-build-crd-installer |
| 92 | + env: |
| 93 | + CRD_INSTALLER_IMAGE_VERSION: ${{ needs.prepare-variables.outputs.release_tag }}-amd64 |
| 94 | + REGISTRY: ${{ secrets.AZURE_REGISTRY }}/${{ env.REGISTRY_REPO}} |
| 95 | + # Build Arc Extension for member clusters |
| 96 | + # Arc-connected clusters can join fleets as member clusters through an Arc Extension. |
| 97 | + # An Arc Extension is a packaged Helm chart that gets deployed to Arc clusters. |
| 98 | + # This step packages both the fleet member agent and networking agents into a single |
| 99 | + # Helm chart for Arc deployment, since Arc Extensions require all components to be bundled together. |
| 100 | + - name: Build and publish ARC member cluster agents helm chart |
| 101 | + run: | |
| 102 | + make helm-package-arc-member-cluster-agents |
| 103 | + env: |
| 104 | + ARC_MEMBER_AGENT_HELMCHART_VERSION: ${{ needs.prepare-variables.outputs.arc_helmchart_version }} |
| 105 | + MEMBER_AGENT_IMAGE_VERSION: ${{ needs.prepare-variables.outputs.release_tag }} |
| 106 | + REFRESH_TOKEN_IMAGE_VERSION: ${{ needs.prepare-variables.outputs.release_tag }} |
| 107 | + CRD_INSTALLER_IMAGE_VERSION: ${{ needs.prepare-variables.outputs.release_tag }} |
| 108 | + MCS_CONTROLLER_IMAGE_VERSION: ${{ needs.prepare-variables.outputs.fleet_networking_version }} |
| 109 | + MEMBER_NET_CONTROLLER_IMAGE_VERSION: ${{ needs.prepare-variables.outputs.fleet_networking_version }} |
| 110 | + REGISTRY: ${{ secrets.AZURE_REGISTRY }}/${{ env.ARC_REGISTRY_REPO}} |
| 111 | + |
| 112 | + publish-images-arm64: |
| 113 | + runs-on: |
| 114 | + labels: [self-hosted, "1ES.Pool=1es-aks-fleet-pool-ubuntu-arm64"] |
| 115 | + needs: prepare-variables |
| 116 | + steps: |
| 117 | + - uses: actions/checkout@v5 |
| 118 | + with: |
| 119 | + ref: ${{ needs.prepare-variables.outputs.release_tag }} |
| 120 | + - name: 'Install the Azure CLI' |
| 121 | + # Note (chenyu1): the self-hosted 1ES ARM64 pool, for some reason, does not have Azure CLI installed by default; |
| 122 | + # install it manually here. |
| 123 | + run: |
| 124 | + curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash |
| 125 | + - name: 'Set up build dependencies' |
| 126 | + # Note (chenyu1): the self-hosted 1ES ARM64 pool, for some reason, does not have the common build |
| 127 | + # tools (e.g., make) installed by default; install them manually. |
| 128 | + run: | |
| 129 | + sudo apt-get update |
| 130 | + sudo apt-get install -y build-essential acl |
| 131 | + - name: 'Set up Docker' |
| 132 | + # Note (chenyu1): the self-hosted 1ES ARM64 pool, for some reason, does not have Docker installed by default, |
| 133 | + # and cannot have Docker installed via the docker/setup-docker-action Github Action, hence the manual setup |
| 134 | + # steps here. |
| 135 | + run: | |
| 136 | + sudo apt-get update |
| 137 | + sudo apt-get -y install ca-certificates curl |
| 138 | + sudo install -m 0755 -d /etc/apt/keyrings |
| 139 | + sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc |
| 140 | + sudo chmod a+r /etc/apt/keyrings/docker.asc |
| 141 | + echo \ |
| 142 | + "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \ |
| 143 | + $(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}") stable" | \ |
| 144 | + sudo tee /etc/apt/sources.list.d/docker.list > /dev/null |
| 145 | + sudo apt-get update |
| 146 | + sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin |
| 147 | + - name: 'Enable Docker access' |
| 148 | + # Note (chenyu1): there are situations where the newgrp command will not take effect; set access |
| 149 | + # to the docker daemon directly just in case. |
| 150 | + run: | |
| 151 | + sudo groupadd docker || true |
| 152 | + echo "Adding $USER to the docker group" |
| 153 | + sudo usermod -aG docker $USER |
| 154 | + newgrp docker |
| 155 | + sudo setfacl --modify user:$USER:rw /var/run/docker.sock |
| 156 | + - name: 'Login the ACR' |
| 157 | + # Note (chenyu1): must not use root privileges; the system seems to have some trouble |
| 158 | + # retrieving credentials when sudo is used. |
| 159 | + run: | |
| 160 | + az login --identity |
| 161 | + az acr login -n ${{ secrets.AZURE_REGISTRY }} |
| 162 | + - name: 'Verify Docker CLI' |
| 163 | + run: | |
| 164 | + docker version |
| 165 | + docker info |
| 166 | + - name: Build and publish hub-agent |
| 167 | + run: | |
| 168 | + make docker-build-hub-agent |
| 169 | + env: |
| 170 | + HUB_AGENT_IMAGE_VERSION: ${{ needs.prepare-variables.outputs.release_tag }}-arm64 |
| 171 | + REGISTRY: ${{ secrets.AZURE_REGISTRY }}/${{ env.REGISTRY_REPO}} |
| 172 | + TARGET_ARCH: arm64 |
| 173 | + - name: Build and publish member-agent |
| 174 | + run: | |
| 175 | + make docker-build-member-agent |
| 176 | + env: |
| 177 | + MEMBER_AGENT_IMAGE_VERSION: ${{ needs.prepare-variables.outputs.release_tag }}-arm64 |
| 178 | + REGISTRY: ${{ secrets.AZURE_REGISTRY }}/${{ env.REGISTRY_REPO}} |
| 179 | + TARGET_ARCH: arm64 |
| 180 | + - name: Build and publish refresh-token |
| 181 | + run: | |
| 182 | + make docker-build-refresh-token |
| 183 | + env: |
| 184 | + REFRESH_TOKEN_IMAGE_VERSION: ${{ needs.prepare-variables.outputs.release_tag }}-arm64 |
| 185 | + REGISTRY: ${{ secrets.AZURE_REGISTRY }}/${{ env.REGISTRY_REPO}} |
| 186 | + TARGET_ARCH: arm64 |
| 187 | + - name: Build and publish crd-installer |
| 188 | + run: | |
| 189 | + make docker-build-crd-installer |
| 190 | + env: |
| 191 | + CRD_INSTALLER_IMAGE_VERSION: ${{ needs.prepare-variables.outputs.release_tag }}-arm64 |
| 192 | + REGISTRY: ${{ secrets.AZURE_REGISTRY }}/${{ env.REGISTRY_REPO}} |
| 193 | + TARGET_ARCH: arm64 |
| 194 | + |
55 | 195 | create-image-manifest-bundle: |
56 | 196 | runs-on: |
57 | 197 | # Use the x86_64 1ES pool to run this job; in theory it can be run on the ARM64 1ES pool as well. |
58 | 198 | labels: [self-hosted, "1ES.Pool=1es-aks-fleet-pool-ubuntu"] |
59 | | - needs: prepare-variables |
60 | | - #needs: [publish-images-amd64, publish-images-arm64] |
| 199 | + needs: [prepare-variables, publish-images-amd64, publish-images-arm64] |
61 | 200 | steps: |
62 | 201 | - name: 'Wait until images are processed' |
| 202 | + # Note (chenyu1): as we are pulling from ACR rather than MCR, the images should be available almost |
| 203 | + # immediately after the push is done; the delay is added here as a precaution. |
63 | 204 | run: | |
64 | | - echo "Waiting for 10 minutes to ensure that images are fully processed in MCR" |
65 | | - sleep 10 |
| 205 | + echo "Waiting for 3 minutes to ensure that images are fully processed" |
| 206 | + sleep 180 |
66 | 207 | - name: 'Login the ACR' |
67 | 208 | run: | |
68 | 209 | az login --identity |
69 | | - az acr login -n aksmcrimagescommon |
| 210 | + az acr login -n ${{ secrets.AZURE_REGISTRY }} |
70 | 211 | - name: 'Pull the hub agent images from ACR' |
71 | 212 | # Note (chenyu1): must set the target platform explictly. |
72 | 213 | run: | |
73 | | - docker pull --platform linux/amd64 aksmcrimagescommon.azurecr.io/${{ env.REGISTRY_REPO}}/hub-agent:${{ needs.prepare-variables.outputs.release_tag }}-amd64 |
74 | | - docker pull --platform linux/arm64 aksmcrimagescommon.azurecr.io/${{ env.REGISTRY_REPO}}/hub-agent:${{ needs.prepare-variables.outputs.release_tag }}-arm64 |
| 214 | + docker pull --platform linux/amd64 ${{ secrets.AZURE_REGISTRY }}/${{ env.REGISTRY_REPO}}/hub-agent:${{ needs.prepare-variables.outputs.release_tag }}-amd64 |
| 215 | + docker pull --platform linux/arm64 ${{ secrets.AZURE_REGISTRY }}/${{ env.REGISTRY_REPO}}/hub-agent:${{ needs.prepare-variables.outputs.release_tag }}-arm64 |
75 | 216 | - name: 'Create and push multi-arch image manifests for the hub agent image' |
76 | 217 | # Note (chenyu1): use `docker buildx imagetools create`, otherwise attestations cannot be perserved. |
77 | 218 | run: | |
78 | 219 | docker buildx imagetools create \ |
79 | | - -t aksmcrimagescommon.azurecr.io/${{ env.REGISTRY_REPO}}/hub-agent:${{ needs.prepare-variables.outputs.release_tag }} \ |
80 | | - aksmcrimagescommon.azurecr.io/${{ env.REGISTRY_REPO}}/hub-agent:${{ needs.prepare-variables.outputs.release_tag }}-amd64 \ |
81 | | - aksmcrimagescommon.azurecr.io/${{ env.REGISTRY_REPO}}/hub-agent:${{ needs.prepare-variables.outputs.release_tag }}-arm64 |
| 220 | + -t ${{ secrets.AZURE_REGISTRY }}/${{ env.REGISTRY_REPO}}/hub-agent:${{ needs.prepare-variables.outputs.release_tag }} \ |
| 221 | + ${{ secrets.AZURE_REGISTRY }}/${{ env.REGISTRY_REPO}}/hub-agent:${{ needs.prepare-variables.outputs.release_tag }}-amd64 \ |
| 222 | + ${{ secrets.AZURE_REGISTRY }}/${{ env.REGISTRY_REPO}}/hub-agent:${{ needs.prepare-variables.outputs.release_tag }}-arm64 |
82 | 223 | - name: 'Pull the member agent images from ACR' |
83 | 224 | # Note (chenyu1): must set the target platform explictly. |
84 | 225 | run: | |
85 | | - docker pull --platform linux/amd64 aksmcrimagescommon.azurecr.io/${{ env.REGISTRY_REPO}}/member-agent:${{ needs.prepare-variables.outputs.release_tag }}-amd64 |
86 | | - docker pull --platform linux/arm64 aksmcrimagescommon.azurecr.io/${{ env.REGISTRY_REPO}}/member-agent:${{ needs.prepare-variables.outputs.release_tag }}-arm64 |
| 226 | + docker pull --platform linux/amd64 ${{ secrets.AZURE_REGISTRY }}/${{ env.REGISTRY_REPO}}/member-agent:${{ needs.prepare-variables.outputs.release_tag }}-amd64 |
| 227 | + docker pull --platform linux/arm64 ${{ secrets.AZURE_REGISTRY }}/${{ env.REGISTRY_REPO}}/member-agent:${{ needs.prepare-variables.outputs.release_tag }}-arm64 |
87 | 228 | - name: 'Create and push multi-arch image manifests for the member agent image' |
88 | 229 | # Note (chenyu1): use `docker buildx imagetools create`, otherwise attestations cannot be perserved. |
89 | 230 | run: | |
90 | 231 | docker buildx imagetools create \ |
91 | | - -t aksmcrimagescommon.azurecr.io/${{ env.REGISTRY_REPO}}/member-agent:${{ needs.prepare-variables.outputs.release_tag }} \ |
92 | | - aksmcrimagescommon.azurecr.io/${{ env.REGISTRY_REPO}}/member-agent:${{ needs.prepare-variables.outputs.release_tag }}-amd64 \ |
93 | | - aksmcrimagescommon.azurecr.io/${{ env.REGISTRY_REPO}}/member-agent:${{ needs.prepare-variables.outputs.release_tag }}-arm64 |
| 232 | + -t ${{ secrets.AZURE_REGISTRY }}/${{ env.REGISTRY_REPO}}/member-agent:${{ needs.prepare-variables.outputs.release_tag }} \ |
| 233 | + ${{ secrets.AZURE_REGISTRY }}/${{ env.REGISTRY_REPO}}/member-agent:${{ needs.prepare-variables.outputs.release_tag }}-amd64 \ |
| 234 | + ${{ secrets.AZURE_REGISTRY }}/${{ env.REGISTRY_REPO}}/member-agent:${{ needs.prepare-variables.outputs.release_tag }}-arm64 |
94 | 235 | - name: 'Pull the refresh token images from ACR' |
95 | 236 | # Note (chenyu1): must set the target platform explictly. |
96 | 237 | run: | |
97 | | - docker pull --platform linux/amd64 aksmcrimagescommon.azurecr.io/${{ env.REGISTRY_REPO}}/refresh-token:${{ needs.prepare-variables.outputs.release_tag }}-amd64 |
98 | | - docker pull --platform linux/arm64 aksmcrimagescommon.azurecr.io/${{ env.REGISTRY_REPO}}/refresh-token:${{ needs.prepare-variables.outputs.release_tag }}-arm64 |
| 238 | + docker pull --platform linux/amd64 ${{ secrets.AZURE_REGISTRY }}/${{ env.REGISTRY_REPO}}/refresh-token:${{ needs.prepare-variables.outputs.release_tag }}-amd64 |
| 239 | + docker pull --platform linux/arm64 ${{ secrets.AZURE_REGISTRY }}/${{ env.REGISTRY_REPO}}/refresh-token:${{ needs.prepare-variables.outputs.release_tag }}-arm64 |
99 | 240 | - name: 'Create and push multi-arch image manifests for the refresh token image' |
100 | 241 | # Note (chenyu1): use `docker buildx imagetools create`, otherwise attestations cannot be perserved. |
101 | 242 | run: | |
102 | 243 | docker buildx imagetools create \ |
103 | | - -t aksmcrimagescommon.azurecr.io/${{ env.REGISTRY_REPO}}/refresh-token:${{ needs.prepare-variables.outputs.release_tag }} \ |
104 | | - aksmcrimagescommon.azurecr.io/${{ env.REGISTRY_REPO}}/refresh-token:${{ needs.prepare-variables.outputs.release_tag }}-amd64 \ |
105 | | - aksmcrimagescommon.azurecr.io/${{ env.REGISTRY_REPO}}/refresh-token:${{ needs.prepare-variables.outputs.release_tag }}-arm64 |
| 244 | + -t ${{ secrets.AZURE_REGISTRY }}/${{ env.REGISTRY_REPO}}/refresh-token:${{ needs.prepare-variables.outputs.release_tag }} \ |
| 245 | + ${{ secrets.AZURE_REGISTRY }}/${{ env.REGISTRY_REPO}}/refresh-token:${{ needs.prepare-variables.outputs.release_tag }}-amd64 \ |
| 246 | + ${{ secrets.AZURE_REGISTRY }}/${{ env.REGISTRY_REPO}}/refresh-token:${{ needs.prepare-variables.outputs.release_tag }}-arm64 |
106 | 247 | - name: 'Pull the crd installer images from ACR' |
107 | 248 | # Note (chenyu1): must set the target platform explictly. |
108 | 249 | run: | |
109 | | - docker pull --platform linux/amd64 aksmcrimagescommon.azurecr.io/${{ env.REGISTRY_REPO}}/crd-installer:${{ needs.prepare-variables.outputs.release_tag }}-amd64 |
110 | | - docker pull --platform linux/arm64 aksmcrimagescommon.azurecr.io/${{ env.REGISTRY_REPO}}/crd-installer:${{ needs.prepare-variables.outputs.release_tag }}-arm64 |
| 250 | + docker pull --platform linux/amd64 ${{ secrets.AZURE_REGISTRY }}/${{ env.REGISTRY_REPO}}/crd-installer:${{ needs.prepare-variables.outputs.release_tag }}-amd64 |
| 251 | + docker pull --platform linux/arm64 ${{ secrets.AZURE_REGISTRY }}/${{ env.REGISTRY_REPO}}/crd-installer:${{ needs.prepare-variables.outputs.release_tag }}-arm64 |
111 | 252 | - name: 'Create and push multi-arch image manifests for the crd installer image' |
112 | 253 | # Note (chenyu1): use `docker buildx imagetools create`, otherwise attestations cannot be perserved. |
113 | 254 | run: | |
114 | 255 | docker buildx imagetools create \ |
115 | | - -t aksmcrimagescommon.azurecr.io/${{ env.REGISTRY_REPO}}/crd-installer:${{ needs.prepare-variables.outputs.release_tag }} \ |
116 | | - aksmcrimagescommon.azurecr.io/${{ env.REGISTRY_REPO}}/crd-installer:${{ needs.prepare-variables.outputs.release_tag }}-amd64 \ |
117 | | - aksmcrimagescommon.azurecr.io/${{ env.REGISTRY_REPO}}/crd-installer:${{ needs.prepare-variables.outputs.release_tag }}-arm64 |
| 256 | + -t ${{ secrets.AZURE_REGISTRY }}/${{ env.REGISTRY_REPO}}/crd-installer:${{ needs.prepare-variables.outputs.release_tag }} \ |
| 257 | + ${{ secrets.AZURE_REGISTRY }}/${{ env.REGISTRY_REPO}}/crd-installer:${{ needs.prepare-variables.outputs.release_tag }}-amd64 \ |
| 258 | + ${{ secrets.AZURE_REGISTRY }}/${{ env.REGISTRY_REPO}}/crd-installer:${{ needs.prepare-variables.outputs.release_tag }}-arm64 |
0 commit comments