<p>I am building a small docker image of this way:</p>

<p>In my <code>Dockerfile</code> I am adding an specific configuration in <code>etc/apache2/apache2.conf</code> about redirect http to https rule:</p>

<p>Specifically this rule  </p>

<pre><code>&lt;VirtualHost *:80&gt;
RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-Proto} =http
RewriteRule .* https://%{HTTP:Host}%{REQUEST_URI} [L,R=permanent]
&lt;/VirtualHost&gt;
</code></pre>

<p>So, my <code>Dockerfile</code> is</p>

<pre><code>FROM wordpress:5.2.4

RUN apt-get update &amp;&amp; apt-get install -y \
    nano wget

COPY etc/apache2/apache2.conf /etc/apache2/apache2.conf
</code></pre>

<p>So, when it finish, I got two images in my local docker environment</p>

<pre><code>REPOSITORY                   TAG      
customize_wordpress          5.2.4     
wordpress                    5.2.4
</code></pre>

<p>Being <code>customize_wordpress:5.2.4</code> my personal image and  <code>wordpress:5.2.4</code> the base public image that I used at <code>FROM</code> instruction above in the Dockerfile</p>

<p>Like my purpose is upload my custom image <code>customize_wordpress:5.2.4</code> to azure container registry, I am following <a href="https://learn.microsoft.com/en-us/azure/container-registry/container-registry-get-started-docker-cli#create-an-alias-of-the-image" rel="nofollow noreferrer">this article</a> in order to do it</p>

<p>I am doing the <code>docker tag</code> command of this way</p>

<pre><code>docker tag customize_wordpress:5.2.4 registryname.azurecr.io/customize_wordpress:5.2.4
</code></pre>

<p>And it works.
Also  I push the image and it works as well </p>

<pre><code>⟩ docker push registryname.azurecr.io/customize_wordpress:5.2.4
The push refers to repository [registryname.azurecr.io/customize_wordpress]
b63469233da6: Pushed 
b032b61b15b2: Pushed  
12fe3564ccac: Pushed 
4e9b2aba858c: Pushed 
b67d19e65ef6: Pushed 
5.2.4: digest: sha256:dc62844f946a49f2e724fa38bad6e2cab73a4561b22b690876ab5534febd3569 size: 5128
[I] 
</code></pre>

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

<p>So, I have these data as a environment variables in order to pass them to the helm command</p>

<pre><code>export acr_login_server=registryname.azurecr.io
export acr_repository=customize_wordpress
export image_tag=5.2.4
</code></pre>

<p>But when I did the helm command</p>

<pre><code>⟩ helm3 install  wordpress-site-4 ./Deployments/Kubernetes/HelmCharts/wordpress/  --set image.registry=$acr_login_server,image.repository=$acr_repository,image.tag=$image_tag,image.pullPolicy=Always,wordpressUsername=$wordpressUsername,wordpressPassword=$wordpressPassword,wordpressEmail=$wordpressEmail,mariadb.enabled=false,externalDatabase.host=$database_host,externalDatabase.user=$database_user,externalDatabase.password=$database_password,externalDatabase.database=$database_name,externalDatabase.port=3306

</code></pre>

<p>I could see in my kubernetes environment that the pod say that the image is not pulled. I got</p>

<pre><code>Error response from daemon: pull access denied for customize_wordpress, repository does not exist or may require 'docker login': denied: requested access to the resource is denied
  Warning  Failed     2m20s (x4 over 3m39s)  kubelet, aks-defaultpool-34253081-vmss000001  Error: ErrImagePull
</code></pre>

<pre><code> Normal   Pulling    2m21s (x4 over 3m40s)  kubelet, aks-defaultpool-34253081-vmss000001  Pulling image "customize_wordpress:5.2.4"
  Warning  Failed     2m20s (x4 over 3m39s)  kubelet, aks-defaultpool-34253081-vmss000001  Failed to pull image "customize_wordpress:5.2.4": rpc error: code = Unknown desc = Error response from daemon: pull access denied for customize_wordpress, repository does not exist or may require 'docker login': denied: requested access to the resource is denied
  Warning  Failed     2m20s (x4 over 3m39s)  kubelet, aks-defaultpool-34253081-vmss000001  Error: ErrImagePull
  Normal   BackOff    114s (x6 over 3m38s)   kubelet, aks-defaultpool-34253081-vmss000001  Back-off pulling image "customize_wordpress:5.2.4"
  Warning  Failed     103s (x7 over 3m38s)   kubelet, aks-defaultpool-34253081-vmss000001  Error: ImagePullBackOff

</code></pre>

<p>I am doing this helm command from azure devops, and previously I logged in to my ACR of multiple ways such as:</p>

<pre><code>echo "Log in to an Azure Container Registry"
# docker login $(acr_login_server) --username $(service_principal_name_ci-cd-app-id) --password $(service_principal_name_ci-cd-password)
az acr login --name $(acr_name) 
</code></pre>

<p>But the result is the same from the pod, I cannot pull the image</p>

<p>That's why I consider that I don't need to reference the docker registry secrets inside kubernetes and in the <code>imagePullSecrets</code> attribute in the helm chart <code>values.yaml</code>. </p>

<p>Despite everything I try to create that docker registry secret with my acr data but the result is the same as well.</p>

<p>How can I upload my customize image and pull it from Kubernetes?</p>

bgarcial
<p>Like my AKS cluster and my azure container registry, both already do exist before the private image installation, I didn't realize that I had to associate the aks cluster with the Azure container registry</p>

<p>It says here <a href="https://learn.microsoft.com/en-us/azure/aks/cluster-container-registry-integration#configure-acr-integration-for-existing-aks-clusters" rel="nofollow noreferrer">https://learn.microsoft.com/en-us/azure/aks/cluster-container-registry-integration#configure-acr-integration-for-existing-aks-clusters</a></p>

<p>So, this is the complete workflow to build our private docker image, uploaded to our private container registry (in my case Azure Container Registry) and pull that image from Azure Kubernetes service:</p>

<ul>
<li>Build the image</li>
</ul>

<p><code>docker build -t customize_wordpress:5.2.4 .</code></p>

<p>It creates the <code>customize_wordpress:5.2.4</code> image</p>

<ul>
<li>Creating tag: We need to create a tag in order to upload  our image to our ACR
We have to include in the tag our ACR host server, in my case <code>registryname.azurecr.io</code> 
<a href="https://learn.microsoft.com/en-us/azure/container-registry/container-registry-get-started-docker-cli" rel="nofollow noreferrer">Here</a> for more information and <a href="https://docs.docker.com/engine/reference/commandline/tag/" rel="nofollow noreferrer">here</a></li>
</ul>

<pre><code>⟩ docker tag customize_wordpress:5.2.4 registryname.azurecr.io/customize_wordpress:5.2.4
</code></pre>

<ul>
<li>Push the image: Please, we have to be sure of use our complete tag created in the immediately previous step, I mean <code>registryname.azurecr.io/customize_wordpress:5.2.4</code></li>
</ul>

<pre><code>⟩ docker push registryname.azurecr.io/customize_wordpress:5.2.4
The push refers to repository [registryname.azurecr.io/customize_wordpress]
b63469233da6: Pushed 
b032b61b15b2: Pushed 
b67d19e65ef6: Pushed 
5.2.4: digest: sha256:dc62844f946a49f2e724fa38bad6e2cab73a4561b22b690876ab5534febd3569 size: 5128
</code></pre>

<p>And then before to install my Wordpress application, in my case from helm chart command (referenced above in my question), here comes <a href="https://learn.microsoft.com/en-us/azure/aks/cluster-container-registry-integration#configure-acr-integration-for-existing-aks-clusters" rel="nofollow noreferrer">the configuration of my ACR to work with my AKS cluster</a></p>

<p>I execute the <code>aks update</code> command:</p>

<pre><code>⟩ az aks update -n MyClusterName -g MyResourceGroup --attach-acr MyACRName
</code></pre>

<p>So, when I install my helm chart, the image is up and running </p>

<pre><code>Events:
  Type     Reason     Age                   From                                          Message
  ----     ------     ----                  ----                                          -------
  Normal   Scheduled  14m                   default-scheduler                             Successfully assigned default/wordpress-site-4-6565b8c64f-w7xvq to aks-defaultpool-34253081-vmss000000
  Normal   Pulling    14m                   kubelet, aks-defaultpool-34253081-vmss000000  Pulling image "registryname.azurecr.io/customize_wordpress:5.2.4"
  Normal   Pulled     14m                   kubelet, aks-defaultpool-34253081-vmss000000  Successfully pulled image "registryname.azurecr.io/customize_wordpress:5.2.4"
  Normal   Created    14m                   kubelet, aks-defaultpool-34253081-vmss000000  Created container wordpress

</code></pre>

<p>If we do that, we don't need to reference the docker registry secret and any <code>imagePullSecrets</code> attribute in our helm chart or yaml file, our image will be pulled without reference any credentials</p>
