222 questions
Deploy image is failing in AKS deploy stage
Diptesh Kumar
246
Reputation points
Build and deploy image stages are passing and I Can see image got pushed to ACR but when I see logs from pod I am seeing following error :
error:
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 83s default-scheduler Successfully assigned default/aks-agent-deployment-7c77d9996f-6jdqq to aks-sdf-30362432-vmss000000
Normal Pulling 82s kubelet Pulling image "acrnnn.azurecr.io/aksimage:v1"
Normal Pulled 56s kubelet Successfully pulled image "acrnnn.azurecr.io/aksimage:v1" in 25.517s (25.517s including waiting). Image size: 262508845 bytes.
Normal Created 42s (x3 over 56s) kubelet Created container: azp-agent
Normal Started 42s (x3 over 56s) kubelet Started container azp-agent
Normal Pulled 42s (x2 over 53s) kubelet Container image "acrnnn.azurecr.io/aksimage:v1" already present on machine
Warning BackOff 26s (x3 over 52s) kubelet Back-off restarting failed container azp-agent in pod aks-agent-deployment-7c77d9996f-6jdqq_default(dcea6c49-f3a2-41ab-b3d6-22b6563143ce)
and below is the pipeline used:
trigger:
- none
variables:
imageName: 'aksimage'
dockerfilePath: 'Dockerfile'
buildContext: '.'
acrLoginServer:: 'acrnnn.azurecr.io'
dockerRegistryServiceConnection: 'april28acr'
parameters:
- name: testtag
displayName: 'Tag to Build and Deploy'
type: string
default: 'latest'
pool:
vmImage: 'ubuntu-latest'
stages:
- stage: Build
displayName: Build and Push Docker Image
jobs:
- job: BuildJob
steps:
- checkout: self
- task: Docker@2
displayName: 'Build and Push Docker Image to ACR'
inputs:
containerRegistry: '$(dockerRegistryServiceConnection)' # <- not hardcoded 'scn'
repository: '$(imageName)' # just aksimage
command: 'buildAndPush'
Dockerfile: '$(dockerfilePath)'
buildContext: '$(buildContext)'
tags: |
${{ parameters.testtag }}
- task: PublishPipelineArtifact@1
displayName: 'Publish deployment.yaml as Artifact'
inputs:
targetPath: '$(Build.SourcesDirectory)/deployment.yaml'
artifactName: 'deployment-files'
# ========================
# 🚀 DEPLOY STAGE
# ========================
- stage: Deploy
displayName: Deploy to AKS
dependsOn: Build
condition: succeeded()
jobs:
- job: DeployJob
displayName: Deploy Using Updated Deployment.yaml
steps:
- checkout: self
- task: DownloadPipelineArtifact@2
displayName: 'Download Deployment Artifact'
inputs:
artifactName: 'deployment-files'
targetPath: '$(Build.SourcesDirectory)/deployment'
- task: Bash@3
name: ShowImageBeforeDeploy
displayName: 'Show Image Before Tag Replace'
inputs:
targetType: 'inline'
script: |
set -e
echo "✅ Image before replacement:"
grep "image:" $(Build.SourcesDirectory)/deployment.yaml
- task: Bash@3
name: ReplaceTag
displayName: 'Replace Image Tag'
inputs:
targetType: 'inline'
script: |
set -e
echo "🔧 Replacing __IMAGETAG__ with '${{ parameters.testtag }}'..."
sed "s|__IMAGETAG__|${{ parameters.testtag }}|g" $(Build.SourcesDirectory)/deployment.yaml > $(Build.SourcesDirectory)/updated-deployment.yaml
- task: Bash@3
name: ShowImageAfterDeploy
displayName: 'Show Image After Tag Replace'
inputs:
targetType: 'inline'
script: |
set -e
echo "✅ Image after replacement:"
grep "image:" $(Build.SourcesDirectory)/updated-deployment.yaml
- task: Kubernetes@1
displayName: 'Deploy to AKS Cluster'
inputs:
connectionType: 'Kubernetes Service Connection'
kubernetesServiceEndpoint: 'april28aks'
namespace: 'default'
command: 'apply'
useConfigurationFile: true
configuration: '$(Build.SourcesDirectory)/updated-deployment.yaml'
secretType: 'dockerRegistry'
containerRegistryType: 'Azure Container Registry'
Please suggest.
Sign in to answer