Working scenario:
i have prepared the image using following commands in docker desktop which you can see below and pushed to ACR and then successfully deployed that image using AKS
shyam@DESKTOP-OO7EVK2:~$ docker tag aksimage:latest acrrrr.azurecr.io/aksimage:latest
shyam@DESKTOP-OO7EVK2:~$ docker push acrrrr.azurecr.io/aksimage:latest
The push refers to repository [acrrrr.azurecr.io/aksimage]
1fe6f44321a3: Pushed
936898278d02: Pushed
a702764f6c9e: Pushed
2dee78b1264b: Pushed
06e3bc688725: Pushed
2a58e20c885d: Pushed
86becefdf252: Pushed
65c636ce09f2: Pushed
latest: digest: sha256:466e1fe0b6b9316a5c8c72c37e72934de9cb2ccf3f717841e448d59cbd06cc9f size: 1992
FYI: I used ubhuntu 22.4 LTS since my laptops windows 11 in my case
Below is not working scenario :
where as here I am using same commands but I am running from pipeline and used same commands you can see below and I am using ubhuntu latest as agent which you can see below, here also image gets pushed but when I deploy I am seeing following error when deploy it using AKS
variables:
imageName: 'aksimage'
dockerfilePath: 'Dockerfile'
buildContext: '.'
containerRegistry: 'acrrrr.azurecr.io'
dockerRegistryServiceConnection: 'acrserviceconnection'
tag: 'latest2' # Unique tag per build
pool:
vmImage: 'ubuntu-latest'
stages:
# ========================
# 🔧 BUILD STAGE
# ========================
- stage: Build
displayName: Build and Push Docker Image
jobs:
- job: Build
displayName: Docker Build, Tag, Push
steps:
- script: |
echo "Building image: $(imageName):$(tag) with platform linux/amd64"
docker build -t $(imageName):$(tag) -f $(dockerfilePath) $(buildContext)
docker tag $(imageName):$(tag) $(containerRegistry)/$(imageName):$(tag)
docker images
displayName: 'Build and Tag Docker Image'
- task: Docker@2
displayName: 'Push Docker Image to ACR'
inputs:
containerRegistry: 'ACR'
repository: '$(imageName)'
command: 'push'I
tags: '$(tag)'
I am seeing following events from POD :in non working scenario
DownwardAPI: true
QoS Class: BestEffort
Node-Selectors: <none>
Tolerations: node.kubernetes.io/not-ready:NoExecute op=Exists for 300s
node.kubernetes.io/unreachable:NoExecute op=Exists for 300s
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Scheduled 95s default-scheduler Successfully assigned default/aks-agent-deployment-5bc5ddf9b5-2tfkw to aks-np-36667834-vmss000001
Normal Pulling 94s kubelet Pulling image "acrrrr.azurecr.io/aksimage:latest2"
Normal Pulled 75s kubelet Successfully pulled image "acrrrr.azurecr.io/aksimage:latest2" in 18.364s (18.365s including waiting). Image size: 262281640 bytes.
Normal Created 28s (x4 over 75s) kubelet Created container: azp-agent
Normal Started 28s (x4 over 75s) kubelet Started container azp-agent
Normal Pulled 28s (x3 over 72s) kubelet Container image "acrrrr.azurecr.io/aksimage:latest2" already present on machine
Warning BackOff 0s (x6 over 71s) kubelet Back-off restarting failed container azp-agent in pod aks-agent-deployment-5bc5ddf9b5-2tfkw_default(9844a9b0-f1b4-4762-95f1-f846f4
Why it is failing during deployment? even both cases got pushed successfully , deployment failed in second scenario. it is same dockerfile and the code is same.
Please suggest