0

I'm new to grafana and prometheus, started working on it from last few days. I'm having some issues. I build a new grafana image and I am using the official helm repo to install it. On using the official image its wotking but on using my image the Pod is showing error. Failed to pull image "my-registry/grafana:9.4.1": rpc error: code = Unknown desc = failed to pull and unpack image "docker.io/my-registry/grafana:9.4.1": failed to resolve reference "docker.io/my-registry/grafana:9.4.1": pull access denied, repository does not exist or may require authorization: server message: insufficient_scope: authorization failed On checking I understood that I need to add imagePullSecret but after add that too i'm having the issue. This is where I have added image pull secret

repository: my-registry/grafana
#Overrides the Grafana image tag whose default is the chart appVersion 
 tag: "9.4.1" 
 sha: ""
 pullPolicy: IfNotPresent
#Optionally specify an array of imagePullSecrets.
 #Secrets must be manually created in the namespace.
 #ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/
 #Can be templated.
 #pullSecrets:
 #- myRegistrKeySecretName
imagePullSecrets:
-name: secretname

What might be the issue here, any insights will be helpful

Tried adding docker secret with few indentation but still having same issue.

3 Answers3

1

I'm guessing your problem is the name of the image. I take it that you used your account to create a repository called "my-repository" in Docker Hub? In that case, the name of the image should be:

<your_dockerhub_username>/my-repository

not

my-repository/grafana

unless your Docker Hub username is my-repository and the name of the repository you created was grafana.

To verify this, go to

https://hub.docker.com/repositories/<your_user_name>

where you will see a list of all repositories. Go into the repo you are using there and you will see a Docker command provided that includes the name of your image. Something like:

docker push username/reponame:tagname

That is the image you should be using.

M B
  • 2,700
  • 2
  • 15
  • 20
  • Thanks for the input, Since I don't want to expose my registry name publically I have given it as my repository. Sorry for make a truble there, I will rename my repository to my registery. for pulling the image I use this command "docker pull my-repository/grafana:9.4.1" – Alexy Pulivelil Mar 13 '23 at 06:32
1

As cluster can pull the image from the public registry, I assume you are pulling docker images from a private registry and k8s cluter does not know the secrets. Please follow the following link to provide the required credentials and accesses:

Pull an Image from a Private Registry

Andromeda
  • 1,205
  • 1
  • 14
  • 21
  • Thanks a lot for sharing the document. I have already created the secret. On using kubectl get secret -n namesoace, my secret is listed. I have deployed other componets including prometheus with the smae secret and its work. What i'm facing is the I'm not sure how should i give imagepullsecret in the values file of grafana, I'm using official helm for deploying grafana. [Official Helm Repo](https://github.com/grafana/helm-charts/blob/6c1c75e59cf116766e61f1c7f77fea654f346cf2/charts/grafana/values.yaml) Line no. 104 – Alexy Pulivelil Mar 13 '23 at 06:48
  • I do not think it is related to the helm chart. You mention the image address in the helm chart, k8s looks at your image addresses and tries to authenticate using the type of `kubernetes.io/dockerconfigjson` secret you provided and tries to log in. Could you pull an image from your private registry or the problem is just with the `grafana`? – Andromeda Mar 13 '23 at 06:55
  • I'm able to pull the images from private registry, I achieve this using the imagePullSecret. But in case of grafana image, I'm not able to pull the image from private repository, So thought its something related with Helm. If its not helm where should I look into. Can you share some insights on this – Alexy Pulivelil Mar 13 '23 at 07:10
  • Does the applied grafana deployment have the imagePullSecret section with the related secret name? – Andromeda Mar 13 '23 at 07:31
  • Yes, I will add the few line of code below `global: # To help compatibility with other charts which use global.imagePullSecrets. # Allow either an array of {name: pullSecret} maps (k8s-style), or an array of strings (more common helm-style). # Can be tempalted. # global: # imagePullSecrets: # - name: pullSecret1 # - name: pullSecret2 # or # global: # imagePullSecrets: # - pullSecret1 # - pullSecret2 imagePullSecrets: [] ` I tried adding here, But I was getting error. – Alexy Pulivelil Mar 13 '23 at 07:35
  • This is the [helm repo](https://github.com/grafana/helm-charts/blob/6c1c75e59cf116766e61f1c7f77fea654f346cf2/charts/grafana/values.yaml) – Alexy Pulivelil Mar 13 '23 at 07:39
  • Could you share the applied deployment not the helm values? – Andromeda Mar 13 '23 at 07:39
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/252482/discussion-between-alexy-pulivelil-and-andromeda). – Alexy Pulivelil Mar 13 '23 at 07:40
0

The error was because I gave imagePullSecret instead of pullSecret, which was mentioned in this file Grafan Helem After correcting it, the issue is solved