<p>I try to build a CI/CD Pipeline with Azure Devops.
My goal is to </p>

<ol>
<li><p>Build a docker Image an upload this to a private docker Respository in Dockerhub within the CI Pipeline</p></li>
<li><p>Deploy this image to an Azure Kubernetes Cluster within the CD Pipeline</p></li>
</ol>

<p>The CI Pipeline works well:
<a href="https://i.stack.imgur.com/dnsnn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dnsnn.png" alt="enter image description here"></a></p>

<p>The image is pushed successfully to dockerhub
<a href="https://i.stack.imgur.com/zzcc3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zzcc3.png" alt="enter image description here"></a></p>

<p>The pipeline docker push task:</p>

<pre><code>steps:
- task: Docker@1
  displayName: 'Push an image'
  inputs:
    containerregistrytype: 'Container Registry'
    dockerRegistryEndpoint: DockerHubConnection
    command: 'Push an image'
    imageName: 'jastechgmbh/microservice-demo:$(Build.BuildId)'
</code></pre>

<p>After that I trigger my release pipeline manually an it shows success as well
<a href="https://i.stack.imgur.com/4LvLD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4LvLD.png" alt="enter image description here"></a></p>

<p>The apply pipeline task:</p>

<pre><code>steps:
- task: Kubernetes@0
  displayName: 'kubectl apply'
  inputs:
    kubernetesServiceConnection: MicroserviceTestClusterConnection
    command: apply
    useConfigurationFile: true
    configuration:   '$(System.DefaultWorkingDirectory)/_MicroservicePlayground-MavenCI/drop/deployment.azure.yaml'
    containerRegistryType: 'Container Registry'
    dockerRegistryConnection: DockerHubConnection
</code></pre>

<p>But when I check the deployment on my kubernetes dashboard an error message pops up:
<a href="https://i.stack.imgur.com/OgumP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OgumP.png" alt="enter image description here"></a></p>

<p><strong>Failed to pull image "jastechgmbh/microservice-demo:38": rpc error: code = Unknown desc = Error response from daemon: pull access denied for jastechgmbh/microservice-demo, repository does not exist or may require 'docker login': denied: requested access to the resource is denied</strong></p>

<p>I use the same dockerhub service connection in the CI &amp; CD Pipeline. </p>

<p><a href="https://i.stack.imgur.com/E9Cfr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/E9Cfr.png" alt="enter image description here"></a></p>

<p><strong>I would be very happy about your help.</strong></p>

user8982746
<p>I believe this error indicates your kubernetes cluster doesnt have access to docker registry. You'd need to create docker secret for that. like so:</p>

<pre><code>kubectl create secret generic regcred \
  --from-file=.dockerconfigjson=&lt;path/to/.docker/config.json&gt; \
  --type=kubernetes.io/dockerconfigjson
</code></pre>

<p>or from command line:</p>

<pre><code>kubectl create secret docker-registry regcred --docker-server=&lt;your-registry-server&gt; --docker-username=&lt;your-name&gt; --docker-password=&lt;your-pword&gt; --docker-email=&lt;your-email&gt;
</code></pre>

<p><a href="https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/" rel="noreferrer">https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/</a></p>
