# Elasticsearch on Kubernetes not able to authenticate to azure container registry

**URL:** <https://discuss.elastic.co/t/elasticsearch-on-kubernetes-not-able-to-authenticate-to-azure-container-registry/291682>\
**Category:** Elastic Cloud on Kubernetes (ECK)\
**Tags:** docker\
**Created:** [December 13, 2021, 3:13pm UTC](https://discuss.elastic.co/t/elasticsearch-on-kubernetes-not-able-to-authenticate-to-azure-container-registry/291682 "2021-12-13T15:13:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![JaydeepUniverse](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jaydeepuniverse/32/98835_2.png) [@JaydeepUniverse](https://discuss.elastic.co/u/JaydeepUniverse)\
**Post date:** [December 13, 2021, 3:13pm UTC](https://discuss.elastic.co/t/elasticsearch-on-kubernetes-not-able-to-authenticate-to-azure-container-registry/291682/1 "2021-12-13T15:13:30Z")

</div>

I have created custom docker image of Elasticsearch which contains some plugins. Then published this docker image to azure container registry. Then I configured Elasticsearch spec as below

```auto
apiVersion: elasticsearch.k8s.elastic.co/v1
kind: Elasticsearch
metadata:
  name: liferay-elasticsearch
spec:
  image: liferay.azurecr.io/liferay/elasticsearch:7.16.0.customLiferayPlugin
  secureSettings:
  - secretName: acrlogin

```

Then I have executed this yaml file, but pod is not running, its showing error that `failed to authorize: failed to fetch anonymous token: unexpected status: 401 Unauthorized`

It seems the secret is not attaching with the pod definition.

The same credentials works for other docker images to pull.

Kindly advise.

Thanks

---

<div class="post-metadata">

**Author:** ![JaydeepUniverse](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jaydeepuniverse/32/98835_2.png) [@JaydeepUniverse](https://discuss.elastic.co/u/JaydeepUniverse)\
**Post date:** [December 13, 2021, 5:30pm UTC](https://discuss.elastic.co/t/elasticsearch-on-kubernetes-not-able-to-authenticate-to-azure-container-registry/291682/2 "2021-12-13T17:30:10Z")

</div>

I found the solution, the code should be like this:

```auto
apiVersion: elasticsearch.k8s.elastic.co/v1
kind: Elasticsearch
metadata:
  name: liferay-elasticsearch
spec:
  image: liferay.azurecr.io/liferay/elasticsearch:7.16.0.customLiferayPlugin
  version: 7.16.0
  nodeSets:
  - name: default
    count: 1
    podTemplate:
      spec:
        imagePullSecrets:
        - name: acrlogin

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [January 10, 2022, 5:30pm UTC](https://discuss.elastic.co/t/elasticsearch-on-kubernetes-not-able-to-authenticate-to-azure-container-registry/291682/3 "2022-01-10T17:30:32Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
