I am basically trying to pull GCR images from Azure kubernetes cluster. I have the folowing for my default service account:
kubectl get serviceaccounts default -o yaml
apiVersion: v1
imagePullSecrets:
- name: gcr-json-key-stg
kind: ServiceAccount
metadata:
creationTimestamp: "2019-12-24T03:42:15Z"
name: default
namespace: default
resourceVersion: "151571"
selfLink: /api/v1/namespaces/default/serviceaccounts/default
uid: 7f88785d-05de-4568-b050-f3a5dddd8ad1
secrets:
- name: default-token-gn9vb
If I add the same imagePullSecret
to individual deployments, it works. So, the secret is correct. However, when I use it for a default service account, I get a ImagePullBackOff
error which on describing confirms that it's a permission issue.
Am I missing something? I have made sure that my deployment is not configured with any other specific serviceaccount and should be using the default serviceaccount.
After you add the secret for pulling the image to the service account, then you need to add the service account into your pod or deployment. For example:
apiVersion: apps/v1
kind: Deployment
metadata:
name: helloworld-deployment
spec:
selector:
matchLabels:
run: helloworld
replicas: 1
template:
metadata:
labels:
app: helloworld
spec:
containers:
- name: helloworld
image: yourPrivateRegistry/image:tag
ports:
- containerPort: 80
serviceAccountName: pull-image # your service account
And the service account pull-image
looks like this:
ok, the problem was that the default
service account that I added the imagePullSecret
wasn't in the same namespace. Once, I patched the default service account in that namespace, it works perfectly well.