Deployment fails to Azure AKS from Bitbucket

I created a Bitbucket pipeline and trying yo deploy a basic pod to Azure AKS.
bitbucket-pipelines.yml is below;

image: atlassian/default-image:2

options:
  docker: true
pipelines:
  default:
    - step:
        name: Docker login
        caches:
           - docker
        script:
          - docker login -u $DOCKERHUB_USER -p $DOCKERHUB_PASSWORD
    - step:
        name: "Deploy to PROD"
        deployment: production
        script:
          - pipe: microsoft/azure-aks-deploy:1.0.0
            variables:
              AZURE_APP_ID: $AZURE_APP_ID
              AZURE_PASSWORD: $AZURE_PASSWORD
              AZURE_TENANT_ID: $AZURE_TENANT_ID
              AZURE_AKS_NAME: "demo-aks"
              AZURE_RESOURCE_GROUP: "demo-rg"
              KUBECTL_COMMAND: 'apply'
              KUBERNETES_SPEC_FILE: 'test.yaml'

and test.yaml file is below;

apiVersion: v1
kind: Pod
metadata:
  name: test
  labels:
    app: test
spec:
  containers:
  - name: test
    image: myrepository/test:1234
    command: ["/bin/sleep", "3650d"]
    imagePullPolicy: IfNotPresent
  restartPolicy: Always

"kubectl apply -f test-yaml" command seems successfully executed and it’s trying to create pod, but gives "docker login" error.

  Warning  Failed     9s (x2 over 24s)   kubelet            Failed to pull image "myrepository/test:1234": rpc error: code = Unknown desc = Error response from daemon: pull access denied for myrepository/test, repository does not exist or may require 'docker login': denied: requested access to the resource is denied
  Warning  Failed     9s (x2 over 24s)   kubelet            Error: ErrImagePul

Docker user and pass variables already added and they’re correct. Not sure where is the problem.
Thanks!

Source: Docker Questions

LEAVE A COMMENT