<p>I'm trying to deploy spring boot app to azure kubernetes cluster using pipelines setup in azure devops git repo. But the aks deployment is failing with the following error:</p>
<blockquote>
<p>Failed to pull image &quot;sapcemission.azurecr.io/spaceship&quot;: [rpc error:
code = Unknown desc = Error response from daemon: manifest for
sapcemission.azurecr.io/spaceship:latest not found: manifest unknown:
manifest tagged by &quot;latest&quot; is not found, rpc error: code = Unknown
desc = Error response from daemon: Get
https://sapcemission.azurecr.io/v2/spaceship/manifests/latest:
unauthorized: authentication required, visit
https://aka.ms/acr/authorization for more information.]</p>
</blockquote>
<p>My project is a spring boot multi-module project containing two modules. I'm trying to deploy them both. What am I doing wrong here?</p>
<p>azure-pipelines.yml</p>
<pre><code># Deploy to Azure Kubernetes Service
# Build and push image to Azure Container Registry; Deploy to Azure Kubernetes Service
# https://learn.microsoft.com/azure/devops/pipelines/languages/docker

trigger:
- master

resources:
- repo: self

variables:

  # Container registry service connection established during pipeline creation
  dockerRegistryServiceConnection: 'd5d300b9-b22f-4b38-a5c8-35526548a630'
  imageRepositoryCommandCenter: 'commandcenter'
  imageRepositorySpaceShip: 'spaceship'
  containerRegistry: 'sapcemissipion.azurecr.io'
  dockerfilePathCommandCenter: '**/command-center/Dockerfile'
  dockerfilePathSpaceShip: '**/space-ship/Dockerfile'
  tag: '$(Build.BuildId)'
  imagePullSecret: 'sapcemission13564b3d-auth'

  # Agent VM image name
  vmImageName: 'ubuntu-latest'
  

stages:
- stage: Build
  displayName: Build stage
  jobs:  
  - job: Build
    displayName: Build
    pool:
      vmImage: $(vmImageName)
    steps:
    - task: Maven@3
      inputs:
        mavenPomFile: 'pom.xml'
        publishJUnitResults: true
        testResultsFiles: '**/surefire-reports/TEST-*.xml'
        javaHomeOption: 'JDKVersion'
        mavenVersionOption: 'Default'
        mavenAuthenticateFeed: false
        effectivePomSkip: false
        sonarQubeRunAnalysis: false
    - task: Docker@2
      displayName: Build and push an command center image to container registry
      inputs:
        command: buildAndPush
        repository: $(imageRepositoryCommandCenter)
        dockerfile: $(dockerfilePathCommandCenter)
        containerRegistry: $(dockerRegistryServiceConnection)
        tags: |
          $(tag)
    - task: Docker@2
      displayName: Build and push an space ship image to container registry
      inputs:
        command: buildAndPush
        repository: $(imageRepositorySpaceShip)
        dockerfile: $(dockerfilePathSpaceShip)
        containerRegistry: $(dockerRegistryServiceConnection)
        tags: |
          $(tag)
          
    - upload: manifests
      artifact: manifests

- stage: Deploy
  displayName: Deploy stage
  dependsOn: Build

  jobs:
  - deployment: Deploy
    displayName: Deploy
    pool:
      vmImage: $(vmImageName)
    environment: 'spacemission-1550.kube-system'
    strategy:
      runOnce:
        deploy:
          steps:
          - task: KubernetesManifest@0
            displayName: Create imagePullSecret
            inputs:
              action: createSecret
              secretName: $(imagePullSecret)
              dockerRegistryEndpoint: $(dockerRegistryServiceConnection)
              
          - task: KubernetesManifest@0
            displayName: Deploy to Kubernetes cluster
            inputs:
              action: deploy
              manifests: |
                $(Pipeline.Workspace)/manifests/deployment.yml
                $(Pipeline.Workspace)/manifests/service.yml
              imagePullSecrets: |
                $(imagePullSecret)
              containers: |
                $(containerRegistry)/$(imageRepositoryCommandCenter):$(tag)
                $(containerRegistry)/$(imageRepositorySpaceShip):$(tag)
</code></pre>
<p>deployment.yml</p>
<pre><code>apiVersion : apps/v1beta1
kind: Deployment
metadata:
  name: commandcenter
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: commandcenter
    spec:
      containers:
        - name: commandcenter
          image: sapcemission.azurecr.io/commandcenter
          ports:
          - containerPort: 8080


---


apiVersion : apps/v1beta1
kind: Deployment
metadata:
  name: spaceship
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: spaceship
    spec:
      containers:
        - name: spaceship
          image: sapcemission.azurecr.io/spaceship
          ports:
          - containerPort: 8081
</code></pre>
<p>service.yml</p>
<pre><code>apiVersion: v1
kind: Service
metadata:
    name: commandcenter
spec:
    type: LoadBalancer
    ports:
    - port: 8080
    selector:
        app: commandcenter

---

apiVersion: v1
kind: Service
metadata:
    name: spaceship
spec:
    type: LoadBalancer
    ports:
        - port: 8080
    selector:
        app: spaceship
</code></pre>

<p>As the error shows the authentication is required. And I see you create the <code>imagePullSecret</code> so that you just need to add the imagePullSecret in the deployment of your YAML file like this:</p>
<pre><code>apiVersion : apps/v1beta1
kind: Deployment
metadata:
  name: commandcenter
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: commandcenter
    spec:
      containers:
        - name: commandcenter
          image: sapcemission.azurecr.io/commandcenter
          ports:
          - containerPort: 8080
      imagePullSecrets:                             # here
      - name: &quot;sapcemission13564b3d-auth&quot;
---
apiVersion : apps/v1beta1
kind: Deployment
metadata:
  name: spaceship
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: spaceship
    spec:
      containers:
        - name: spaceship
          image: sapcemission.azurecr.io/spaceship
          ports:
          - containerPort: 8081
      imagePullSecrets:                             # here                             
      - name: &quot;sapcemission13564b3d-auth&quot;
</code></pre>
<p>And the error also shows the image tag not found. So you need also to check if the tag really exists.</p>
